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 FreeExt_c extends CofferExt_c { 13 public KeySet keyFlow(KeySet held_keys, Type throwType) { 14 Free f = (Free) node(); 15 16 Type t = f.expr().type(); 17 18 if (! (t instanceof CofferClassType)) { 19 return held_keys; 20 } 21 22 CofferClassType ct = (CofferClassType) t; 23 24 return held_keys.remove(ct.key()); 25 } 26 27 public void checkHeldKeys(KeySet held, KeySet stored) throws SemanticException { 28 Free f = (Free) node(); 29 30 Type t = f.expr().type(); 31 32 if (! (t instanceof CofferClassType)) { 33 throw new SemanticException("Cannot free expression of " + 34 "non-tracked type \"" + t + "\".", 35 f.position()); 36 } 37 38 CofferClassType ct = (CofferClassType) t; 39 40 if (! held.contains(ct.key())) { 41 throw new SemanticException("Key \"" + ct.key() + 42 "\" not held.", f.position()); 43 } 44 } 45 } 46 | Popular Tags |