示例#1
0
 // JL should we rename addhoistedCodeToCurrentContext to ...ComponentContext
 // or add further contexts here?
 public void addHoistedCodeToComponentContext(String s) {
   // look back the stack until we find a Component
   int lastIndex = bodyStack.size() - 1;
   for (int i = lastIndex; i > 0; i--) {
     ICode thisone = bodyStack.get(i);
     if (thisone instanceof Component) {
       ((IComponent) thisone).addHoistedCode(s);
       return;
     }
   }
   throw new RuntimeException("Didn't find Component when adding hoisted code");
 }
示例#2
0
 // JL should we look back on stack for next valid context for code hoisting e.g.
 // hoisting makes sense for ?expression?, procedure, behaviour, component, sequence ...
 public void addHoistedCodeToCurrentContext(String s) {
   // look back the stack until we find valid context for hoisting
   int lastIndex = bodyStack.size() - 1;
   for (int i = lastIndex; i >= 0; i--) {
     ICode thisone = bodyStack.get(i);
     if (thisone instanceof Sequence) {
       ((ISequence) thisone).addHoistedCode(s);
       return;
     } else if (thisone instanceof Function) {
       ((IFunction) thisone).addHoistedCode(s);
       return;
     } else if (thisone instanceof Behaviour) {
       ((IBehaviour) thisone).addHoistedCode(s);
       return;
     } else if (thisone instanceof Component) {
       ((IComponent) thisone).addHoistedCode(s);
       return;
     }
   }
   throw new RuntimeException("Didn't find suitable context for code hoisting");
 }