diff --git a/JSS.Lib/AST/BitwiseNotExpression.cs b/JSS.Lib/AST/BitwiseNotExpression.cs index 5eead2a..9d244a1 100644 --- a/JSS.Lib/AST/BitwiseNotExpression.cs +++ b/JSS.Lib/AST/BitwiseNotExpression.cs @@ -31,7 +31,7 @@ override public Completion Evaluate(VM vm) { // a. Return Number::bitwiseNOT(oldValue). var asNumber = oldValue.Value.AsNumber(); - return Completion.NormalCompletion(Number.BitwiseNOT(asNumber)); + return Number.BitwiseNOT(asNumber); } // 4. Else, else diff --git a/JSS.Lib/AST/CallExpression.cs b/JSS.Lib/AST/CallExpression.cs index d607f37..6d5e78e 100644 --- a/JSS.Lib/AST/CallExpression.cs +++ b/JSS.Lib/AST/CallExpression.cs @@ -105,7 +105,7 @@ private Completion ArgumentListEvaluation(VM vm) precedingArgs.Add(arg.Value); } - return Completion.NormalCompletion(precedingArgs); + return precedingArgs; } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/ComputedPropertyExpression.cs b/JSS.Lib/AST/ComputedPropertyExpression.cs index 62d6a2d..375b4e6 100644 --- a/JSS.Lib/AST/ComputedPropertyExpression.cs +++ b/JSS.Lib/AST/ComputedPropertyExpression.cs @@ -46,7 +46,7 @@ private Completion EvaluatePropertyAccessWithExpressionKey(VM vm, Value baseValu // 4. Return the Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: EMPTY }. var propertyString = propertyKey.Value.AsString(); - return Completion.NormalCompletion(Reference.Resolvable(baseValue, propertyString.Value, Empty.The)); + return Reference.Resolvable(baseValue, propertyString.Value, Empty.The); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/ConstDeclaration.cs b/JSS.Lib/AST/ConstDeclaration.cs index 3e87340..77410d3 100644 --- a/JSS.Lib/AST/ConstDeclaration.cs +++ b/JSS.Lib/AST/ConstDeclaration.cs @@ -44,7 +44,7 @@ override public Completion Evaluate(VM vm) MUST(asReference.InitializeReferencedBinding(value.Value)); // 6. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public string Identifier { get; } diff --git a/JSS.Lib/AST/DebuggerStatement.cs b/JSS.Lib/AST/DebuggerStatement.cs index 851e1f4..c69dfee 100644 --- a/JSS.Lib/AST/DebuggerStatement.cs +++ b/JSS.Lib/AST/DebuggerStatement.cs @@ -17,11 +17,11 @@ public override Completion Evaluate(VM vm) Debugger.Break(); // b. Return a new implementation-defined Completion Record. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 2. Else, // a. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } } \ No newline at end of file diff --git a/JSS.Lib/AST/DoWhileStatement.cs b/JSS.Lib/AST/DoWhileStatement.cs index 50e23fb..8c72f68 100644 --- a/JSS.Lib/AST/DoWhileStatement.cs +++ b/JSS.Lib/AST/DoWhileStatement.cs @@ -62,7 +62,7 @@ override public Completion Evaluate(VM vm) // f. If ToBoolean(exprValue) is false, return V. if (!exprValue.Value.ToBoolean().Value) { - return Completion.NormalCompletion(V); + return V; } } } diff --git a/JSS.Lib/AST/EmptyStatement.cs b/JSS.Lib/AST/EmptyStatement.cs index bc5b030..ef95a4e 100644 --- a/JSS.Lib/AST/EmptyStatement.cs +++ b/JSS.Lib/AST/EmptyStatement.cs @@ -10,6 +10,6 @@ internal sealed class EmptyStatement : INode override public Completion Evaluate(VM vm) { // 1. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } } diff --git a/JSS.Lib/AST/ForStatement.cs b/JSS.Lib/AST/ForStatement.cs index de5aa8f..f8ec236 100644 --- a/JSS.Lib/AST/ForStatement.cs +++ b/JSS.Lib/AST/ForStatement.cs @@ -114,7 +114,7 @@ private Completion ForBodyEvaluation(VM vm) // iii. If ToBoolean(testValue) is false, return V. if (!testValue.Value.ToBoolean().Value) { - return Completion.NormalCompletion(V); + return V; } } diff --git a/JSS.Lib/AST/FunctionDeclaration.cs b/JSS.Lib/AST/FunctionDeclaration.cs index 01cfac0..661150c 100644 --- a/JSS.Lib/AST/FunctionDeclaration.cs +++ b/JSS.Lib/AST/FunctionDeclaration.cs @@ -48,7 +48,7 @@ public FunctionObject InstantiateFunctionObject(Environment env) override public Completion Evaluate(VM vm) { // 1. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public string Identifier { get; } diff --git a/JSS.Lib/AST/GreaterThanEqualsExpression.cs b/JSS.Lib/AST/GreaterThanEqualsExpression.cs index 18516a0..ca347c6 100644 --- a/JSS.Lib/AST/GreaterThanEqualsExpression.cs +++ b/JSS.Lib/AST/GreaterThanEqualsExpression.cs @@ -37,10 +37,10 @@ override public Completion Evaluate(VM vm) if (r.IsAbruptCompletion()) return r; // 6. If r is either true or undefined, return false. Otherwise, return true. - if (r.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(false)); + if (r.Value.IsUndefined()) return new Boolean(false); var rAsBoolean = r.Value.AsBoolean(); - return Completion.NormalCompletion(new Boolean(!rAsBoolean.Value)); + return new Boolean(!rAsBoolean.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/GreaterThanExpreesion.cs b/JSS.Lib/AST/GreaterThanExpreesion.cs index 278dff7..4f2b9fb 100644 --- a/JSS.Lib/AST/GreaterThanExpreesion.cs +++ b/JSS.Lib/AST/GreaterThanExpreesion.cs @@ -37,10 +37,10 @@ override public Completion Evaluate(VM vm) if (r.IsAbruptCompletion()) return r; // 6. If r is undefined, return false. Otherwise, return r. - if (r.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(false)); + if (r.Value.IsUndefined()) return new Boolean(false); var rAsBoolean = r.Value.AsBoolean(); - return Completion.NormalCompletion(new Boolean(rAsBoolean.Value)); + return new Boolean(rAsBoolean.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/IExpression.cs b/JSS.Lib/AST/IExpression.cs index ca327a6..34c99a7 100644 --- a/JSS.Lib/AST/IExpression.cs +++ b/JSS.Lib/AST/IExpression.cs @@ -51,7 +51,7 @@ static public Completion ApplyStringOrNumericBinaryOperator(Value lval, BinaryOp var lstrValue = lstr.Value.AsString(); var rstrValue = rstr.Value.AsString(); var concatenation = lstrValue.Value + rstrValue.Value; - return Completion.NormalCompletion(new String(concatenation)); + return new String(concatenation); } // d. Set lval to lprim. @@ -99,7 +99,7 @@ static public Completion ApplyStringOrNumericBinaryOperator(Value lval, BinaryOp }; var result = operation(lnum.Value.AsNumber(), rnum.Value.AsNumber()); - return Completion.NormalCompletion(result); + return result; } // 13.15.4 EvaluateStringOrNumericBinaryExpression ( leftOperand, opText, rightOperand ) diff --git a/JSS.Lib/AST/IfStatement.cs b/JSS.Lib/AST/IfStatement.cs index 72a206f..ecb0a01 100644 --- a/JSS.Lib/AST/IfStatement.cs +++ b/JSS.Lib/AST/IfStatement.cs @@ -74,7 +74,7 @@ private Completion EvaluateWithoutElse(VM vm) if (!exprValue.Value) { // a. Return undefined. - return Completion.NormalCompletion(Undefined.The); + return Undefined.The; } // 4. Else, else diff --git a/JSS.Lib/AST/LessThanEqualsExpression.cs b/JSS.Lib/AST/LessThanEqualsExpression.cs index 14f27e3..9cd2be4 100644 --- a/JSS.Lib/AST/LessThanEqualsExpression.cs +++ b/JSS.Lib/AST/LessThanEqualsExpression.cs @@ -37,10 +37,10 @@ override public Completion Evaluate(VM vm) if (r.IsAbruptCompletion()) return r; // 6. If r is either true or undefined, return false. Otherwise, return true. - if (r.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(false)); + if (r.Value.IsUndefined()) return new Boolean(false); var rAsBoolean = r.Value.AsBoolean(); - return Completion.NormalCompletion(new Boolean(!rAsBoolean.Value)); + return new Boolean(!rAsBoolean.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/LessThanExpression.cs b/JSS.Lib/AST/LessThanExpression.cs index 8188a94..1992e14 100644 --- a/JSS.Lib/AST/LessThanExpression.cs +++ b/JSS.Lib/AST/LessThanExpression.cs @@ -37,10 +37,10 @@ override public Completion Evaluate(VM vm) if (r.IsAbruptCompletion()) return r; // 6. If r is undefined, return false. Otherwise, return r. - if (r.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(false)); + if (r.Value.IsUndefined()) return new Boolean(false); var rAsBoolean = r.Value.AsBoolean(); - return Completion.NormalCompletion(new Boolean(rAsBoolean.Value)); + return new Boolean(rAsBoolean.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/LetDeclaration.cs b/JSS.Lib/AST/LetDeclaration.cs index 97bb9d7..e2e4a7b 100644 --- a/JSS.Lib/AST/LetDeclaration.cs +++ b/JSS.Lib/AST/LetDeclaration.cs @@ -43,7 +43,7 @@ private Completion EvaluateWithoutInitializer(VM vm) MUST(asReference.InitializeReferencedBinding(Undefined.The)); // 3. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } private Completion EvaluateWithInitializer(VM vm) @@ -69,7 +69,7 @@ private Completion EvaluateWithInitializer(VM vm) MUST(asReference.InitializeReferencedBinding(value.Value)); // 6. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public string Identifier { get; } diff --git a/JSS.Lib/AST/Literal/BooleanLiteral.cs b/JSS.Lib/AST/Literal/BooleanLiteral.cs index 4f0ad85..539c6f7 100644 --- a/JSS.Lib/AST/Literal/BooleanLiteral.cs +++ b/JSS.Lib/AST/Literal/BooleanLiteral.cs @@ -17,7 +17,7 @@ override public Completion Evaluate(VM _) { // 1. If BooleanLiteral is the token false, return false. // 2. If BooleanLiteral is the token true, return true. - return Completion.NormalCompletion(_value); + return _value; } public bool Value diff --git a/JSS.Lib/AST/Literal/NullLiteral.cs b/JSS.Lib/AST/Literal/NullLiteral.cs index 64931ba..4b1c157 100644 --- a/JSS.Lib/AST/Literal/NullLiteral.cs +++ b/JSS.Lib/AST/Literal/NullLiteral.cs @@ -10,6 +10,6 @@ internal sealed class NullLiteral : IExpression override public Completion Evaluate(VM vm) { // 1. Return null. - return Completion.NormalCompletion(Null.The); + return Null.The; } } diff --git a/JSS.Lib/AST/Literal/NumericLiteral.cs b/JSS.Lib/AST/Literal/NumericLiteral.cs index 5b85164..d17f18e 100644 --- a/JSS.Lib/AST/Literal/NumericLiteral.cs +++ b/JSS.Lib/AST/Literal/NumericLiteral.cs @@ -15,7 +15,7 @@ public NumericLiteral(double value) override public Completion Evaluate(VM _) { // 1. Return the NumericValue of NumericLiteral as defined in 12.9.3. - return Completion.NormalCompletion(_value); + return _value; } public double Value diff --git a/JSS.Lib/AST/Literal/ObjectLiteral.cs b/JSS.Lib/AST/Literal/ObjectLiteral.cs index a8231fe..1a6c3f5 100644 --- a/JSS.Lib/AST/Literal/ObjectLiteral.cs +++ b/JSS.Lib/AST/Literal/ObjectLiteral.cs @@ -12,6 +12,6 @@ override public Completion Evaluate(VM vm) { // FIXME: Implement the rest of the evaluation when we parse property definitions // 1. Return OrdinaryObjectCreate(%Object.prototype%). - return Completion.NormalCompletion(new Object(ObjectPrototype.The)); + return new Object(ObjectPrototype.The); } } diff --git a/JSS.Lib/AST/Literal/StringLiteral.cs b/JSS.Lib/AST/Literal/StringLiteral.cs index 45ee7bc..1e1c3b7 100644 --- a/JSS.Lib/AST/Literal/StringLiteral.cs +++ b/JSS.Lib/AST/Literal/StringLiteral.cs @@ -15,7 +15,7 @@ public StringLiteral(string value) override public Completion Evaluate(VM _) { // 1. Return the SV of StringLiteral as defined in 12.9.4.2. - return Completion.NormalCompletion(_value); + return _value; } public string Value diff --git a/JSS.Lib/AST/LogicalNotExpression.cs b/JSS.Lib/AST/LogicalNotExpression.cs index 13df706..35ef83f 100644 --- a/JSS.Lib/AST/LogicalNotExpression.cs +++ b/JSS.Lib/AST/LogicalNotExpression.cs @@ -26,7 +26,7 @@ override public Completion Evaluate(VM vm) // 3. If oldValue is true, return false. // 4. Return true. - return Completion.NormalCompletion(new Boolean(!oldValue.Value)); + return new Boolean(!oldValue.Value); } public IExpression Expression { get; } diff --git a/JSS.Lib/AST/LooseInequalityExpression.cs b/JSS.Lib/AST/LooseInequalityExpression.cs index 7141d4d..ec7d538 100644 --- a/JSS.Lib/AST/LooseInequalityExpression.cs +++ b/JSS.Lib/AST/LooseInequalityExpression.cs @@ -38,7 +38,7 @@ override public Completion Evaluate(VM vm) // 6. If r is true, return false. Otherwise, return true. var rAsBoolean = r.Value.AsBoolean().Value; - return Completion.NormalCompletion(new Boolean(!rAsBoolean)); + return new Boolean(!rAsBoolean); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/PrefixDecrementExpression.cs b/JSS.Lib/AST/PrefixDecrementExpression.cs index bfb2ecf..106c225 100644 --- a/JSS.Lib/AST/PrefixDecrementExpression.cs +++ b/JSS.Lib/AST/PrefixDecrementExpression.cs @@ -49,7 +49,7 @@ override public Completion Evaluate(VM vm) if (putResult.IsAbruptCompletion()) return putResult; // 6. Return newValue. - return Completion.NormalCompletion(newValue); + return newValue; } public IExpression Expression { get; } diff --git a/JSS.Lib/AST/PrefixIncrementExpression.cs b/JSS.Lib/AST/PrefixIncrementExpression.cs index b69b7af..ae774f5 100644 --- a/JSS.Lib/AST/PrefixIncrementExpression.cs +++ b/JSS.Lib/AST/PrefixIncrementExpression.cs @@ -48,7 +48,7 @@ public override Completion Evaluate(VM vm) if (putResult.IsAbruptCompletion()) return putResult; // 6. Return newValue. - return Completion.NormalCompletion(newValue); + return newValue; } public IExpression Expression { get; } diff --git a/JSS.Lib/AST/PropertyExpression.cs b/JSS.Lib/AST/PropertyExpression.cs index bc6c612..73db384 100644 --- a/JSS.Lib/AST/PropertyExpression.cs +++ b/JSS.Lib/AST/PropertyExpression.cs @@ -26,7 +26,7 @@ override public Completion Evaluate(VM vm) // FIXME: 3. If the source text matched by this MemberExpression is strict mode code, let strict be true; else let strict be false. // 4. Return EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict). - return Completion.NormalCompletion(EvaluatePropertyAccessWithIdentifierKey(baseValue.Value)); + return EvaluatePropertyAccessWithIdentifierKey(baseValue.Value); } // 13.3.4 EvaluatePropertyAccessWithIdentifierKey, https://tc39.es/ecma262/#sec-evaluate-property-access-with-identifier-key diff --git a/JSS.Lib/AST/StatementList.cs b/JSS.Lib/AST/StatementList.cs index 4038ad0..17a7317 100644 --- a/JSS.Lib/AST/StatementList.cs +++ b/JSS.Lib/AST/StatementList.cs @@ -15,7 +15,7 @@ public StatementList(List statements) override public Completion Evaluate(VM vm) { // 1. Let sl be ? Evaluation of StatementList. - Completion completion = Completion.NormalCompletion(Empty.The); + Completion completion = Empty.The; foreach (var statement in Statements) { // 2. Let s be Completion(Evaluation of StatementListItem). diff --git a/JSS.Lib/AST/StrictEqualityExpression.cs b/JSS.Lib/AST/StrictEqualityExpression.cs index c1753c8..f7dd361 100644 --- a/JSS.Lib/AST/StrictEqualityExpression.cs +++ b/JSS.Lib/AST/StrictEqualityExpression.cs @@ -32,7 +32,7 @@ override public Completion Evaluate(VM vm) if (rval.IsAbruptCompletion()) return rval; // 5. Return IsStrictlyEqual(rval, lval). - return Completion.NormalCompletion(Value.IsStrictlyEqual(rval.Value, lval.Value)); + return Value.IsStrictlyEqual(rval.Value, lval.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/StrictInequalityExpression.cs b/JSS.Lib/AST/StrictInequalityExpression.cs index 8c95b1d..93d2b5c 100644 --- a/JSS.Lib/AST/StrictInequalityExpression.cs +++ b/JSS.Lib/AST/StrictInequalityExpression.cs @@ -36,7 +36,7 @@ override public Completion Evaluate(VM vm) var r = Value.IsStrictlyEqual(rval.Value, lval.Value); // 6. If r is true, return false. Otherwise, return true. - return Completion.NormalCompletion(new Boolean(!r.Value)); + return new Boolean(!r.Value); } public IExpression Lhs { get; } diff --git a/JSS.Lib/AST/TypeOfExpression.cs b/JSS.Lib/AST/TypeOfExpression.cs index a80fa7a..7d31e7c 100644 --- a/JSS.Lib/AST/TypeOfExpression.cs +++ b/JSS.Lib/AST/TypeOfExpression.cs @@ -28,7 +28,7 @@ public override Completion Evaluate(VM vm) var asReference = val.Value.AsReference(); if (asReference.IsUnresolvableReference()) { - return Completion.NormalCompletion(new String("undefined")); + return new String("undefined"); } } @@ -39,43 +39,43 @@ public override Completion Evaluate(VM vm) // 4. If val is undefined, return "undefined". if (val.Value.IsUndefined()) { - return Completion.NormalCompletion(new String("undefined")); + return new String("undefined"); } // 5. If val is null, return "object". if (val.Value.IsNull()) { - return Completion.NormalCompletion(new String("object")); + return new String("object"); } // 6. If val is a String, return "string". if (val.Value.IsString()) { - return Completion.NormalCompletion(new String("string")); + return new String("string"); } // 7. If val is a Symbol, return "symbol". if (val.Value.IsSymbol()) { - return Completion.NormalCompletion(new String("symbol")); + return new String("symbol"); } // 8. If val is a Boolean, return "boolean". if (val.Value.IsBoolean()) { - return Completion.NormalCompletion(new String("boolean")); + return new String("boolean"); } // 9. If val is a Number, return "number". if (val.Value.IsNumber()) { - return Completion.NormalCompletion(new String("number")); + return new String("number"); } // 10. If val is a BigInt, return "bigint". if (val.Value.IsBigInt()) { - return Completion.NormalCompletion(new String("bigint")); + return new String("bigint"); } // 11. Assert: val is an Object. @@ -86,11 +86,11 @@ public override Completion Evaluate(VM vm) // 13. If val has a [[Call]] internal slot, return "function". if (val.Value.HasInternalCall()) { - return Completion.NormalCompletion(new String("function")); + return new String("function"); } // 14. Return "object". - return Completion.NormalCompletion(new String("object")); + return new String("object"); } public IExpression Expression { get; } diff --git a/JSS.Lib/AST/UnaryMinusExpression.cs b/JSS.Lib/AST/UnaryMinusExpression.cs index 87ed251..e78f0c0 100644 --- a/JSS.Lib/AST/UnaryMinusExpression.cs +++ b/JSS.Lib/AST/UnaryMinusExpression.cs @@ -31,7 +31,7 @@ override public Completion Evaluate(VM vm) { // a. Return Number::unaryMinus(oldValue). var asNumber = oldValue.Value.AsNumber(); - return Completion.NormalCompletion(Number.UnaryMinus(asNumber)); + return Number.UnaryMinus(asNumber); } // 4. Else, else diff --git a/JSS.Lib/AST/Values/FunctionObject.cs b/JSS.Lib/AST/Values/FunctionObject.cs index 2a74165..002aa8a 100644 --- a/JSS.Lib/AST/Values/FunctionObject.cs +++ b/JSS.Lib/AST/Values/FunctionObject.cs @@ -59,13 +59,13 @@ public Completion Call(VM vm, Value thisArgument, List argumentsList) vm.PopExecutionContext(); // 8. If result.[[Type]] is RETURN, return result.[[Value]]. - if (result.IsReturnCompletion()) return Completion.NormalCompletion(result.Value); + if (result.IsReturnCompletion()) return result.Value; // 9. ReturnIfAbrupt(result). if (result.IsAbruptCompletion()) return result; // 10. Return undefined. - return Completion.NormalCompletion(Undefined.The); + return Undefined.The; } // 10.2.1.1 PrepareForOrdinaryCall ( F, newTarget ), https://tc39.es/ecma262/#sec-prepareforordinarycall @@ -224,10 +224,10 @@ public Completion Construct(VM vm, List argumentsList) if (result.IsReturnCompletion()) { // a. If result.[[Value]] is an Object, return result.[[Value]]. - if (result.Value.IsObject()) return Completion.NormalCompletion(result.Value); + if (result.Value.IsObject()) return result.Value; // b. If kind is BASE, return thisArgument. - if (ConstructorKind == ConstructorKind.BASE) return Completion.NormalCompletion(thisArgument); + if (ConstructorKind == ConstructorKind.BASE) return thisArgument; // c. If result.[[Value]] is not undefined, throw a FIXME: TypeError exception. if (!result.Value.IsUndefined()) return Completion.ThrowCompletion(new String("Function constructor without kind of base did not return an object/undefined")); @@ -246,8 +246,8 @@ public Completion Construct(VM vm, List argumentsList) // 13. Assert: thisBinding is an Object. Debug.Assert(thisBinding.Value is Object); - // FIXME: 14. Return thisBinding. - return Completion.NormalCompletion(thisBinding.Value); + // 14. Return thisBinding. + return thisBinding; } // 10.2.3 OrdinaryFunctionCreate ( FIXME: functionPrototype, FIXME: sourceText, ParameterList, Body, thisMode, env, FIXME: privateEnv ), https://tc39.es/ecma262/#sec-ordinaryfunctioncreate @@ -637,7 +637,7 @@ private Completion FunctionDeclarationInstantiation(VM vm, List argumentsList) } // 37. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // FIXME: We should have a Parameters parse node that we can call BoundNames on diff --git a/JSS.Lib/AST/Values/Object.cs b/JSS.Lib/AST/Values/Object.cs index bb9867d..79b8294 100644 --- a/JSS.Lib/AST/Values/Object.cs +++ b/JSS.Lib/AST/Values/Object.cs @@ -53,7 +53,7 @@ static public Completion Set(Object O, string P, Value V, bool Throw) } // 3. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 7.3.9 DefinePropertyOrThrow ( O, P, desc ), https://tc39.es/ecma262/#sec-definepropertyorthrow @@ -68,7 +68,7 @@ static public Completion DefinePropertyOrThrow(Object O, string P, Property desc if (!asBoolean.Value) return Completion.ThrowCompletion(new String($"Should not define property of name {P} with a value of {desc.Value}")); // 3. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 7.3.12 HasProperty ( O, P ), https://tc39.es/ecma262/#sec-hasproperty @@ -87,7 +87,7 @@ static public Completion HasOwnProperty(Object O, string P) // 2. If desc is undefined, return false. // 3. Return true. - return Completion.NormalCompletion(new Boolean(!desc.Value.IsUndefined())); + return new Boolean(!desc.Value.IsUndefined()); } // 7.3.14 Call ( F, V [ , argumentsList ] ) @@ -120,7 +120,7 @@ private Completion OrdinaryGetOwnProperty(Object O, string P) // 1. If O does not have an own property with key P, return undefined. if (!O.DataProperties.ContainsKey(P)) { - return Completion.NormalCompletion(Undefined.The); + return Undefined.The; } // FIXME: 2. Let D be a newly created Property Descriptor with no fields. @@ -135,7 +135,7 @@ private Completion OrdinaryGetOwnProperty(Object O, string P) // FIXME: 6. Set D.[[Enumerable]] to the value of X's [[Enumerable]] attribute. // FIXME: 7. Set D.[[Configurable]] to the value of X's [[Configurable]] attribute. // FIXME: 8. Return D. - return Completion.NormalCompletion(O.DataProperties[P].Value); + return O.DataProperties[P].Value; } // 10.1.6 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc @@ -152,7 +152,7 @@ static public Completion OrdinaryDefineOwnProperty(Object O, string P, Property // FIXME: 2. Let extensible be ? IsExtensible(O). // FIXME: 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). O.DataProperties.Add(P, desc); - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // 10.1.7 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p @@ -170,7 +170,7 @@ static public Completion OrdinaryHasProperty(Object O, string P) if (hasOwn.IsAbruptCompletion()) return hasOwn; // FIXME: 2. If hasOwn is not undefined, return true. - return Completion.NormalCompletion(new Boolean(!hasOwn.Value.IsUndefined())); + return new Boolean(!hasOwn.Value.IsUndefined()); // FIXME: 3. Let parent be ? O.[[GetPrototypeOf]](). // FIXME: 4. If parent is not null, then @@ -195,7 +195,7 @@ static public Completion OrdinaryGet(Object O, string P, Object receiver) // FIXME: c. Return ? parent.[[Get]](P, Receiver). // FIXME: 3. If IsDataDescriptor(desc) is true, return desc.[[Value]]. - return Completion.NormalCompletion(O.DataProperties[P].Value); + return O.DataProperties[P].Value; // FIXME: 4. Assert: IsAccessorDescriptor(desc) is true. // FIXME: 5. Let getter be desc.[[Get]]. @@ -225,7 +225,7 @@ static public Completion OrdinarySet(Object O, string P, Value V, Object receive receiver.DataProperties[P] = new Property(V, new Attributes(true, false, false)); } - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // FIXME: Accessor Attributes diff --git a/JSS.Lib/AST/Values/Value.cs b/JSS.Lib/AST/Values/Value.cs index 84c74f1..4120aaf 100644 --- a/JSS.Lib/AST/Values/Value.cs +++ b/JSS.Lib/AST/Values/Value.cs @@ -94,7 +94,7 @@ public Completion GetValue() // 1. If V is not a Reference Record, return V. if (!IsReference()) { - return Completion.NormalCompletion(this); + return this; } // FIXME: Throw an ReferenceError Object @@ -159,7 +159,7 @@ public Completion PutValue(VM vm, Value W) if (setResult.IsAbruptCompletion()) return setResult; // d. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 3. If IsPropertyReference(V) is true, then if (reference.IsPropertyReference()) @@ -177,7 +177,7 @@ public Completion PutValue(VM vm, Value W) // FIXME: d. If succeeded is false FIXME: (and V.[[Strict]] is true,) throw a TypeError exception. // e. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 4. Else, else @@ -214,7 +214,7 @@ public Completion ToPrimitive() // FIXME: d. Return? OrdinaryToPrimitive(input, preferredType). // 2. Return input. - return Completion.NormalCompletion(this); + return this; } // 7.1.2 ToBoolean ( argument ), https://tc39.es/ecma262/#sec-toboolean @@ -273,21 +273,21 @@ public Completion ToNumeric() public Completion ToNumber() { // 1. If argument is a Number, return argument. - if (IsNumber()) return Completion.NormalCompletion(this); + if (IsNumber()) return this; // FIXME: 2. If argument is either a Symbol or a BigInt, throw a TypeError exception. // FIXME: 3. If argument is undefined, return NaN. // 4. If argument is either null or false, return FIXME: +0𝔽. - if (IsNull()) return Completion.NormalCompletion(new Number(0.0)); + if (IsNull()) return new Number(0.0); if (IsBoolean()) { // 5. If argument is true, return 1𝔽. var boolean = AsBoolean(); var asNumber = new Number(boolean.Value ? 1.0 : 0.0); - return Completion.NormalCompletion(asNumber); + return asNumber; } // FIXME: Implement StringToNumber instead of using double.Parse @@ -298,11 +298,11 @@ public Completion ToNumber() { var asString = AsString(); var asNumber = new Number(double.Parse(asString.Value)); - return Completion.NormalCompletion(asNumber); + return asNumber; } catch (Exception) { - return Completion.NormalCompletion(Number.NaN); + return Number.NaN; } } @@ -317,14 +317,14 @@ public Completion ToNumber() public Completion ToStringJS() { // 1. If argument is a String, return argument. - if (IsString()) return Completion.NormalCompletion(this); + if (IsString()) return this; // FIXME: 2. If argument is a Symbol, throw a TypeError exception. // FIXME: 3. If argument is undefined, return "undefined". // 4. If argument is null, return "null". - if (IsNull()) return Completion.NormalCompletion(new String("null")); + if (IsNull()) return new String("null"); // 5. If argument is true, return "true". // 6. If argument is false, return "false". @@ -332,7 +332,7 @@ public Completion ToStringJS() { var boolean = AsBoolean(); var asString = new String(boolean.Value ? "true" : "false"); - return Completion.NormalCompletion(asString); + return asString; } // FIXME: Follow the spec instead of using C#'s ToString @@ -341,7 +341,7 @@ public Completion ToStringJS() { var number = AsNumber(); var asString = new String(number.Value.ToString()); - return Completion.NormalCompletion(asString); + return asString; } // FIXME: 8. If argument is a BigInt, return BigInt::toString(argument, 10). @@ -370,7 +370,7 @@ public Completion ToObject() // FIXME: Implement the rest of the conversions // Object, Return argument. - return Completion.NormalCompletion(this); + return this; } // 7.1.19 ToPropertyKey ( argument ), https://tc39.es/ecma262/#sec-topropertykey @@ -388,7 +388,7 @@ public Completion ToPropertyKey() } // 3. Return ! ToString(key). - return Completion.NormalCompletion(MUST(key.Value.ToStringJS())); + return MUST(key.Value.ToStringJS()); } // 7.2.3 IsCallable ( argument ), https://tc39.es/ecma262/#sec-iscallable @@ -509,18 +509,18 @@ static public Completion IsLessThan(Value x, Value y, bool leftFirst) // iii. If cx < cy, return true. if (cx < cy) { - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // iv. If cx > cy, return false. if (cx > cy) { - return Completion.NormalCompletion(new Boolean(false)); + return new Boolean(false); } } // d. If lx < ly, return true. Otherwise, return false. - return Completion.NormalCompletion(new Boolean(lx < ly)); + return new Boolean(lx < ly); } // 4. Else, @@ -548,7 +548,7 @@ static public Completion IsLessThan(Value x, Value y, bool leftFirst) // i. If nx is a Number, then // 1. Return Number::lessThan(nx, ny). var result = Number.LessThan(nx.Value.AsNumber(), ny.Value.AsNumber()); - return Completion.NormalCompletion(result); + return result; // FIXME: ii. Else, // FIXME: 1. Assert: nx is a BigInt. @@ -567,19 +567,19 @@ static public Completion IsLooselyEqual(Value x, Value y) if (x.Type().Equals(y.Type())) { // a. Return IsStrictlyEqual(x, y). - return Completion.NormalCompletion(IsStrictlyEqual(x, y)); + return IsStrictlyEqual(x, y); } // 2. If x is null and y is undefined, return true. if (x.IsNull() && y.IsUndefined()) { - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // 3. If x is undefined and y is null, return true. if (x.IsUndefined() && y.IsNull()) { - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // 4. NOTE: This step is replaced in section B.3.6.2. @@ -587,13 +587,13 @@ static public Completion IsLooselyEqual(Value x, Value y) // 5. If x is a Number and y is a String, return ! IsLooselyEqual(x, ! ToNumber(y)). if (x.IsNumber() && y.IsString()) { - return Completion.NormalCompletion(MUST(IsLooselyEqual(x, MUST(y.ToNumber())))); + return MUST(IsLooselyEqual(x, MUST(y.ToNumber()))); } // 6. If x is a String and y is a Number, return ! IsLooselyEqual(! ToNumber(x), y). if (x.IsString() && y.IsNumber()) { - return Completion.NormalCompletion(MUST(IsLooselyEqual(MUST(x.ToNumber()), y))); + return MUST(IsLooselyEqual(MUST(x.ToNumber()), y)); } // FIXME: 7. If x is a BigInt and y is a String, then @@ -631,7 +631,7 @@ static public Completion IsLooselyEqual(Value x, Value y) // FIXME: b. If ℝ(x) = ℝ(y), return true; otherwise return false. // 14. Return false. - return Completion.NormalCompletion(new Boolean(false)); + return new Boolean(false); } // 7.2.15 IsStrictlyEqual ( x, y ), https://tc39.es/ecma262/#sec-isstrictlyequal diff --git a/JSS.Lib/AST/VarStatement.cs b/JSS.Lib/AST/VarStatement.cs index 4a11148..0f0761d 100644 --- a/JSS.Lib/AST/VarStatement.cs +++ b/JSS.Lib/AST/VarStatement.cs @@ -49,7 +49,7 @@ override public Completion Evaluate(VM vm) private Completion EvaluateWithoutInitializer() { // 1. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } private Completion EvaluateWithInitializer(VM vm) @@ -78,7 +78,7 @@ private Completion EvaluateWithInitializer(VM vm) if (putResult.IsAbruptCompletion()) return putResult; // 6. Return EMPTY. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public string Identifier { get; } diff --git a/JSS.Lib/AST/VoidExpression.cs b/JSS.Lib/AST/VoidExpression.cs index 16b99bc..84bbdb7 100644 --- a/JSS.Lib/AST/VoidExpression.cs +++ b/JSS.Lib/AST/VoidExpression.cs @@ -23,7 +23,7 @@ public override Completion Evaluate(VM vm) if (value.IsAbruptCompletion()) return value; // 3. Return undefined. - return Completion.NormalCompletion(Undefined.The); + return Undefined.The; } public IExpression Expression { get; } diff --git a/JSS.Lib/AST/WhileStatement.cs b/JSS.Lib/AST/WhileStatement.cs index 1c6f4b9..69edecf 100644 --- a/JSS.Lib/AST/WhileStatement.cs +++ b/JSS.Lib/AST/WhileStatement.cs @@ -47,7 +47,7 @@ override public Completion Evaluate(VM vm) // c. If ToBoolean(exprValue) is false, return V. if (!exprValue.Value.ToBoolean().Value) { - return Completion.NormalCompletion(V); + return V; } // d. Let stmtResult be Completion(Evaluation of Statement). diff --git a/JSS.Lib/Execution/Completion.cs b/JSS.Lib/Execution/Completion.cs index 02eafb8..91c4f87 100644 --- a/JSS.Lib/Execution/Completion.cs +++ b/JSS.Lib/Execution/Completion.cs @@ -41,6 +41,9 @@ static public Completion NormalCompletion(Value value) return new Completion(CompletionType.Normal, value, ""); } + // NOTE: We use an implicit conversion operator as a syntaxic sugar for NormalCompletion in functions + public static implicit operator Completion(Value value) => NormalCompletion(value); + // 6.2.4.2 ThrowCompletion ( value ), https://tc39.es/ecma262/#sec-throwcompletion static public Completion ThrowCompletion(Value value) { diff --git a/JSS.Lib/Execution/DeclarativeEnvironment.cs b/JSS.Lib/Execution/DeclarativeEnvironment.cs index 602e197..6c28acf 100644 --- a/JSS.Lib/Execution/DeclarativeEnvironment.cs +++ b/JSS.Lib/Execution/DeclarativeEnvironment.cs @@ -38,7 +38,7 @@ override public Completion CreateMutableBinding(string N, bool D) _identifierToBinding.Add(N, new Binding(Undefined.The, true, false)); // 3. Return unused. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.1.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-createimmutablebinding-n-s @@ -52,7 +52,7 @@ override public Completion CreateImmutableBinding(string N, bool S) _identifierToBinding.Add(N, new Binding(Undefined.The, false, S)); // 3. Return unused. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.1.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-declarative-environment-records-initializebinding-n-v @@ -68,7 +68,7 @@ public override Completion InitializeBinding(string N, Value V) // FIXME: 3. Record that the binding for N in envRec has been initialized. // 4. Return unused. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.1.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-getbindingvalue-n-s @@ -90,7 +90,7 @@ public override Completion SetMutableBinding(string N, Value V, bool S) MUST(InitializeBinding(N, V)); // d. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 2. If the binding for N in envRec is a strict binding, set S to true. @@ -120,7 +120,7 @@ public override Completion SetMutableBinding(string N, Value V, bool S) } // 6. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.1.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-getbindingvalue-n-s @@ -133,7 +133,7 @@ override public Completion GetBindingValue(string N, bool S) // 3. Return the value currently bound to N in envRec. var binding = _identifierToBinding[N]; - return Completion.NormalCompletion(binding.Value); + return binding.Value; } // 9.1.1.1.8 HasThisBinding ( ), https://tc39.es/ecma262/#sec-declarative-environment-records-hasthisbinding diff --git a/JSS.Lib/Execution/Environment.cs b/JSS.Lib/Execution/Environment.cs index bf1e01a..d4e6049 100644 --- a/JSS.Lib/Execution/Environment.cs +++ b/JSS.Lib/Execution/Environment.cs @@ -29,7 +29,7 @@ static public Completion GetIdentifierReference(Environment? env, string name) if (env is null) { // a. Return the Reference Record { [[Base]]: UNRESOLVABLE, [[ReferencedName]]: name, [[Strict]]: strict, [[ThisValue]]: EMPTY }. - return Completion.NormalCompletion(Reference.Unresolvable(name, Empty.The)); + return Reference.Unresolvable(name, Empty.The); } // 2. Let exists be ? env.HasBinding(name). @@ -39,7 +39,7 @@ static public Completion GetIdentifierReference(Environment? env, string name) if (exists) { // a. Return the Reference Record { [[Base]]: env, [[ReferencedName]]: name, [[Strict]]: strict, [[ThisValue]]: EMPTY }. - return Completion.NormalCompletion(Reference.Resolvable(env, name, Empty.The)); + return Reference.Resolvable(env, name, Empty.The); } // 4. Else, else diff --git a/JSS.Lib/Execution/FunctionEnvironment.cs b/JSS.Lib/Execution/FunctionEnvironment.cs index 4c1c649..035ab21 100644 --- a/JSS.Lib/Execution/FunctionEnvironment.cs +++ b/JSS.Lib/Execution/FunctionEnvironment.cs @@ -51,7 +51,7 @@ public Completion BindThisValue(Value V) // 2. If envRec.[[ThisBindingStatus]] is INITIALIZED, throw a FIXKME: ReferenceError exception. if (ThisBindingStatus == ThisBindingStatus.INITIALIZED) { - return Completion.NormalCompletion(new String("Tried to bind a this value to already this-initialized function environment")); + return new String("Tried to bind a this value to already this-initialized function environment"); } // 3. Set envRec.[[ThisValue]] to V. @@ -61,7 +61,7 @@ public Completion BindThisValue(Value V) ThisBindingStatus = ThisBindingStatus.INITIALIZED; // 5. Return V. - return Completion.NormalCompletion(V); + return V; } // 9.1.1.3.2 HasThisBinding ( ), https://tc39.es/ecma262/#sec-function-environment-records-hasthisbinding @@ -80,11 +80,11 @@ override public Completion GetThisBinding() // 2. If envRec.[[ThisBindingStatus]] is UNINITIALIZED, throw a FIXME: ReferenceError exception. if (ThisBindingStatus == ThisBindingStatus.UNINITIALIZED) { - return Completion.NormalCompletion(new String("Tried to get an uninitialized this value")); + return Completion.ThrowCompletion(new String("Tried to get an uninitialized this value")); } // 3. Return envRec.[[ThisValue]]. - return Completion.NormalCompletion(ThisValue!); + return ThisValue!; } public Value? ThisValue { get; private set; } diff --git a/JSS.Lib/Execution/GlobalEnvironment.cs b/JSS.Lib/Execution/GlobalEnvironment.cs index ef7b342..a211b27 100644 --- a/JSS.Lib/Execution/GlobalEnvironment.cs +++ b/JSS.Lib/Execution/GlobalEnvironment.cs @@ -59,7 +59,7 @@ override public Completion CreateMutableBinding(string N, bool D) if (DeclarativeRecord.HasBinding(N)) return Completion.ThrowCompletion(new String($"redeclaration of mutable binding {N}")); // 3. Return ! DclRec.CreateMutableBinding(N, D). - return Completion.NormalCompletion(MUST(DeclarativeRecord.CreateMutableBinding(N, D))); + return MUST(DeclarativeRecord.CreateMutableBinding(N, D)); } // 9.1.1.4.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-createimmutablebinding-n-s @@ -70,7 +70,7 @@ override public Completion CreateImmutableBinding(string N, bool S) if (DeclarativeRecord.HasBinding(N)) return Completion.ThrowCompletion(new String($"redeclaration of immutable binding {N}")); // 3. Return ! DclRec.CreateImmutableBinding(N, S). - return Completion.NormalCompletion(MUST(DeclarativeRecord.CreateImmutableBinding(N, S))); + return MUST(DeclarativeRecord.CreateImmutableBinding(N, S)); } // 9.1.1.4.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-global-environment-records-initializebinding-n-v @@ -81,7 +81,7 @@ override public Completion InitializeBinding(string N, Value V) if (DeclarativeRecord.HasBinding(N)) { // a. Return ! DclRec.InitializeBinding(N, V). - return Completion.NormalCompletion(MUST(DeclarativeRecord.InitializeBinding(N, V))); + return MUST(DeclarativeRecord.InitializeBinding(N, V)); } // 3. Assert: If the binding exists, it must be in the Object Environment Record. @@ -135,7 +135,7 @@ public override bool HasThisBinding() public override Completion GetThisBinding() { // 1. Return envRec.[[GlobalThisValue]]. - return Completion.NormalCompletion(GlobalThisValue); + return GlobalThisValue; } // 9.1.1.4.12 HasVarDeclaration ( N ), https://tc39.es/ecma262/#sec-hasvardeclaration @@ -167,11 +167,11 @@ public Completion HasRestrictedGlobalProperty(string N) if (existingProp.IsAbruptCompletion()) return existingProp; // 4. If existingProp is undefined, return false. - if (existingProp.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(false)); + if (existingProp.Value.IsUndefined()) return new Boolean(false); // FIXME: 5. If existingProp.[[Configurable]] is true, return false. // 6. Return true. - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // 9.1.1.4.15 CanDeclareGlobalVar ( N ), https://tc39.es/ecma262/#sec-candeclareglobalvar @@ -187,10 +187,10 @@ public Completion CanDeclareGlobalVar(string N) // 4. If hasProperty is true, return true. var asBoolean = hasProperty.Value.AsBoolean(); - if (asBoolean.Value) return Completion.NormalCompletion(new Boolean(true)); + if (asBoolean.Value) return new Boolean(true); // FIXME: 5. Return ? IsExtensible(globalObject). - return Completion.NormalCompletion(new Boolean(true)); + return new Boolean(true); } // 9.1.1.4.16 CanDeclareGlobalFunction ( N ), https://tc39.es/ecma262/#sec-candeclareglobalfunction @@ -205,12 +205,12 @@ public Completion CanDeclareGlobalFunction(string N) if (existingProp.IsAbruptCompletion()) return existingProp; // 4. If existingProp is undefined, FIXME: return ? IsExtensible(globalObject). - if (existingProp.Value.IsUndefined()) return Completion.NormalCompletion(new Boolean(true)); + if (existingProp.Value.IsUndefined()) return new Boolean(true); // FIXME: 5. If existingProp.[[Configurable]] is true, return true. // FIXME: 6. If IsDataDescriptor(existingProp) is true and existingProp has attribute values { [[Writable]]: true, [[Enumerable]]: true }, return true. // 7. Return false. - return Completion.NormalCompletion(new Boolean(false)); + return new Boolean(false); } // 9.1.1.4.17 CreateGlobalVarBinding ( N, D ), https://tc39.es/ecma262/#sec-createglobalvarbinding @@ -246,7 +246,7 @@ public Completion CreateGlobalVarBinding(string N, bool D) } // 7. Return unused. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.4.18 CreateGlobalFunctionBinding ( N, V, D ), https://tc39.es/ecma262/#sec-createglobalfunctionbinding @@ -291,7 +291,7 @@ public Completion CreateGlobalFunctionBinding(string N, Value V, bool D) } // 9. Return unused. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public ObjectEnvironment ObjectRecord { get; } diff --git a/JSS.Lib/Execution/ObjectEnvironment.cs b/JSS.Lib/Execution/ObjectEnvironment.cs index 55153b1..d54b5f2 100644 --- a/JSS.Lib/Execution/ObjectEnvironment.cs +++ b/JSS.Lib/Execution/ObjectEnvironment.cs @@ -54,7 +54,7 @@ override public Completion CreateMutableBinding(string N, bool D) if (defineResult.IsAbruptCompletion()) return defineResult; // 3. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.2.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-object-environment-records-initializebinding-n-v @@ -65,7 +65,7 @@ override public Completion InitializeBinding(string N, Value V) if (setResult.IsAbruptCompletion()) return setResult; // 2. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.2.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-object-environment-records-getbindingvalue-n-s @@ -89,7 +89,7 @@ override public Completion SetMutableBinding(string N, Value V, bool S) if (setResult.IsAbruptCompletion()) return setResult; // 5. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 9.1.1.2.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-getbindingvalue-n-s @@ -111,7 +111,7 @@ override public Completion GetBindingValue(string N, bool S) } else { - return Completion.NormalCompletion(Undefined.The); + return Undefined.The; } } diff --git a/JSS.Lib/Execution/Realm.cs b/JSS.Lib/Execution/Realm.cs index 23f121c..b42fb08 100644 --- a/JSS.Lib/Execution/Realm.cs +++ b/JSS.Lib/Execution/Realm.cs @@ -82,7 +82,7 @@ private Completion SetDefaultGlobalBindings() } // 3. Return global. - return Completion.NormalCompletion(GlobalObject); + return GlobalObject; } private Dictionary CreateGlobalProperties() @@ -140,7 +140,7 @@ static public Completion InitializeHostDefinedRealm(out VM vm) // FIXME: 11. Create any host-defined global object properties on globalObj. // 12. Return UNUSED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } public Agent Agent { get; } diff --git a/JSS.Lib/Execution/Script.cs b/JSS.Lib/Execution/Script.cs index edab0d3..9130b07 100644 --- a/JSS.Lib/Execution/Script.cs +++ b/JSS.Lib/Execution/Script.cs @@ -59,7 +59,7 @@ public Completion ScriptEvaluation() if (result.IsNormalCompletion() && result.IsValueEmpty()) { // i. Set result to NormalCompletion(undefined). - result = Completion.NormalCompletion(Undefined.The); + result = Undefined.The; } // 14. (FIXME: Suspend) scriptContext and remove it from the execution context stack. @@ -245,7 +245,7 @@ private Completion GlobalDeclarationInstantiation(GlobalEnvironment env) } // 18. Return UNUSUED. - return Completion.NormalCompletion(Empty.The); + return Empty.The; } // 8.2.4 Static Semantics: LexicallyDeclaredNames, https://tc39.es/ecma262/#sec-static-semantics-lexicallydeclarednames diff --git a/JSS.Lib/Runtime/Object.constructor.cs b/JSS.Lib/Runtime/Object.constructor.cs index 23c07be..3047062 100644 --- a/JSS.Lib/Runtime/Object.constructor.cs +++ b/JSS.Lib/Runtime/Object.constructor.cs @@ -31,11 +31,11 @@ public Completion Construct(VM vm, List argumentList) var value = argumentList[0]; if (value.IsUndefined() || value.IsNull()) { - return Completion.NormalCompletion(new Object(ObjectPrototype.The)); + return new Object(ObjectPrototype.The); } // 3. Return ! ToObject(value). - return Completion.NormalCompletion(MUST(value.ToObject())); + return MUST(value.ToObject()); } static public ObjectConstructor The