Evaluate a script.
772084
function eval(req, res, source, args) {
  this.spawn();
  this.reply(req, res, this._limit);
  // need to coerce buffers for the moment
  args = args.map(function(a) {
    if(a instanceof Buffer) return a.toString();
    return a;
  })
  this.ps.send({event: 'eval', source: source, args: args});
}
1206701
public function evalEx($script, $args = null, $num_keys = null)
    {
        $sha1 = sha1($script);
        $this->clearLastError();
        $result = $this->evalSha($sha1, $args, $num_keys);
        if('NOSCRIPT No matching script. Please use EVAL.' === $this->getLastError())
        {
            $result = $this->eval($script, $args, $num_keys);
        }
        return $result;
    }
308325
def evaluate(self, data):
        """"""
        try:
            inputs = copy.deepcopy(data.input)
            hydrate_input_references(inputs, data.process.input_schema)
            hydrate_input_uploads(inputs, data.process.input_schema)

            # Include special 'proc' variable in the context.
            inputs['proc'] = {
                'data_id': data.id,
                'data_dir': self.manager.get_executor().resolve_data_path(),
            }

            # Include special 'requirements' variable in the context.
            inputs['requirements'] = data.process.requirements
            # Inject default values and change resources according to
            # the current Django configuration.
            inputs['requirements']['resources'] = data.process.get_resource_limits()

            script_template = data.process.run.get('program', '')

            # Get the appropriate expression engine. If none is defined, do not evaluate
            # any expressions.
            expression_engine = data.process.requirements.get('expression-engine', None)
            if not expression_engine:
                return script_template

            return self.get_expression_engine(expression_engine).evaluate_block(
                script_template, inputs,
                escape=self._escape,
                safe_wrapper=SafeString,
            )
        except EvaluationError as error:
            raise ExecutionError('{}'.format(error))
921917
def evaluate(str, file = '<in QML::Engine#evaluate>', lineno = 1)
      evaluate_impl(str, file, lineno).tap do |result|
        raise result.to_error if result.is_a?(JSObject) && result.error?
      end
    end
908119
private static Object evaluateScript(final ActionContext actionContext, final GraphObject entity, final String engineName, final String script) throws FrameworkException {

		final ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine engine = manager.getEngineByName(engineName);

		if (engine == null) {
			List<ScriptEngineFactory> factories = manager.getEngineFactories();

			for (ScriptEngineFactory factory : factories) {

				if (factory.getNames().contains(engineName)) {

					engine = factory.getScriptEngine();
					break;

				}

			}

		}


		if (engine == null) {
			throw new RuntimeException(engineName + " script engine could not be initialized. Check class path.");
		}

		final ScriptContext scriptContext = engine.getContext();
		final Bindings bindings           = new StructrScriptBindings(actionContext, entity);

		if (!(engine instanceof RenjinScriptEngine)) {
			scriptContext.setBindings(bindings, ScriptContext.GLOBAL_SCOPE);
		} else if (engine instanceof  RenjinScriptEngine) {

			engine.put("Structr", new StructrScriptObject(actionContext, entity));

		}

		StringWriter output = new StringWriter();
		scriptContext.setWriter(output);

		try {

			Object extractedValue = engine.eval(script);

			if (output != null && output.toString() != null && output.toString().length() > 0) {
				extractedValue = output.toString();
			}

			return extractedValue;

		} catch (final Throwable e) {

			if (!actionContext.getDisableVerboseExceptionLogging()) {
				logger.error("Error while processing {} script: {}", engineName, script, e);
			}

			throw new FrameworkException(422, e.getMessage());
		}

	}
1093214
public Object evaluateString(String scriptName, String source, Bindings bindings) {
		try {
			scriptEngine.put(ScriptEngine.FILENAME, scriptName);
			return scriptEngine.eval(source, bindings);
		} catch (ScriptException e) {
			throw new BundlingProcessException("Error while evaluating script : " + scriptName, e);
		}
	}
1198497
def evaluate(self, s, value, insert=None):
        
        assert not isinstance(value, kurt.Script)

        if insert and insert.unevaluated:
            return value

        if isinstance(value, kurt.Block):
            if value.type.shape == "hat":
                return []

            if value.type not in self.COMMANDS:
                if getattr(value.type, '_workaround', None):
                    value = value.type._workaround(value)
                    if not value:
                        raise kurt.BlockNotSupported(value.type)
                else:
                    raise kurt.BlockNotSupported(value.type)

            f = self.COMMANDS[value.type]

            args = [self.evaluate(s, arg, arg_insert)
                    for (arg, arg_insert)
                    in zip(list(value.args), value.type.inserts)]
            value = f(s, *args)

            def flatten_generators(gen):
                for item in gen:
                    if inspect.isgenerator(item):
                        for x in flatten_generators(item):
                            yield x
                    else:
                        yield item
            if inspect.isgenerator(value):
                value = flatten_generators(value)

            if value is None:
                value = []

        if insert:
            if isinstance(value, basestring):
                value = unicode(value)

                if insert.shape in ("number", "number-menu", "string"):
                    try:
                        value = float(value)
                    except (TypeError, ValueError):
                        if insert.shape == "number":
                            value = 0

            if isinstance(value, float) and value == int(value):
                value = int(value)

            if insert.kind in ("spriteOrStage", "spriteOrMouse", "stageOrThis",
                               "spriteOnly", "touching"):
                if value not in ("mouse-pointer", "edge"):
                    value = (self.project.stage if value == "Stage"
                             else self.project.get_sprite(value))
            elif insert.kind == "var":
                if value in s.variables:
                    value = s.variables[value]
                else:
                    value = s.project.variables[value]
            elif insert.kind == "list":
                if value in s.lists:
                    value = s.lists[value]
                else:
                    value = s.project.lists[value]
            elif insert.kind == "sound":
                for sound in s.sounds:
                    if sound.name == value:
                        value = sound
                        break

        return value
324218
function validateScript(script) {
  var valid = this._validate(script);
  validateScript.errors = this._validate.errors;
  return valid;
}
186080
def result(self):
        """"""
        # Module(body=[Expr(value=...)])
        return self.eval_(ast.parse(self.expr).body[0].value)
690314
def evaluate(self, m):
        """"""

        g = m.groupdict()
        if g["strings"]:
            self.line_num += g['strings'].count('\n')
        elif g["code"]:
            self.line_num += g["code"].count('\n')
        else:
            if g['block']:
                self.evaluate_block(g)
            elif self.stylesheets != CSS:
                if g['start'] is None:
                    self.evaluate_inline_tail(g)
                else:
                    self.evaluate_inline(g)
            self.line_num += g['comments'].count('\n')
1002890
def evaluate_script(self):
        

        editor = self.get_current_editor()
        if not editor:
            return False

        LOGGER.debug("> Evaluating 'Script Editor' content.")
        if self.evaluate_code(foundations.strings.to_string(editor.toPlainText().toUtf8())):
            self.ui_refresh.emit()
            return True
845346
@Override
    public Object eval(Reader reader, ScriptContext context) throws ScriptException {
	try {
	    return eval(IOUtil.toString(reader), context);
	}
	catch (IOException ioe) {
	    throw toScriptException(ioe);
	}
    }
276615
def run_script(scriptfile):
    ''''''
    try:
        f = open(scriptfile, mode='r')
    except Exception:
        return
    mpstate.console.writeln("Running script %s" % scriptfile)
    sub = mp_substitute.MAVSubstitute()
    for line in f:
        line = line.strip()
        if line == "" or line.startswith('#'):
            continue
        try:
            line = sub.substitute(line, os.environ)
        except mp_substitute.MAVSubstituteError as ex:
            print("Bad variable: %s" % str(ex))
            if mpstate.settings.script_fatal:
                sys.exit(1)
            continue
        if line.startswith('@'):
            line = line[1:]
        else:
            mpstate.console.writeln("-> %s" % line)
        process_stdin(line)
    f.close()
665181
public Object eval(ScriptContext scriptContext) throws ScriptException {
        if (this.compiledScript == null) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("No compiled script available, invoking ScriptEngine.eval(String, ScriptContext) for script:\n" + this.script);
            }

            return this.scriptEngine.eval(this.script, scriptContext);
        }

        try {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Compiled script available, invoking CompiledScript.eval(ScriptContext) for script:\n" + this.script);
            }

            return evalCompiledScriptWithContextMethod.invoke(this.compiledScript, scriptContext);
        }
        catch (Exception e) {
            if (e instanceof ScriptException) {
                throw (ScriptException)e;
            }
            
            throw new ScriptException(e);
        }
    }
1121425
private void eval( CssFormatter formatter ) {
        if( type != UNKNOWN ) {
            return;
        }
        try {
            ScriptEngineManager factory = new ScriptEngineManager( getClass().getClassLoader() );
            ScriptEngine engine = factory.getEngineByName( "JavaScript" );
            engine.setContext( new JavaScriptContext( formatter, this ) );

            String script = toString();
            script = SelectorUtils.replacePlaceHolder( formatter, script, this );
            script = script.substring( 1, script.length() - 1 );
            result = engine.eval( script );
            if( result instanceof Number ) {
                type = NUMBER;
            } else if( result instanceof Boolean ) {
                type = BOOLEAN;
            } else if( result instanceof Collection ) {
                type = LIST;
            } else if( result instanceof Map ) {
                result = ((Map)result).values();
                type = LIST;
            } else {
                type = STRING;
            }
        } catch( Exception ex ) {
            throw createException( ex );
        }
    }
1371348
protected boolean evaluateCondition( String script, Log log )
        throws EnforcerRuleException
    {
        Boolean evaluation = Boolean.FALSE;
        try
        {
            evaluation = (Boolean) bsh.eval( script );
            log.debug( "Echo evaluating : " + evaluation );
        }
        catch ( EvalError ex )
        {
            throw new EnforcerRuleException( "Couldn't evaluate condition: " + script, ex );
        }
        return evaluation.booleanValue();
    }
309891
def evalsha(self, sha, numkeys, *keys_and_args):
        """"""
        if not self.script_exists(sha)[0]:
            raise RedisError("Sha not registered")
        script_callable = Script(self, self.shas[sha], self.load_lua_dependencies)
        numkeys = max(numkeys, 0)
        keys = keys_and_args[:numkeys]
        args = keys_and_args[numkeys:]
        return script_callable(keys, args)