Skip to content

Commit 4e4d39f

Browse files
committed
..
1 parent 5dfe023 commit 4e4d39f

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

continue.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- Module evaluation now walks requested modules ahead of body execution, ResolveExport/export\* follow the spec (cycle-aware, ambiguous names filtered), module namespaces expose unambiguous exports only, and namespace [[Set]]/Reflect.set return false instead of throwing.
3030
- Object destructuring rest now walks [[OwnPropertyKeys]] with exclusions checked before GetOwnPropertyDescriptor, skips Get for non-enumerables, and uses the original object (including proxies) instead of cloning; the proxy rest destructuring get/gOPD/ownKeys-order tests are passing.
3131
- Async functions now resolve their completion through the global Promise constructor even when executed from nested scopes (class/field environments fall back to the root global object), so the async class element clusters involving same-line static async methods/private names are green again.
32+
- Parameter environments now hang off their function environments so default-parameter `super`/`this` lookups see the right bindings, and sloppy generator methods coerce `this` to the realm global object; the object method definition default-super/sloppy-this generators are passing.
3233

3334
## Next Iteration Plan
3435
1. When resuming broader work, run a narrow Language filter outside `ArgumentsObject`/`Array_fromAsync` to find the next hot cluster (avoid full 43k sweep).

languagetests.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@
3535
Expressions_prefixDecrement("language/expressions/prefix-decrement/eval-nostrict.js",False)
3636
Expressions_prefixIncrement
3737
Expressions_prefixIncrement("language/expressions/prefix-increment/eval-nostrict.js",False)
38-
Expressions_super
39-
Expressions_super("language/expressions/super/call-arg-evaluation-err.js",False)
40-
Expressions_super("language/expressions/super/call-construct-invocation.js",False)
41-
Expressions_super("language/expressions/super/call-construct-invocation.js",True)
42-
Expressions_super("language/expressions/super/prop-expr-getsuperbase-before-topropertykey-putvalue-increment.js",False)
43-
Expressions_super("language/expressions/super/prop-expr-getsuperbase-before-topropertykey-putvalue-increment.js",True)
44-
Expressions_super("language/expressions/super/realm.js",False)
45-
Expressions_super("language/expressions/super/realm.js",True)
4638
Expressions_yield
4739
Expressions_yield("language/expressions/yield/star-rhs-iter-thrw-res-done-no-value.js",False)
4840
Expressions_yield("language/expressions/yield/star-rhs-iter-thrw-res-done-no-value.js",True)
@@ -54,6 +46,7 @@
5446
FutureReservedWords
5547
FutureReservedWords("language/future-reserved-words/static.js",False)
5648
GlobalCode
49+
GlobalCode("language/global-code/decl-lex-restricted-global.js",True)
5750
GlobalCode("language/global-code/script-decl-func-err-non-extensible.js",False)
5851
GlobalCode("language/global-code/script-decl-func-err-non-extensible.js",True)
5952
GlobalCode("language/global-code/script-decl-lex-var-declared-via-eval.js",False)
@@ -62,6 +55,10 @@
6255
ModuleCode_topLevelAwait("language/module-code/top-level-await/await-dynamic-import-resolution.js",True)
6356
ModuleCode_topLevelAwait("language/module-code/top-level-await/module-graphs-does-not-hang.js",True)
6457
ModuleCode_topLevelAwait_syntax
58+
ModuleCode_topLevelAwait_syntax("language/module-code/top-level-await/syntax/await-expr-dyn-import.js",True)
59+
ReservedWords
60+
ReservedWords("language/reserved-words/unreserved-words.js",False)
61+
ReservedWords("language/reserved-words/unreserved-words.js",True)
6562
Statements_asyncGenerator
6663
Statements_asyncGenerator("language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js",False)
6764
Statements_asyncGenerator("language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js",True)

src/Asynkron.JsEngine/Ast/TypedAstEvaluator.TypedFunction.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,16 @@ public bool TryDefineProperty(string name, PropertyDescriptor descriptor)
462462
JsEnvironment functionEnvironment;
463463
if (hasParameterExpressions)
464464
{
465-
parameterEnvironment = new JsEnvironment(_closure, true, _isStrict, _function.Source,
465+
functionEnvironment = new JsEnvironment(_closure, true, _isStrict, _function.Source,
466+
description);
467+
functionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
468+
469+
// Hang the parameter environment off the function environment so defaults
470+
// can see `this`/super/new.target while still isolating their bindings
471+
// from the body’s var environment.
472+
parameterEnvironment = new JsEnvironment(functionEnvironment, false, _isStrict, _function.Source,
466473
description, isParameterEnvironment: true);
467474
parameterEnvironment.SetBodyLexicalNames(bodyLexicalNames);
468-
functionEnvironment = new JsEnvironment(parameterEnvironment, true, _isStrict,
469-
_function.Source, description);
470-
functionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
471-
// Parameter expressions (including direct eval) should use the
472-
// dedicated parameter environment as their variable environment
473-
// (ES 10.2.11, FunctionDeclarationInstantiation step 14 when
474-
// HasParameterExpressions is true). This keeps var bindings created
475-
// during parameter evaluation (e.g. `eval("var arguments = ...")`)
476-
// separate from the function body’s var environment so later body
477-
// declarations do not overwrite them.
478475
}
479476
else
480477
{
@@ -484,7 +481,7 @@ public bool TryDefineProperty(string name, PropertyDescriptor descriptor)
484481
parameterEnvironment = functionEnvironment;
485482
}
486483

487-
var executionEnvironment = new JsEnvironment(functionEnvironment, false, _isStrict,
484+
var executionEnvironment = new JsEnvironment(parameterEnvironment, false, _isStrict,
488485
_function.Source, description, isBodyEnvironment: true);
489486
executionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
490487

src/Asynkron.JsEngine/Ast/TypedAstEvaluator.TypedGeneratorInstance.cs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ private JsEnvironment CreateExecutionEnvironment()
219219
JsEnvironment functionEnvironment;
220220
if (hasParameterExpressions)
221221
{
222-
parameterEnvironment = new JsEnvironment(_closure, true, _isStrict, _function.Source,
222+
functionEnvironment = new JsEnvironment(_closure, true, _isStrict, _function.Source,
223+
description);
224+
functionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
225+
226+
parameterEnvironment = new JsEnvironment(functionEnvironment, false, _isStrict, _function.Source,
223227
description, isParameterEnvironment: true);
224228
parameterEnvironment.SetBodyLexicalNames(bodyLexicalNames);
225-
functionEnvironment = new JsEnvironment(parameterEnvironment, true, _isStrict,
226-
_function.Source, description);
227-
functionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
228229
}
229230
else
230231
{
@@ -234,23 +235,52 @@ private JsEnvironment CreateExecutionEnvironment()
234235
parameterEnvironment = functionEnvironment;
235236
}
236237

237-
var executionEnvironment = new JsEnvironment(functionEnvironment, false, _isStrict,
238+
var executionEnvironment = new JsEnvironment(parameterEnvironment, false, _isStrict,
238239
_function.Source, description, isBodyEnvironment: true);
239240
executionEnvironment.SetBodyLexicalNames(bodyLexicalNames);
240241

241-
functionEnvironment.Define(Symbol.This, _thisValue ?? new JsObject());
242+
var generatorContext = _realmState.CreateContext(
243+
ScopeKind.Function,
244+
DetermineGeneratorScopeMode(),
245+
true);
246+
247+
object? boundThis = _thisValue;
248+
if (!_isStrict)
249+
{
250+
if (boundThis is null || ReferenceEquals(boundThis, Symbol.Undefined))
251+
{
252+
boundThis = _realmState.Engine?.GlobalObject;
253+
boundThis ??= Symbol.Undefined;
254+
}
255+
256+
if (boundThis is null)
257+
{
258+
boundThis = new JsObject
259+
{
260+
RealmState = _realmState
261+
};
262+
}
263+
else if (boundThis is not IJsPropertyAccessor &&
264+
!IsNullish(boundThis) &&
265+
boundThis is not IIsHtmlDda)
266+
{
267+
boundThis = ToObjectForDestructuring(boundThis, generatorContext);
268+
}
269+
}
270+
271+
functionEnvironment.Define(Symbol.This, boundThis);
242272
functionEnvironment.Define(Symbol.YieldResumeContextSymbol, _resumeContext);
243273
functionEnvironment.Define(Symbol.GeneratorInstanceSymbol, this);
244274

245275
var superPrototype = _homeObject?.Prototype;
246-
if (superPrototype is null && _thisValue is JsObject thisObj)
276+
if (superPrototype is null && boundThis is JsObject thisObj)
247277
{
248278
superPrototype = thisObj.Prototype;
249279
}
250280

251281
if (superPrototype is not null)
252282
{
253-
var superBinding = new SuperBinding(null, superPrototype, _thisValue, true);
283+
var superBinding = new SuperBinding(null, superPrototype, boundThis, true);
254284
functionEnvironment.Define(Symbol.Super, superBinding);
255285
}
256286

@@ -268,10 +298,6 @@ private JsEnvironment CreateExecutionEnvironment()
268298
parameterEnvironment.Define(functionName, _callable, isConst: true, isLexical: true, blocksFunctionScopeOverride: true);
269299
}
270300

271-
var generatorContext = _realmState.CreateContext(
272-
ScopeKind.Function,
273-
DetermineGeneratorScopeMode(),
274-
true);
275301
generatorContext.BlockedFunctionVarNames = blockedFunctionVarNames;
276302
HoistVarDeclarations(_function.Body, executionEnvironment, generatorContext,
277303
lexicalNames: lexicalNames,

0 commit comments

Comments
 (0)