use of com.github.anba.es6draft.runtime.types.Constructor in project es6draft by anba.
the class PropertiesTest method createEmptyClass.
@Test
public void createEmptyClass() {
Constructor emptyClass = Properties.createClass(cx, "EmptyClass", EmptyClass.ConstructorProperties.class, EmptyClass.PrototypeProperties.class);
assertNotNull(emptyClass);
assertNotNull(emptyClass.getOwnProperty(cx, "prototype"));
}
use of com.github.anba.es6draft.runtime.types.Constructor in project es6draft by anba.
the class PropertiesTest method createCustomClassNoArgs.
@Test
public void createCustomClassNoArgs() {
Constructor customClass = Properties.createClass(cx, "CustomClassNoArgs", CustomClassNoArgs.ConstructorProperties.class, CustomClassNoArgs.PrototypeProperties.class);
ScriptObject object = customClass.construct(cx, customClass);
assertNotNull(object);
}
use of com.github.anba.es6draft.runtime.types.Constructor in project es6draft by anba.
the class PropertiesTest method createCustomClassWithSubclass.
@Test
public void createCustomClassWithSubclass() {
Constructor customClass = Properties.createClass(cx, "CustomClassWithSubclass", CustomClassWithSubclass.ConstructorProperties.class, CustomClassWithSubclass.PrototypeProperties.class);
ScriptObject object = customClass.construct(cx, customClass);
assertNotNull(object);
}
use of com.github.anba.es6draft.runtime.types.Constructor in project es6draft by anba.
the class Bootstrap method superSetup.
@SuppressWarnings("unused")
private static MethodHandle superSetup(MutableCallSite callsite, Constructor constructor, ExecutionContext cx, Constructor newTarget, Object[] arguments) {
MethodHandle target, test;
if (constructor instanceof FunctionObject && constructor instanceof Constructor) {
FunctionObject fn = (FunctionObject) constructor;
test = MethodHandles.insertArguments(testFunctionObjectMH, 1, fn.getMethodInfo());
target = fn.getConstructMethod();
} else if (constructor instanceof BuiltinConstructor) {
BuiltinConstructor fn = (BuiltinConstructor) constructor;
test = MethodHandles.insertArguments(testBuiltinFunctionMH, 1, fn.getMethodInfo());
target = fn.getConstructMethod();
} else {
target = test = null;
}
if (test != null) {
test = test.asType(test.type().changeParameterType(0, Constructor.class));
}
return setCallSiteTarget(callsite, target, test, superGenericMH);
}
use of com.github.anba.es6draft.runtime.types.Constructor in project es6draft by anba.
the class Bootstrap method constructSetup.
@SuppressWarnings("unused")
private static MethodHandle constructSetup(MutableCallSite callsite, Object constructor, ExecutionContext cx, Object[] arguments) {
MethodHandle target, test;
if (constructor instanceof FunctionObject && constructor instanceof Constructor) {
FunctionObject fn = (FunctionObject) constructor;
test = MethodHandles.insertArguments(testFunctionObjectMH, 1, fn.getMethodInfo());
target = fn.getConstructMethod();
} else if (constructor instanceof BuiltinConstructor) {
BuiltinConstructor fn = (BuiltinConstructor) constructor;
test = MethodHandles.insertArguments(testBuiltinFunctionMH, 1, fn.getMethodInfo());
target = fn.getConstructMethod();
} else {
target = test = null;
}
if (target != null) {
// Insert constructor as newTarget argument.
target = target.asType(target.type().changeParameterType(2, constructor.getClass()));
target = MethodHandles.permuteArguments(target, target.type().dropParameterTypes(2, 3), 0, 1, 0, 2);
}
return setCallSiteTarget(callsite, target, test, constructGenericMH);
}
Aggregations