org.mozilla.javascript.Script.exec()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 JavaScript  
字(4.4k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中org.mozilla.javascript.Script.exec()方法的一些代码示例,展示了Script.exec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Script.exec()方法的具体详情如下:
包路径:org.mozilla.javascript.Script
类名称:Script
方法名:exec

Script.exec介绍

[英]Execute the script.

The script is executed in a particular runtime Context, which must be associated with the current thread. The script is executed relative to a scope--definitions and uses of global top-level variables and functions will access properties of the scope object. For compliant ECMA programs, the scope must be an object that has been initialized as a global object using Context.initStandardObjects.
[中]执行脚本。
脚本在特定的运行时上下文中执行,该上下文必须与当前线程相关联。脚本是相对于作用域执行的——全局顶级变量和函数的定义和使用将访问作用域对象的属性。对于兼容的ECMA程序,作用域必须是已使用Context.initStandardObjects初始化为全局对象的对象。

代码示例

代码示例来源:origin: stackoverflow.com

Script script = cx.compileString(scriptText, "<command>", 1, null);
if (script != null) {
  script.exec(cx, getShellScope()); // <- just an eval
}

代码示例来源:origin: pentaho/pentaho-kettle

jsscript.exec( jscx, jsscope );

代码示例来源:origin: pentaho/pentaho-kettle

evalScript.exec( jscx, jsscope );

代码示例来源:origin: pentaho/pentaho-kettle

evalScript.exec( jscx, jsscope );

代码示例来源:origin: pentaho/pentaho-kettle

endScript.exec( data.cx, data.scope );
if ( log.isDetailed() ) {
 logDetailed( ( "End Script found!" ) );

代码示例来源:origin: pentaho/pentaho-kettle

startScript.exec( data.cx, data.scope );
   if ( log.isDetailed() ) {
    logDetailed( ( "Start Script found!" ) );
data.script.exec( data.cx, data.scope );

代码示例来源:origin: rhino/js

@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
          Object[] args)
{
  if (script != null) {
    return script.exec(cx, scope);
  }
  return Undefined.instance;
}

代码示例来源:origin: geogebra/geogebra

private static void executeOptionalScript(Script script, Context cx,
    Scriptable executionScope)
{
  if(script != null) {
    script.exec(cx, executionScope);
  }
}

代码示例来源:origin: com.github.tntim96/rhino

@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
          Object[] args)
{
  if (script != null) {
    return script.exec(cx, scope);
  }
  return Undefined.instance;
}

代码示例来源:origin: com.github.tntim96/rhino

private static void executeOptionalScript(Script script, Context cx,
    Scriptable executionScope)
{
  if(script != null) {
    script.exec(cx, executionScope);
  }
}

代码示例来源:origin: geogebra/geogebra

@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
          Object[] args)
{
  if (script != null) {
    return script.exec(cx, scope);
  }
  return Undefined.instance;
}

代码示例来源:origin: io.apigee/rhino

@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
          Object[] args)
{
  if (script != null) {
    return script.exec(cx, scope);
  }
  return Undefined.instance;
}

代码示例来源:origin: rhino/js

public Object run(Context cx)
  {
    ScriptableObject global = ScriptRuntime.getGlobal(cx);
    script.exec(cx, global);
    return global;
  }
});

代码示例来源:origin: geogebra/geogebra

public Object run(Context cx)
  {
    ScriptableObject global = ScriptRuntime.getGlobal(cx);
    script.exec(cx, global);
    return global;
  }
});

代码示例来源:origin: com.github.tntim96/rhino

public Object run(Context cx)
  {
    ScriptableObject global = ScriptRuntime.getGlobal(cx);
    script.exec(cx, global);
    return global;
  }
});

代码示例来源:origin: io.apigee/rhino

public Object run(Context cx)
  {
    ScriptableObject global = ScriptRuntime.getGlobal(cx);
    script.exec(cx, global);
    return global;
  }
});

代码示例来源:origin: ro.isdc.wro4j/rhino

public Object run(Context cx)
  {
    ScriptableObject global = ScriptRuntime.getGlobal(cx);
    script.exec(cx, global);
    return global;
  }
});

代码示例来源:origin: io.apigee.trireme/trireme-util

@JSFunction
  @SuppressWarnings("unused")
  public static Object runInContext(Context cx, Scriptable thisObj, Object[] args, Function funObj)
  {
    ContextImpl ctx = objArg(args, 0, ContextImpl.class, true);
    ScriptImpl self = (ScriptImpl)thisObj;
    return self.script.exec(cx, ctx.globalProxy);
  }
}

代码示例来源:origin: apache/cxf

private Object[] compileScript(Context cx, String scriptStr, Scriptable scriptScope, File f) {
  int opt = cx.getOptimizationLevel();
  cx.setOptimizationLevel(-1);
  Script script = cx.compileString(scriptStr, f.getName(), 1, null);
  script.exec(cx, scriptScope);
  Object[] ids = scriptScope.getIds();
  cx.setOptimizationLevel(opt);
  script = cx.compileString(scriptStr, f.getName(), 1, null);
  script.exec(cx, scriptScope);
  return ids;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-js

private Object[] compileScript(Context cx, String scriptStr, Scriptable scriptScope, File f) {
  int opt = cx.getOptimizationLevel();
  cx.setOptimizationLevel(-1);
  Script script = cx.compileString(scriptStr, f.getName(), 1, null);
  script.exec(cx, scriptScope);
  Object[] ids = scriptScope.getIds();
  cx.setOptimizationLevel(opt);
  script = cx.compileString(scriptStr, f.getName(), 1, null);
  script.exec(cx, scriptScope);
  return ids;
}

相关文章