Executes the given script with the element's object ID, but does not parse the response.

@param script the script to execute
340422
private void executeMethod(String script) {
    parent.assertConnected();
    debugger.callFunctionOnObject(script, objectId, false);
  }
455944
public static String executeGroovy(String script, @Nonnull VirtualChannel channel) throws IOException, InterruptedException {
        return channel.call(new Script(script));
    }
1056580
public Object eval(String script) {
//        // use Java's ScriptEngine at the moment
//        ScriptEngineManager manager = new ScriptEngineManager();
//        ScriptEngine jsEngine = manager.getEngineByName("JavaScript");
//        try {
//            return jsEngine.eval(script);
//        } catch (ScriptException e) {
//            throw new RuntimeException(e);
//        }
        return eval(script, Collections.<String, Object>emptyMap());
    }
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());
		}

	}
890050
public <T> T eval(String name, final String script, Map<String,Object> data) throws ScriptException,ScriptLimitException,SyntaxException {
        long t = System.currentTimeMillis();
        if(data==null)
            data = Objects.newHashMap();
        if(script.length()>sizeLimit)
            throw new ScriptLimitException(ScriptLimitException.Limits.SIZE,getSizeLimit());
        if(LOG.isDebugEnabled()){
            LOG.debug("Evaluating S1 script:\n"+script+"\nWith data:"+data);
        }

        AstRoot _root = null;
        if(Objects.isNullOrEmpty(name)){
            _root = parseScript(script);
        }else{
            _root = astCache.get(name,new Closure<String, AstRoot>() {
                @Override
                public AstRoot call(String input) {
                    return parseScript(script);
                }
            });
        }
        final AstRoot root = _root;

        final Context ctx=new Context(getMemoryLimit());
        ctx.getVariables().putAll(data);

        //functions from options
        for(final Map<String,Object> f:functions){
            String clName = Objects.get(f,"class");
            String ns = Objects.get(f,"namespace","");
            Map<String,Object> set_cfg = Objects.get(f,"config",Objects.newSOHashMap());
            Class<? extends ScriptFunctionSet> cls = null;
            try {
                cls = (Class<? extends ScriptFunctionSet>)Class.forName(clName);
                ScriptFunctionSet set = cls.newInstance();
                set.setConfig(set_cfg);
                set.setContext(new Context(getMemoryLimit()));
                Objects.set(ctx.getVariables(),ns,set);
            } catch (Throwable e) {
                LOG.warn("Class "+cls+" cannot be initialized as ScriptFunctions: "+e.getMessage(),e);
            }
        }

        //system functions
        ScriptFunctionSet set = new SystemFunctionSet();
        //set.setConfig(set_cfg);
        set.setContext(new Context(getMemoryLimit()));
        Objects.set(ctx.getVariables(),SYSTEM_FUNCTION_NS,set);

        final Session.SessionBean sb = Session.getSessionBean();

        Future<Object> f = null;
        if(isInside.get() == null || !isInside.get()) {
            if (sb != null) {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        String id = null;
                        try {
                            isInside.set(true);
                            id = Session.start(sb.getId());
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        } finally {
                            Session.end(id);
                            isInside.set(false);
                        }
                    }
                });
            } else {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        try {
                            isInside.set(true);
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        }finally {
                            isInside.set(false);
                        }
                    }
                });
            }
        }

        try {
            long l = System.currentTimeMillis();
            T result = null;
            /*try {
                // Try to get answer in short timeout, should be available
                result = (T)f.get(getTimeLimit(), TimeUnit.MILLISECONDS);
            } catch (TimeoutException te) {
                f.cancel(true);
                throw new ScriptLimitException(ScriptLimitException.Limits.TIME,getTimeLimit());
            }*/
            if(f==null || getTimeLimit()<=0){
                ASTEvaluator ast = new ASTEvaluator();
                result = (T)ast.eval(root, ctx);
            }else {
                while (true) {
                    if (System.currentTimeMillis() - l > getTimeLimit()) {
                        f.cancel(true);
                        throw new ScriptLimitException(ScriptLimitException.Limits.TIME, getTimeLimit());
                    }

                    if (f.isDone()) {
                        break;
                    }
                    Thread.sleep(1);
                }
                result = (T) f.get();
            }
            if(LOG.isDebugEnabled()){
                LOG.debug("Script result ("+(System.currentTimeMillis()-t)+"ms.): "+result);
            }
            return result;
        } catch (InterruptedException e){
            throw S1SystemError.wrap(e);
        } catch (ExecutionException e){
            if(e.getCause()!=null){
                if(e.getCause() instanceof ScriptLimitException)
                    throw (ScriptLimitException)e.getCause();
                if(e.getCause() instanceof ScriptException) {
                    ScriptException se = (ScriptException) e.getCause();
                    int line = se.getLine();
                    if(line>=0){
                        String arr [] = script.split("\n",-1);
                        String m = (arr.length>line?(arr[line]):"");
                        se.setCode(m);
                        throw se;
                    }
                    throw se;
                }
            }
            throw S1SystemError.wrap(e);
        } catch (ScriptException se){
            int line = se.getLine();
            if(line>=0){
                String arr [] = script.split("\n",-1);
                String m = (arr.length>line?(arr[line]):"");
                se.setCode(m);
                throw se;
            }
            throw se;
        }
    }
1057054
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlEnumeration == null) {
			this.container = script;
			this.sarlEnumeration = SarlFactory.eINSTANCE.createSarlEnumeration();
			script.getXtendTypes().add(this.sarlEnumeration);
			this.sarlEnumeration.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlEnumeration.setName(name);
			}
		}
	}
1154673
private String executeScriptExecuteRequest(String rScript) throws IOException {
    URI uri = getScriptExecutionUri();
    HttpPost httpPost = new HttpPost(uri);
    NameValuePair nameValuePair = new BasicNameValuePair("x", rScript);
    httpPost.setEntity(new UrlEncodedFormEntity(singletonList(nameValuePair)));

    String openCpuSessionKey;
    try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode >= 200 && statusCode < 300) {
        Header openCpuSessionKeyHeader = response.getFirstHeader("X-ocpu-session");
        if (openCpuSessionKeyHeader == null) {
          throw new IOException("Missing 'X-ocpu-session' header");
        }
        openCpuSessionKey = openCpuSessionKeyHeader.getValue();
        EntityUtils.consume(response.getEntity());
      } else if (statusCode == 400) {
        HttpEntity entity = response.getEntity();
        String rErrorMessage = EntityUtils.toString(entity);
        EntityUtils.consume(entity);
        throw new ScriptException(rErrorMessage);
      } else {
        throw new ClientProtocolException(format(FORMAT_UNEXPECTED_RESPONSE_STATUS, statusCode));
      }
    }
    return openCpuSessionKey;
  }
718923
@RequestMapping(value = "/api/scripts", method = RequestMethod.POST)
    public
    @ResponseBody
    Script addScript(Model model,
                     @RequestParam(required = true) String name,
                     @RequestParam(required = true) String script) throws Exception {

        return ScriptService.getInstance().addScript(name, script);
    }
89661
@Override
	public CompiledScript compile(String script) throws ScriptException {
		return ((Compilable) engine).compile(script);
	}
1011820
protected void writeFrameworkScript(AbstractRenderAppender sb)
    {
        boolean script = false;
        ScriptRequestState jsu = ScriptRequestState.getScriptRequestState((HttpServletRequest) pageContext.getRequest());

        boolean writeLegacy = false;
        boolean writeName = false;
        String val;

        // if we are writing out legacy JavaScript support output the idMap
        if (TagConfig.isLegacyJavaScript()) {
            val = processIdMap(_idMap, "idMappingEntry", _idScope);
            if (val != null) {
                writeIdMap(this, "idMappingTable", val);
                writeLegacy = true;
            }
        }

        // if we are writing out default JavaScript support we create the name map
        if (TagConfig.isDefaultJavaScript()) {
            String idScope = getJavaScriptId();
            if (idScope.equals(""))
                idScope = null;
            val = processIdMap(_idToNameMap, "tagIdNameMappingEntry", idScope);
            if (val != null) {
                writeIdMap(this, "tagIdNameMappingTable", val);
                writeName = true;
            }
        }

        if (writeLegacy || _writeId || writeName)
            jsu.writeNetuiNameFunctions(this, writeLegacy, _writeId, writeName);

        ScriptTag.State state = null;
        ScriptTag br = null;
        if (_funcBlocks != null && _funcBlocks.size() > 0) {
            if (!script) {
                state = new ScriptTag.State();
                state.suppressComments = false;
                br = (ScriptTag) TagRenderingBase.Factory.getRendering(TagRenderingBase.SCRIPT_TAG, pageContext.getRequest());
                br.doStartTag(sb, state);
                script = true;
            }
            String s = ScriptRequestState.getString("functionComment", null);
            sb.append(s);
            int cnt = _funcBlocks.size();
            for (int i = 0; i < cnt; i++) {
                sb.append((String)_funcBlocks.get(i));
                if (i != cnt - 1) {
                    sb.append("\n");
                }
            }
        }

        if (script) {
            assert(br != null);
            br.doEndTag(sb, false);
        }
    }
8978
def evaluate(self, script):
        
        if WEBENGINE:
            return self.dom.runJavaScript("{}".format(script))
        else:
            return self.dom.evaluateJavaScript("{}".format(script))
644493
protected Object evaluate(String script, String scriptName) {
        try {
            Context curCtx = Context.getCurrentContext();
            curCtx.setLanguageVersion(Context.VERSION_1_8);
            return curCtx.evaluateString(programScope, script, scriptName, 1, null);
        } catch (EcmaError rerr) {
            throw new BPjsCodeEvaluationException(rerr);

        } catch (WrappedException wrapped) {
            try {
                throw wrapped.getCause();
            } catch (BPjsException be ) {
                throw be;
            } catch ( IllegalStateException ise ) {
                String msg = ise.getMessage();
                if ( msg.contains("Cannot capture continuation") && msg.contains("executeScriptWithContinuations or callFunctionWithContinuations") ){
                    throw new BPjsCodeEvaluationException("bp.sync called outside of a b-thread");
                } else {
                    throw ise;
                }
            } catch ( Throwable generalException ) {
                throw new BPjsRuntimeException("(Wrapped) Exception evaluating BProgram code: " + generalException.getMessage(), generalException);
            }

        } catch (EvaluatorException evalExp) {
            throw new BPjsCodeEvaluationException(evalExp);
            
        } catch ( Exception exp ) {
            throw new BPjsRuntimeException("Error evaluating BProgram code: " + exp.getMessage(), exp);
        }
    }
1260483
function injectScriptTag(script) {
  // Get some kind of target to put the script in.
  // Only valid documents get body/head, so this is a nice way to ignore bad
  // ones. Try to insert as early as possible.
  var targetElement =
      document.documentElement || document.head || document.body;
  if (targetElement) {
    if (targetElement.firstElementChild) {
      targetElement.insertBefore(script, targetElement.firstElementChild);
    } else {
      targetElement.appendChild(script);
    }
    script.parentNode.removeChild(script);
  }
}
1259553
Object executeScript(String jsScript, Map<String, Object> parameters) {
    EntityType entityType = entityTypeFactory.create("entity");
    Set<String> attributeNames = parameters.keySet();
    attributeNames.forEach(key -> entityType.addAttribute(attributeFactory.create().setName(key)));
    if (attributeNames.iterator().hasNext()) {
      entityType.getAttribute(attributeNames.iterator().next()).setIdAttribute(true);
    }
    Entity entity = new DynamicEntity(entityType);
    parameters.forEach(entity::set);
    return jsMagmaScriptEvaluator.eval(jsScript, entity);
  }
1341280
public void setPreUninstallScript( final String script) {
        setPreUninstallProgram(readProgram(script));
        if ( script != null) format.getHeader().createEntry( PREUNSCRIPT, script);
	}
1358945
protected void executeScript(final String filename, final Statement statement) throws SQLException {
        LOG.info("Executing sql script: " + filename);

        InputStream fileInputStream;
        try {
            fileInputStream = ConfigurationLoader.loadResource(filename);
        } catch (FileNotFoundException e) {
            LOG.error("could not execute script", e);
            return;
        }

        final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
        executeScript(reader, statement);
    }
492767
public function customScript($script, $uniquenessID = null)
    {
        if ($uniquenessID) {
            $this->customScript[$uniquenessID] = $script;
        } else {
            $this->customScript[] = $script;
        }
    }