Beispiel #1
0
  public ExecutionContext createEvalExecutionContext(JSProgram eval, boolean direct) {
    // 10.4.2 (with caller)
    ExecutionContext context = null;

    Object evalThisBinding = null;
    LexicalEnvironment evalLexEnv = null;
    LexicalEnvironment evalVarEnv = null;

    if (!direct) {
      evalThisBinding = getGlobalObject();
      evalLexEnv = LexicalEnvironment.newGlobalEnvironment(getGlobalObject());
      evalVarEnv = LexicalEnvironment.newGlobalEnvironment(getGlobalObject());
    } else {
      evalThisBinding = this.thisBinding;
      evalLexEnv = this.getLexicalEnvironment();
      evalVarEnv = this.getVariableEnvironment();
    }

    if (eval.isStrict()) {
      LexicalEnvironment strictVarEnv =
          LexicalEnvironment.newDeclarativeEnvironment(this.getLexicalEnvironment());
      evalLexEnv = strictVarEnv;
      evalVarEnv = strictVarEnv;
    }

    context = new ExecutionContext(this, evalLexEnv, evalVarEnv, evalThisBinding, eval.isStrict());
    context.performFunctionDeclarationBindings(eval, true);
    context.performVariableDeclarationBindings(eval, true);
    context.fileName = eval.getFileName();
    return context;
  }
Beispiel #2
0
 public Completion execute(JSProgram program) {
   try {
     ThreadContextManager.pushContext(this);
     setStrict(program.isStrict());
     this.fileName = program.getFileName();
     performDeclarationBindingInstantiation(program);
     try {
       return program.execute(this);
     } catch (ThrowException e) {
       throw e;
     } catch (Throwable t) {
       throw new ThrowException(this, t);
     }
   } finally {
     ThreadContextManager.popContext();
   }
 }