src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
Print this page
@@ -28,10 +28,12 @@
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
import static jdk.nashorn.internal.runtime.linker.Lookup.MH;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
+
+import jdk.nashorn.internal.codegen.ScriptFunctionData;
import jdk.nashorn.internal.codegen.objects.FunctionObjectCreator;
import jdk.nashorn.internal.runtime.GlobalFunctions;
import jdk.nashorn.internal.runtime.Property;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction;
@@ -92,11 +94,11 @@
* @param methodHandle handle for invocation
* @param map initial property map
* @param specs specialized versions of this method, if available, null otherwise
*/
ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final PropertyMap map, final MethodHandle[] specs) {
- super(name, methodHandle, (nasgenmap$ == map) ? nasgenmap$ : map.addAll(nasgenmap$), null, null, 0, false, specs);
+ super(name, methodHandle, (nasgenmap$ == map) ? nasgenmap$ : map.addAll(nasgenmap$), null, false, specs);
this.setIsBuiltin();
init();
}
/**
@@ -122,34 +124,19 @@
* Constructor
*
* Called by (compiler) generated code for {@link ScriptObject}s. Code is
* generated by {@link FunctionObjectCreator}
*
- * TODO this is a horrible constructor - can we do it with fewer args?
- *
- * @param name name of function
+ * @param data static function data
* @param methodHandle handle for invocation
* @param scope scope object
- * @param source source
- * @param token token
* @param allocator instance constructor for function
- * @param allocatorMap initial map that constructor will keep reference to for future instantiations
- * @param needCallee does the function use the {@code callee} variable
- * @param strict are we in strict mode
*/
- public ScriptFunctionImpl(
- final String name,
- final MethodHandle methodHandle,
- final ScriptObject scope,
- final Source source,
- final long token,
- final MethodHandle allocator,
- final PropertyMap allocatorMap,
- final boolean needCallee,
- final boolean strict) {
- super(name, methodHandle, getMap(strict), scope, source, token, allocator, allocatorMap, needCallee, null);
- if (strict) {
+ public ScriptFunctionImpl(final ScriptFunctionData data, final MethodHandle methodHandle,
+ final ScriptObject scope, final MethodHandle allocator) {
+ super(data, methodHandle, getMap(data.isStrict()), scope, allocator);
+ if (data.isStrict()) {
this.setIsStrict();
}
init();
}
@@ -167,11 +154,11 @@
static synchronized ScriptFunction getTypeErrorThrower() {
if (typeErrorThrower == null) {
//name handle
final ScriptFunctionImpl func = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_SETTER, null, false, null);
// clear constructor handle...
- func.constructHandle = null;
+ func.constructor = null;
func.prototype = UNDEFINED;
typeErrorThrower = func;
}
return typeErrorThrower;