-
Notifications
You must be signed in to change notification settings - Fork 923
Separate top level scope and globalThis.
#2161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
234edce
923639b
95dd979
a7c0521
b79475a
cf32736
b0df6c9
836e4dd
8138693
cb8105d
cff270a
1ce6d52
74840c1
c6cbf52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,10 +137,10 @@ public static Object coercibleIterativeMethod( | |
| Object callbackArg = args.length > 0 ? args[0] : Undefined.instance; | ||
|
|
||
| Function f = getCallbackArg(cx, callbackArg); | ||
| Scriptable parent = ScriptableObject.getTopLevelScope(f); | ||
| TopLevel parent = ScriptableObject.getTopLevelScope(f); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a minor thing but in my new Java code I have been getting more judicious about using "var" in cases like this and if we had done so before then perhaps this would not have been necessary to make this particular change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I've been using |
||
| Scriptable thisArg; | ||
| if (args.length < 2 || args[1] == null || args[1] == Undefined.instance) { | ||
| thisArg = parent; | ||
| thisArg = parent.getGlobalThis(); | ||
| } else { | ||
| thisArg = ScriptRuntime.toObject(cx, scope, args[1]); | ||
| } | ||
|
|
@@ -339,7 +339,8 @@ public static Object reduceMethodWithLength( | |
| throw ScriptRuntime.notFunctionError(callbackArg); | ||
| } | ||
| Function f = (Function) callbackArg; | ||
| Scriptable parent = ScriptableObject.getTopLevelScope(f); | ||
| TopLevel parent = ScriptableObject.getTopLevelScope(f); | ||
| Scriptable globalThis = parent.getGlobalThis(); | ||
| // hack to serve both reduce and reduceRight with the same loop | ||
| boolean movingLeft = operation == ReduceOperation.REDUCE; | ||
| Object value = args.length > 1 ? args[1] : NOT_FOUND; | ||
|
|
@@ -354,7 +355,7 @@ public static Object reduceMethodWithLength( | |
| value = elem; | ||
| } else { | ||
| Object[] innerArgs = {value, elem, index, o}; | ||
| value = f.call(cx, parent, parent, innerArgs); | ||
| value = f.call(cx, parent, globalThis, innerArgs); | ||
| } | ||
| } | ||
| if (value == NOT_FOUND) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a small comment here that
Builtinsare stored asassociatedValueon the scope and notthisObjwhich is now just the GlobalThis object? Not a big deal.