Skip to content

Commit

Permalink
fix fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Jan 1, 2021
1 parent 69f5beb commit c5b1a9b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 14 deletions.
9 changes: 8 additions & 1 deletion Jint.Tests.Test262/test/skipped.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@


{
"source": "language/expressions/object/fn-name-arrow.js",
"source": "language/expressions/arrow-function/scope-paramsbody-var-open.js",
"reason": "not implemented: Creation of new variable environment for the function body (as distinct from that for the function's parameters)"
},
Expand All @@ -405,6 +404,14 @@
"source": "built-ins/Object/prototype/toString/proxy-function.js",
"reason": "generators not implemented"
},
{
"source": "language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js",
"reason": "generators not implemented"
},
{
"source": "language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js",
"reason": "generators not implemented"
},

// Esprima problems

Expand Down
11 changes: 9 additions & 2 deletions Jint/Native/Function/ClassDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ internal class ClassDefinition
function,
obj.Engine.ExecutionContext.LexicalEnvironment,
strict: true
);
)
{
_prototypeDescriptor = null

};
closure.SetFunctionName(propKey, prefix: method.Kind == PropertyKind.Get ? "get" : "set");
closure.MakeMethod(obj);

Expand Down Expand Up @@ -207,7 +211,10 @@ internal class ClassDefinition
function,
engine.ExecutionContext.LexicalEnvironment,
strict: true,
proto: prototype);
proto: prototype)
{
_prototypeDescriptor = null
};

closure.MakeMethod(obj);

Expand Down
5 changes: 3 additions & 2 deletions Jint/Native/Function/FunctionInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Jint.Native.Function
{
public abstract class FunctionInstance : ObjectInstance, ICallable
{
protected PropertyDescriptor _prototypeDescriptor;
protected internal PropertyDescriptor _prototypeDescriptor;

protected internal PropertyDescriptor _length;
private PropertyDescriptor _nameDescriptor;
Expand Down Expand Up @@ -67,7 +67,8 @@ public abstract class FunctionInstance : ObjectInstance, ICallable
public bool Strict => _thisMode == FunctionThisMode.Strict;

internal override bool IsConstructor =>
this is IConstructor && _functionDefinition?.Function is not ArrowFunctionExpression;
this is IConstructor
&& _functionDefinition?.Function is not ArrowFunctionExpression;

public virtual bool HasInstance(JsValue v)
{
Expand Down
13 changes: 8 additions & 5 deletions Jint/Native/Function/ScriptFunctionInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ public sealed class ScriptFunctionInstance : FunctionInstance, IConstructor

_length = new LazyPropertyDescriptor(() => JsNumber.Create(function.Initialize(engine, this).Length), PropertyFlag.Configurable);

var prototype = new ObjectInstanceWithConstructor(engine, this)
if (proto is null)
{
_prototype = _engine.Object.PrototypeObject
};
_prototypeDescriptor = new PropertyDescriptor(prototype, PropertyFlag.OnlyWritable);
var prototype = new ObjectInstanceWithConstructor(engine, this)
{
_prototype = _engine.Object.PrototypeObject
};
_prototypeDescriptor = new PropertyDescriptor(prototype, PropertyFlag.OnlyWritable);
}

if (!function.Strict && !engine._isStrict && function.Function is not ArrowFunctionExpression)
{
Expand Down Expand Up @@ -166,7 +169,7 @@ internal void MakeConstructor(bool writableProperty = true, ObjectInstance proto
};
prototype.DefinePropertyOrThrow(CommonProperties.Constructor, new PropertyDescriptor(this, writableProperty, enumerable: false, configurable: false));
}
DefinePropertyOrThrow(CommonProperties.Prototype, new PropertyDescriptor(prototype, writableProperty, enumerable: false, configurable: false));
_prototypeDescriptor = new PropertyDescriptor(prototype, writableProperty, enumerable: false, configurable: false);
}

internal void MakeClassConstructor()
Expand Down
1 change: 0 additions & 1 deletion Jint/Runtime/Environments/FunctionEnvironmentRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public JsValue GetSuperBase()
: ((ObjectInstance) home).GetPrototypeOf();
}


// optimization to have logic near record internal structures.

internal void InitializeParameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ protected override object EvaluateInternal()
_function,
scope,
FunctionThisMode.Lexical,
proto: _engine.Function.PrototypeObject);
proto: _engine.Function.PrototypeObject)
{
_prototypeDescriptor = null
};

closure.PreventExtensions();
return closure;
Expand Down
9 changes: 8 additions & 1 deletion Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override void Initialize()

protected override object EvaluateInternal()
{
JsValue actualThis = null;
string baseReferenceName = null;
JsValue baseValue = null;
var isStrictModeCode = StrictModeScope.IsStrictModeCode;
Expand All @@ -62,6 +63,12 @@ protected override object EvaluateInternal()
{
baseValue = thisExpression.GetValue();
}
else if (_objectExpression is JintSuperExpression)
{
var env = (FunctionEnvironmentRecord) _engine.GetThisEnvironment();
actualThis = env.GetThisBinding();
baseValue = env.GetSuperBase();
}

if (baseValue is null)
{
Expand Down Expand Up @@ -90,7 +97,7 @@ protected override object EvaluateInternal()
? property
: TypeConverter.ToPropertyKey(property);

return _engine._referencePool.Rent(baseValue, propertyKey, isStrictModeCode, thisValue: null);
return _engine._referencePool.Rent(baseValue, propertyKey, isStrictModeCode, thisValue: actualThis);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private object BuildObjectNormal()
_engine.ExecutionContext.LexicalEnvironment,
isStrictModeCode
);
closure.SetFunctionName((property.Kind == PropertyKind.Get ? "get " : "set ") + propName);
closure.SetFunctionName(propName, property.Kind == PropertyKind.Get ? "get" : "set");
if (property.Method)
{
closure.MakeMethod(obj);
Expand Down

0 comments on commit c5b1a9b

Please sign in to comment.