KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > coffer > extension > AssignDel_c


1 package polyglot.ext.coffer.extension;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.util.*;
6 import polyglot.visit.*;
7 import polyglot.ext.jl.ast.*;
8 import polyglot.ext.coffer.ast.*;
9 import polyglot.ext.coffer.types.*;
10
11 import java.util.*;
12
13 public class AssignDel_c extends JL_c {
14     public Node typeCheck(TypeChecker tc) throws SemanticException {
15         Assign n = (Assign) super.typeCheck(tc);
16
17         if (n.right().type() instanceof CofferClassType) {
18             CofferClassType t = (CofferClassType) n.right().type();
19
20             if (t.key() != null && n.left() instanceof Field) {
21                 throw new SemanticException("Cannot assign tracked value into a field.", n.position());
22             }
23             if (t.key() != null && n.left() instanceof ArrayAccess) {
24                 throw new SemanticException("Cannot assign tracked value into an array.", n.position());
25             }
26         }
27
28         return n;
29     }
30 }
31
Popular Tags