Evaluates the given function in the context of the web page. The execution is sandboxed, the web page has no access to the phantom object and it can't probe its own setting.
551058
function (expressionFn, callbackFn) {
                    var self = this,
                        url = self.options.hostAndPort + '/page/functions/evaluate';

                    self.options.debug && console.log('calling url: %s', url);

                    request.post(url, {
                            form:{expressionFn:expressionFn.toString(), args:JSON.stringify(Array.prototype.slice.call(arguments, 2, arguments.length), null, 4)}
                        },
                        function (error, response, body) {
                            if (response && response.statusCode === 200) {
                                callbackFn && callbackFn.call(self, JSON.parse(body));
                            }
                            else {
                                console.error(body);
                                callbackFn && callbackFn.call(self, body);
                            }
                        });
                }
909264
def evaluate(self, context):
        
        html = self._source.format(**context)
        parts = {"text/html": html, "text/plain": textFromHTML(html)}
        return {}, parts
1352559
private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException {
        try {
            Interpreter bsh = getInterpreter();
            NameSpace contextNameSpace = getEngineNameSpace(scriptContext);
            bsh.setNameSpace(contextNameSpace);

            bsh.setOut(toPrintStream(scriptContext.getWriter()));
            bsh.setErr(toPrintStream(scriptContext.getErrorWriter()));


            if (source instanceof Reader) {
                return bsh.eval((Reader) source);
            } else {
                return bsh.eval((String) source);
            }
        } catch (ParseException e) {
            // explicit parsing error
            throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
        } catch (TargetError e) {
            // The script threw an application level exception
            ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
            se.initCause(e.getTarget());
            throw se;
        } catch (EvalError e) {
            // The script couldn't be evaluated properly
            throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
        } catch (IOException e) {
            throw new ScriptException(e.toString());
        }
    }
8978
def evaluate(self, script):
        
        if WEBENGINE:
            return self.dom.runJavaScript("{}".format(script))
        else:
            return self.dom.evaluateJavaScript("{}".format(script))
952643
function evalModel(currentScope, scopeDefinition, partialModel, partialName) {
    if (!partialModel) { return; }

    var user = currentScope && currentScope.user;
    var activeUser = user ? {
        _id: user._id,
        name: user.username,
        role: user.role,
        user: user
    } : {};

    var opts = { dependencies: { currentScope: currentScope, activeUser: activeUser }};
    var me = this;

    // if its a function, then its our injection point
    if (_.isFunction(partialModel)) {
        updateScope(this.pancakes.cook(partialModel, opts), scopeDefinition, currentScope, partialName);
    }
    // else if its an object, we want to loop through the object values
    else if (_.isObject(partialModel)) {
        _.each(partialModel, function (partialModelVal, partialModelName) {

            // if the name is in the scope definition, throw error because it means we are trying to modify a parent scope value in the model
            if (scopeDefinition[partialModelName]) {
                throw new Error(partialName + 'mode() value ' + partialModelName + ' is from the parent scope and should not be modified in the mode().');
            }

            // any function in the object is an injection point
            if (_.isFunction(partialModelVal)) {
                updateScope(me.pancakes.cook(partialModelVal, opts), scopeDefinition, currentScope, partialName, partialModelName);
            }
            // else just set the value on the scope
            else {
                currentScope[partialModelName] = partialModelVal;
            }
        });
    }
    else {
        throw new Error(partialName + ' invalid model() format');
    }
}
973252
function evalModule( source, context ) {

    const argumentKeys = Object.keys( context );
    const argumentValues = argumentKeys.map( argument => context[ argument ] );

    const sandbox = { exports: {} };
    argumentKeys.push( "module", "exports", source );
    argumentValues.push( sandbox, sandbox.exports );

    Function( ...argumentKeys )( ...argumentValues );

    return sandbox.exports;

}
1225364
def evaluate_at(self, eval_at, testcases, mode=None):
        
        self.eval_at = eval_at
        self.log.eval_at = eval_at

        if mode is None:
            if self.context_mode is None or (self.context_mode.has_key('choose_m') and self.context_mode['choose_m']):
                mode = 'inverse'
            else:
                mode = self.context_mode["mode"]
                

        self.evaluation = Evaluation(self.ag, self.env, testcases, mode=mode)
        for test in testcases:
            self.log.add('testcases', test)
430317
@Override
    public int doEndTag() throws JspException {
        try {
            // If we didn't expose a Reader earlier...
            if (varReader == null) {
                // ... store it in 'var', if available ...
                if (var != null) {
                    pageContext.setAttribute(var, acquireString(), scope);
                }
                // ... or simply output it, if we have nowhere to expose it
                else {
                    pageContext.getOut().print(acquireString());
                }
            }
            return EVAL_PAGE;
        } catch (IOException ex) {
            throw new JspTagException(ex.toString(), ex);
        }
    }
261174
@Override
    public Object visitFunctionCall(ExcellentParser.FunctionCallContext ctx) {
        String funcName = ctx.fnname().getText();
        List<Object> parameters;
        if (ctx.parameters() != null) {
            parameters = (List<Object>) visit(ctx.parameters());
        } else {
            parameters = Collections.emptyList();
        }
        return m_functions.invokeFunction(m_evalContext, funcName, parameters);
    }
354396
private Object evalInternal(
    Selector sel,
    MatchSpaceKey bind,
    EvalCache cache,
    Object contextValue,
    boolean permissive)
    throws BadMessageFormatMatchingException
  {
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass, "evalInternal", new Object[] { sel, bind, cache, contextValue, new Boolean(permissive) });
    
    Object theReturn = null;
    // If sel is a literal, its value is simply the literal's value
    if (sel instanceof Literal)
    {
      if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
        tc.debug(cclass, "Selector is a literal");         
      theReturn = ((Literal) sel).getValue();
      if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
        tc.exit(cclass, "evalInternal", theReturn);  
      return theReturn;
    }

    // If sel is an Identifier, we let the MatchSpaceKey evaluate it.  The MatchSpaceKey is
    // given explicit type information unless the evaluation mode is permissive, in which
    // case the value is retrieved regardless and the permissive casts are applied.

    if (sel instanceof Identifier)
    {
      if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
        tc.debug(cclass, "Selector is an Identifier");        
      Identifier id = (Identifier) sel;
      if (permissive && id.getType() != Selector.UNKNOWN)
      {
        // Result may require permissive mode casts.  First, get the value, whatever it
        // is.
        boolean returnList = true;
        if(id.getType() == Selector.BOOLEAN)
          returnList = false;
        Object idVal = 
          bind.getIdentifierValue(id,
                                  true,
                                  contextValue, 
                                  returnList); // true means return a nodelist
        if (idVal == null)
        {
          if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(cclass, "evalInternal", null);            
          return null;
        }
        // Perform permissive casts
        switch (id.getType())
        {
          case Selector.NUMERIC :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is numeric");               
            if (idVal instanceof Number) // was NumericValue
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              if(idVal instanceof ArrayList)
              {
                theReturn = castToNumberList((ArrayList)idVal);
              }
              else
                theReturn = castToNumber(idVal);
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);
              return theReturn;
            }
          case Selector.STRING :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is string");              
            if (idVal instanceof String)
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              if(idVal instanceof ArrayList)
              {
                theReturn = castToStringList((ArrayList)idVal);
              }
              else
                theReturn = idVal.toString();
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);
              return theReturn;
            }            
          case Selector.BOOLEAN :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is boolean");              
            if (idVal instanceof Boolean) // was BooleanValue
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", idVal);                
              return idVal;
            }
            else
            {
              theReturn = castToBoolean(idVal);
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", theReturn);            
              return theReturn;              
            }
          default :
            if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
              tc.debug(cclass, "Selector type is default");              
            // Normally, permissive mode evaluation would not apply to TOPIC and OBJECT
            // Identifiers.  But, in any case, there are no valid casts to those types.
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null;
        }
      }
      else
      {
        // not permissive, or the type is UNKNOWN so no permissive mode casts apply
        boolean returnList = true;
        if(id.getType() == Selector.BOOLEAN)
          returnList = false;
        theReturn = 
          bind.getIdentifierValue(id,
                                  false,
                                  contextValue, 
                                  returnList); // true means return a nodelist
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;
      }
    }

    // Otherwise, it's an Operator
    Operator op = (Operator) sel;
    if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
      tc.debug(cclass, "Selector is an operator");  
    // Evaluate the operands to obtain the values needed to evaluate the operator
    Object val0 = eval(op.getOperands()[0], bind, cache, contextValue, permissive); // was false
    Object val1 =
      (op.getOperands().length == 1)
        ? null
        : eval(op.getOperands()[1], bind, cache, contextValue, permissive); // was false

    // Evaluate according to the operator
    switch (op.getOp())
    {
      case Selector.NOT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NOT");         
        if (val0 instanceof Boolean) 
        {
          theReturn = not((Boolean) val0);
          if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
            tc.exit(cclass, "evalInternal", theReturn);         
          return theReturn;          
        }
        else
          if (permissive && val0 != null)
          {
            theReturn = not(castToBoolean(val0));
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", theReturn);         
            return theReturn;            
          }
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null; 
          }
      case Selector.NEG :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NEG");         
        if (!(val0 instanceof Number)) // was NumericValue
          if (permissive && val0 != null)
          {
            val0 = castToNumber(val0);
            if (val0 == null)
            {
              if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
                tc.exit(cclass, "evalInternal", null);               
              return null;
            }
          }
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);             
            return null;
          }
        // val0 is now definitely a Number
        return neg((Number)val0);
      case Selector.ISNULL :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type ISNULL");
        theReturn = Boolean.valueOf(val0 == null);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;         
      case Selector.LIKE :
      case Selector.TOPIC_LIKE:
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LIKE");        
        if (!(val0 instanceof String))
          if (permissive && val0 != null)
            val0 = val0.toString();
          else
          {
            if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
              tc.exit(cclass, "evalInternal", null);              
            return null;
          }
        // val0 is a String
        theReturn = Boolean.valueOf(((LikeOperatorImpl) op)
            .getInternalPattern().match((String) val0));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);           
        return theReturn;
      case Selector.NE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is NE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else
          theReturn = not(compare(val0, val1, false, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);           
        return theReturn;        
      case Selector.EQ :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is EQ");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else        
          theReturn = compare(val0, val1, false, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;
      case Selector.GT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is GT");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else              
          theReturn = compare(val1, val0, true, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;        
      case Selector.LT :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LT");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, true);
        else              
          theReturn = compare(val0, val1, true, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;         
      case Selector.GE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is GE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else              
          theReturn = not(compare(val0, val1, true, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;          
      case Selector.LE :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is LE");          
        if(val0 instanceof ArrayList)
          theReturn = compareList((ArrayList)val0, val1, false, permissive, false);
        else              
          theReturn = not(compare(val1, val0, true, permissive));
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn); 
        return theReturn;          
      case Selector.PLUS :
      case Selector.MINUS :
      case Selector.TIMES :
      case Selector.DIV :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is ARITHMETIC");          
        theReturn = promoteAndEvaluate(op.getOp(), val0, val1, permissive);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;
      case Selector.AND :
      case Selector.OR :
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is ANDOR");          
        if (!(val0 instanceof Boolean)) // was BooleanValue
          if (permissive && val0 != null)
            val0 = castToBoolean(val0);
        if (!(val1 instanceof Boolean)) // was BooleanValue
          if (permissive && val1 != null)
            val1 = castToBoolean(val1);
        if (op.getOp() == Operator.AND)
          theReturn = and((Boolean) val0, (Boolean) val1);
        else
          theReturn = or((Boolean) val0, (Boolean) val1);
        if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
          tc.exit(cclass, "evalInternal", theReturn);         
        return theReturn;        
      default :
        // Should not occur
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Selector type is DEFAULT");          
        throw new IllegalStateException();
    }
  }
1223891
function runInPage(code,callback,errorCallback){
  errorCallback = errorCallback || function(err){ alert(errorMessage+err); };
  chrome.devtools.inspectedWindow["eval"](
    code,
    function(result, isException) {
     if (isException)
       errorCallback(isException);
     else{
       callback(result);
     }
  });
}
267746
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        url = (String) ExpressionUtil.evalNotNull(
                "redirect", "url", url_, String.class, this, pageContext);
        context = (String) ExpressionUtil.evalNotNull(
                "redirect", "context", context_, String.class, this, pageContext);
    }
274809
public Object eval( CallStack callstack, Interpreter interpreter )
        throws EvalError
    {
        throw new InterpreterError(
            "Unimplemented or inappropriate for " + getClass().getName() );
    }
406354
def _evaluation_context(self, escape, safe_wrapper):
        """"""
        self._escape = escape
        self._safe_wrapper = safe_wrapper

        try:
            yield
        finally:
            self._escape = None
            self._safe_wrapper = None
1175104
public Object eval(String source, int lineNo, int columnNo, Object script) throws BSFException {
        try {
            Class scriptClass = evalScripts.get(script);
            if (scriptClass == null) {
                scriptClass = loader.parseClass(script.toString(), source);
                evalScripts.put(script, scriptClass);
            } else {
                LOG.fine("eval() - Using cached script...");
            }
            //can't cache the script because the context may be different.
            //but don't bother loading parsing the class again
            Script s = InvokerHelper.createScript(scriptClass, context);
            return s.run();
        } catch (Exception e) {
            throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "exception from Groovy: " + e, e);
        }
    }
367576
public static void main(String[] args)
    {
        Context cx = Context.enter();
        try {
            // Set version to JavaScript1.2 so that we get object-literal style
            // printing instead of "[object Object]"
            cx.setLanguageVersion(Context.VERSION_1_2);

            // Initialize the standard objects (Object, Function, etc.)
            // This must be done before scripts can be executed.
            Scriptable scope = cx.initStandardObjects();

            // Now we can evaluate a script. Let's create a new object
            // using the object literal notation.
            Object result = cx.evaluateString(scope, "obj = {a:1, b:['x','y']}",
                                              "MySource", 1, null);

            Scriptable obj = (Scriptable) scope.get("obj", scope);

            // Should print "obj == result" (Since the result of an assignment
            // expression is the value that was assigned)
            System.out.println("obj " + (obj == result ? "==" : "!=") +
                               " result");

            // Should print "obj.a == 1"
            System.out.println("obj.a == " + obj.get("a", obj));

            Scriptable b = (Scriptable) obj.get("b", obj);

            // Should print "obj.b[0] == x"
            System.out.println("obj.b[0] == " + b.get(0, b));

            // Should print "obj.b[1] == y"
            System.out.println("obj.b[1] == " + b.get(1, b));

            // Should print {a:1, b:["x", "y"]}
            Function fn = (Function) ScriptableObject.getProperty(obj, "toString");
            System.out.println(fn.call(cx, scope, obj, new Object[0]));
        } finally {
            Context.exit();
        }
    }
1115620
function (cmd,context,silent)
		{
			var ctx = (context!=undefined?context:this);
			try
			{
				return (function () {
					var result = eval(cmd);
					if (!silent)
						self.e.log&&self.e.log(util.inspect(result),'result');
					return result;
				}.bind(ctx))();
			} catch (e)
			{
				this.e.exception&&this.e.exception(e);
			}
			return;
		}