KickJava   Java API By Example, From Geeks To Geeks.

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


1 package polyglot.ext.coffer.extension;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.util.*;
6 import polyglot.ext.jl.ast.*;
7 import polyglot.ext.coffer.ast.*;
8 import polyglot.ext.coffer.types.*;
9
10 import java.util.*;
11
12 public class NewExt_c extends ProcedureCallExt_c {
13     public void checkHeldKeys(KeySet held, KeySet stored)
14         throws SemanticException
15     {
16         New n = (New) node();
17
18         CofferConstructorInstance vci =
19             (CofferConstructorInstance) n.constructorInstance();
20
21         super.checkHeldKeys(held, stored);
22
23         if (n.type() instanceof CofferClassType) {
24             Key key = ((CofferClassType) n.type()).key();
25
26             if (key != null) {
27                 if (held.contains(key) || stored.contains(key)) {
28                     throw new SemanticException(
29                         "Can evaluate \"new\" expression of type \"" +
30                         n.type() + "\" only if key \"" + key +
31                         "\" is not held.", n.position());
32                 }
33             }
34         }
35     }
36 }
37
Popular Tags