use of com.github.anba.es6draft.runtime.types.builtins.BuiltinConstructor in project es6draft by anba.
the class Bootstrap method constructSetup.
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);
}
use of com.github.anba.es6draft.runtime.types.builtins.BuiltinConstructor in project es6draft by anba.
the class Bootstrap method superSetup.
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);
}
Aggregations