Skip to content
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

Small test262 fixes #249

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions JS-Interpreters/ecmaref5/section 10/section_10.3.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -60,7 +60,7 @@ function IdentifierResolution(Identifier, runningExecCtx) {

/* 2. If the syntactic production that is being evaluated is contained in a strict mode code,
then let strict be true, else let strict be false. */
if (isContainedInStrictCode(runningExecCtx)) strict := true; else strict := false;
strict := isContainedInStrictCode(runningExecCtx);
/* 3. Return the result of calling GetIdentifierReference function passing env, Identifier, and strict as arguments.
The result of evaluating an identifier is always a value of type Reference with its referenced name component
equal to the Identifier String. */
Expand Down
6 changes: 3 additions & 3 deletions JS-Interpreters/ecmaref5/section 8/section_8.7.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down
4 changes: 2 additions & 2 deletions JS-Interpreters/ecmaref6/esl_interpreter.esl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function JS_Interpreter_Expr(e, scope) {
/* 1. If the function code for this ArrowFunction is strict mode code
(10.2.1), */
/* let strict be true. Otherwise let strict be false */
if (isStrictModeCode(ConciseBody, scope)) strict := true; else strict := false;
strict := isStrictModeCode(ConciseBody, scope);
/* 2. Let scope be the LexicalEnvironment of the running execution context. */
lexEnv := scope.LexicalEnvironment;
/* 3. Let parameters be CoveredFormalsList of ArrowParameters. */
Expand Down Expand Up @@ -969,7 +969,7 @@ function JS_Interpreter_FunctionDeclaration(FunctionDeclaration, scope) {

/* 1. If the function code for FunctionDeclaration is strict mode code, let strict be true.
Otherwise let strict be false. */
if (isStrictModeCode(FunctionBody, scope)) strict := true; else strict := false;
strict := isStrictModeCode(FunctionBody, scope);
/* 2. Let name br StringValue of BindingIdentifier */
name := Identifier.name;
lex := getLexicalEnvironment(scope);
Expand Down
10 changes: 5 additions & 5 deletions JS-Interpreters/ecmaref6/section 10/section_10.2.esl
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* 10.2 Strict Code */

function isStrict(code) {
return (code != 'undefined &&& code.strict == true);
return (code != 'undefined &&& code.strict);
}

function isStrictModeCode(code, execCtx) {
return (code != 'undefined &&& code.strict == true) ||| isContainedInStrictCode(execCtx);
return (code != 'undefined &&& code.strict) ||| isContainedInStrictCode(execCtx);
}
8 changes: 4 additions & 4 deletions JS-Interpreters/ecmaref6/section 19/section_19.2.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -434,7 +434,7 @@ function isParsableAsFunctionBody(bodyObj) {
}

function isBuiltInFunctionBodyStrictModeCode(bodyObj) {
return ("strict" in_obj bodyObj) &&& (bodyObj.strict);
return ("strict" in_obj bodyObj) &&& bodyObj.strict;
}

function anyStrictModeRestrictionApplicable(bodyObj) {
Expand Down
10 changes: 5 additions & 5 deletions JS-Interpreters/ecmaref6/section 20/section_20.1.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -189,13 +189,13 @@ function initNumberConstructor(prototype, global, strict) {
createBuiltInPropertyWithFullDescriptor(NumberConstructor, "NEGATIVE_INFINITY", (-Infinity), false, false, false);

/* 20.1.2.12 Number.parseFloat ( string ) */
parseFloatObject := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", global, strict, null);
parseFloatObject := |Intrinsics|["parseFloat"];
createBuiltInProperty(NumberConstructor, "parseFloat", parseFloatObject);
descriptor := newDataPropertyDescriptorFull("parseFloat", false, false, true);
setJSProperty(parseFloatObject, "name", descriptor);

/* 20.1.2.13 Number.parseInt ( string, radix ) */
parseIntObject := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", global, strict, null);
parseIntObject := |Intrinsics|["parseInt"];
createBuiltInProperty(NumberConstructor, "parseInt", parseIntObject);
descriptor := newDataPropertyDescriptorFull("parseInt", false, false, true);
setJSProperty(parseIntObject, "name", descriptor);
Expand Down
24 changes: 13 additions & 11 deletions JS-Interpreters/ecmaref6/section 6/section_6.1.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -262,6 +262,16 @@ function initIntrinsics(intrinsics, realm, strict) {
/* Math */
intrinsics.Math := initMathObject(realm, objProto, strict);

/* parseFloat */
/* IMPORTANT: This needs to be here before `initNumberObject`! */
parseFloat := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", realm, strict, null);
intrinsics.parseFloat := parseFloat;

/* parseInt */
/* IMPORTANT: This needs to be here before `initNumberObject`! */
parseInt := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", realm, strict, null);
intrinsics.parseInt := parseInt;

/* Number */
NumberObject := initNumberObject(realm, objProto, strict);
intrinsics.Number := NumberObject;
Expand All @@ -272,14 +282,6 @@ function initIntrinsics(intrinsics, realm, strict) {
intrinsics.ObjProto_toString := getJSProperty(objProto, "toString").Value;
intrinsics.ObjectIteratorPrototype := initObjectIteratorPrototype(realm, objProto, strict);

/* parseFloat */
parseFloat := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", realm, strict, null);
intrinsics.parseFloat := parseFloat;

/* parseInt */
parseInt := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", realm, strict, null);
intrinsics.parseInt := parseInt;

/* Promise */
PromiseObject := initPromiseObject(realm, funcProto, objProto, strict);
intrinsics.Promise := PromiseObject;
Expand Down
6 changes: 3 additions & 3 deletions JS-Interpreters/ecmaref6/section 6/section_6.2.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down
11 changes: 4 additions & 7 deletions JS-Interpreters/ecmaref6/section 8/section_8.3.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand All @@ -25,10 +25,7 @@ function IdentifierResolution(Identifier, runningExecCtx) {
env := getLexicalEnvironment(runningExecCtx);
/* 2. If the syntactic production that is being evaluated is contained in a strict mode code,
then let strict be true, else let strict be false. */
if (isContainedInStrictCode(runningExecCtx))
strict := true;
else
strict := false;
strict := isContainedInStrictCode(runningExecCtx);
/* 3. Return the result of calling GetIdentifierReference function passing env, Identifier, and strict as arguments.
The result of evaluating an identifier is always a value of type Reference with its referenced name component
equal to the Identifier String. */
Expand Down
10 changes: 5 additions & 5 deletions JS-Interpreters/ecmaref6/section 9/section_9.2.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -143,7 +143,7 @@ function OrdinaryCallBindThis (F, calleeContext, thisArgument) {
/* 4. Let localEnv be the LexicalEnvironment of calleeContext. */
localEnv := calleeContext.LexicalEnvironment;
/* 5. If thisMode is strict, let thisValue be thisArgument. */
if (thisMode == "strict") {
if (thisMode == "Strict") {
thisValue := thisArgument;
/* 6. Else */
} else {
Expand Down Expand Up @@ -367,7 +367,7 @@ function FunctionInitialize(F, kind, ParameterList, Body, Scope) {
/* 10. Else if Strict is true, */
else if (Strict == true)
/* set the [[ThisMode]] internal slot of F to strict */
F.ThisMode := "strict";
F.ThisMode := "Strict";
/* 11. Else set the [[ThisMode]] internal slot of F to global. */
else
F.ThisMode := "global";
Expand Down
10 changes: 5 additions & 5 deletions JS-Interpreters/ecmaref6/section 9/section_9.3.esl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Copyright (C) 2022-2025 formalsec programmers
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -62,11 +62,11 @@ function BuiltInCall(externalScope, ref, F, V, NewTarget, argumentsList) {
if (("ECMAScriptCode" in_obj F) &&& (typeof F.ECMAScriptCode == "string")
&&& ((F.ECMAScriptCode == "FunctionPrototypeCall") ||| (F.ECMAScriptCode == "TypedArraySubConstructor"))) {
args := completeArgs(argumentsList, F);
result := {F.ECMAScriptCode}(externalScope, V, NewTarget, F.strict, args) catch BuiltInCall_Handler;
result := {F.ECMAScriptCode}(externalScope, V, NewTarget, F.Strict, args) catch BuiltInCall_Handler;
}
else if (("ECMAScriptCode" in_obj F) &&& ((typeof F.ECMAScriptCode == "string") ||| (typeof F.ECMAScriptCode == "curry"))) {
args := completeArgs(argumentsList, F);
result := {F.ECMAScriptCode}(F.Environment, V, NewTarget, F.strict, args) catch BuiltInCall_Handler;
result := {F.ECMAScriptCode}(F.Environment, V, NewTarget, F.Strict, args) catch BuiltInCall_Handler;
}

/* 10. Remove calleeContext from the execution context stack and restore callerContext as the running execution context. */
Expand Down
2 changes: 1 addition & 1 deletion bench/test262