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 ProcedureCallExt_c extends CofferExt_c { 13 public KeySet keyFlow(KeySet held_keys, Type throwType) { 14 ProcedureCall n = (ProcedureCall) node(); 15 CofferProcedureInstance vmi = (CofferProcedureInstance) n.procedureInstance(); 16 17 if (throwType == null) { 18 return held_keys.removeAll(vmi.entryKeys()).addAll(vmi.returnKeys()); 19 } 20 21 for (Iterator i = vmi.throwConstraints().iterator(); i.hasNext(); ) { 22 ThrowConstraint c = (ThrowConstraint) i.next(); 23 if (throwType.equals(c.throwType())) { 24 return held_keys.removeAll(vmi.entryKeys()).addAll(c.keys()); 25 } 26 } 27 28 return held_keys; 30 } 31 32 public void checkHeldKeys(KeySet held, KeySet stored) throws SemanticException { 33 ProcedureCall n = (ProcedureCall) node(); 34 CofferProcedureInstance vmi = (CofferProcedureInstance) n.procedureInstance(); 35 36 if (! held.containsAll(vmi.entryKeys())) { 37 throw new SemanticException("Entry " + 38 keysToString(vmi.entryKeys()) + 39 " not held.", n.position()); 40 } 41 42 KeySet not_held = vmi.returnKeys().removeAll(vmi.entryKeys()); 44 not_held = not_held.retainAll(held); 45 46 if (! not_held.isEmpty()) { 47 throw new SemanticException("Cannot hold " + 48 keysToString(not_held) + " before " + 49 vmi.designator() + " entry.", 50 n.position()); 51 } 52 } 53 } 54 | Popular Tags |