KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > ast > AmbAssign_c


1 package polyglot.ext.jl.ast;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.visit.*;
6 import polyglot.util.*;
7 import java.util.*;
8
9 /**
10  * A <code>AmbAssign</code> represents a Java assignment expression to
11  * an as yet unknown expression.
12  */

13 public class AmbAssign_c extends Assign_c implements AmbAssign
14 {
15   public AmbAssign_c(Position pos, Expr left, Operator op, Expr right) {
16     super(pos, left, op, right);
17   }
18
19   public Term entry() {
20     if (operator() != Assign.ASSIGN) {
21       return left();
22     }
23
24     return right().entry();
25   }
26   
27   protected void acceptCFGAssign(CFGBuilder v) {
28       v.visitCFG(right(), this);
29   }
30   
31   protected void acceptCFGOpAssign(CFGBuilder v) {
32       v.edge(left(), right().entry());
33       v.visitCFG(right(), this);
34   }
35   
36   public Node disambiguate(AmbiguityRemover ar) throws SemanticException {
37       Assign n = (Assign) super.disambiguate(ar);
38       
39       if (n.left() instanceof Local) {
40           return ar.nodeFactory().LocalAssign(n.position(), (Local)left(), operator(), right());
41       }
42       else if (n.left() instanceof Field) {
43           return ar.nodeFactory().FieldAssign(n.position(), (Field)left(), operator(), right());
44       }
45       else if (n.left() instanceof ArrayAccess) {
46           return ar.nodeFactory().ArrayAccessAssign(n.position(), (ArrayAccess)left(), operator(), right());
47       }
48
49       throw new SemanticException("Could not disambiguate left side of assignment!", n.position());
50   }
51   
52 }
53
Popular Tags