KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > coffer > extension > LocalExt_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 LocalExt_c extends CofferExt_c {
13     public void checkHeldKeys(KeySet held, KeySet stored) throws SemanticException {
14         Local e = (Local) node();
15
16         if (e.type() instanceof CofferClassType) {
17             Key key = ((CofferClassType) e.type()).key();
18
19             if (key != null) {
20                 if (! stored.contains(key)) {
21                     throw new SemanticException(
22                         "Can evaluate expression of type \"" +
23                         e.type() + "\" only if key \"" + key +
24                         "\" is held by \"" + e.name() + "\".", e.position());
25
26                 }
27             }
28         }
29     }
30 }
31
Popular Tags