本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptFunction.createBuiltin方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptFunction.createBuiltin方法的具体用法?Java ScriptFunction.createBuiltin怎么用?Java ScriptFunction.createBuiltin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ScriptFunction
的用法示例。
在下文中一共展示了ScriptFunction.createBuiltin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: captureStackTrace
import jdk.nashorn.internal.runtime.ScriptFunction; //导入方法依赖的package包/类
/**
* Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
*
* @param self self reference
* @param errorObj the error object
* @return undefined
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
final ScriptObject sobj = Global.checkObject(errorObj);
initException(sobj);
sobj.delete(STACK, false);
if (! sobj.has("stack")) {
final ScriptFunction getStack = ScriptFunction.createBuiltin("getStack", GET_STACK);
final ScriptFunction setStack = ScriptFunction.createBuiltin("setStack", SET_STACK);
sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
}
return UNDEFINED;
}
示例2: addShellBuiltins
import jdk.nashorn.internal.runtime.ScriptFunction; //导入方法依赖的package包/类
/**
* Adds jjs shell interactive mode builtin functions to global scope.
*/
public void addShellBuiltins() {
Object value = ScriptFunction.createBuiltin("input", ShellFunctions.INPUT);
addOwnProperty("input", Attribute.NOT_ENUMERABLE, value);
value = ScriptFunction.createBuiltin("evalinput", ShellFunctions.EVALINPUT);
addOwnProperty("evalinput", Attribute.NOT_ENUMERABLE, value);
}
示例3: initErrorObjects
import jdk.nashorn.internal.runtime.ScriptFunction; //导入方法依赖的package包/类
private void initErrorObjects() {
// Error objects
this.builtinError = initConstructor("Error", ScriptFunction.class);
final ScriptObject errorProto = getErrorPrototype();
// Nashorn specific accessors on Error.prototype - stack, lineNumber, columnNumber and fileName
final ScriptFunction getStack = ScriptFunction.createBuiltin("getStack", NativeError.GET_STACK);
final ScriptFunction setStack = ScriptFunction.createBuiltin("setStack", NativeError.SET_STACK);
errorProto.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
final ScriptFunction getLineNumber = ScriptFunction.createBuiltin("getLineNumber", NativeError.GET_LINENUMBER);
final ScriptFunction setLineNumber = ScriptFunction.createBuiltin("setLineNumber", NativeError.SET_LINENUMBER);
errorProto.addOwnProperty("lineNumber", Attribute.NOT_ENUMERABLE, getLineNumber, setLineNumber);
final ScriptFunction getColumnNumber = ScriptFunction.createBuiltin("getColumnNumber", NativeError.GET_COLUMNNUMBER);
final ScriptFunction setColumnNumber = ScriptFunction.createBuiltin("setColumnNumber", NativeError.SET_COLUMNNUMBER);
errorProto.addOwnProperty("columnNumber", Attribute.NOT_ENUMERABLE, getColumnNumber, setColumnNumber);
final ScriptFunction getFileName = ScriptFunction.createBuiltin("getFileName", NativeError.GET_FILENAME);
final ScriptFunction setFileName = ScriptFunction.createBuiltin("setFileName", NativeError.SET_FILENAME);
errorProto.addOwnProperty("fileName", Attribute.NOT_ENUMERABLE, getFileName, setFileName);
// ECMA 15.11.4.2 Error.prototype.name
// Error.prototype.name = "Error";
errorProto.set(NativeError.NAME, "Error", 0);
// ECMA 15.11.4.3 Error.prototype.message
// Error.prototype.message = "";
errorProto.set(NativeError.MESSAGE, "", 0);
tagBuiltinProperties("Error", builtinError);
this.builtinReferenceError = initErrorSubtype("ReferenceError", errorProto);
this.builtinSyntaxError = initErrorSubtype("SyntaxError", errorProto);
this.builtinTypeError = initErrorSubtype("TypeError", errorProto);
}