本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptObject.setInitialProto方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptObject.setInitialProto方法的具体用法?Java ScriptObject.setInitialProto怎么用?Java ScriptObject.setInitialProto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ScriptObject
的用法示例。
在下文中一共展示了ScriptObject.setInitialProto方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createObject
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private Object createObject(final PropertyMap propertyMap, final List<Object> values, final ArrayData arrayData) {
final long[] primitiveSpill = dualFields ? new long[values.size()] : null;
final Object[] objectSpill = new Object[values.size()];
for (final Property property : propertyMap.getProperties()) {
if (!dualFields || property.getType() == Object.class) {
objectSpill[property.getSlot()] = values.get(property.getSlot());
} else {
primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
}
}
final ScriptObject object = dualFields ?
new JD(propertyMap, primitiveSpill, objectSpill) : new JO(propertyMap, null, objectSpill);
object.setInitialProto(global.getObjectPrototype());
object.setArray(arrayData);
return object;
}
示例2: initPrototype
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private ScriptObject initPrototype(final String name, final ScriptObject prototype) {
try {
// Assuming class name pattern for JS prototypes
final String className = PACKAGE_PREFIX + name + "$Prototype";
final Class<?> funcClass = Class.forName(className);
final ScriptObject res = (ScriptObject) funcClass.getDeclaredConstructor().newInstance();
res.setIsBuiltin();
res.setInitialProto(prototype);
return res;
} catch (final Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new RuntimeException(e);
}
}
}
示例3: initErrorSubtype
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) {
final ScriptFunction cons = initConstructor(name, ScriptFunction.class);
final ScriptObject prototype = ScriptFunction.getPrototype(cons);
prototype.set(NativeError.NAME, name, 0);
prototype.set(NativeError.MESSAGE, "", 0);
prototype.setInitialProto(errorProto);
tagBuiltinProperties(name, cons);
return cons;
}