Skip to content

Commit dd9b5d9

Browse files
Add isRecordAndTupleEnabled-method for hiding functionality.
1 parent 052710d commit dd9b5d9

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSContext.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,13 @@ protected JSContext(Evaluator evaluator, JSContextOptions contextOptions, JavaSc
574574
this.webAssemblyTableFactory = builder.create(JSWebAssemblyTable.INSTANCE);
575575
this.webAssemblyGlobalFactory = builder.create(JSWebAssemblyGlobal.INSTANCE);
576576

577-
this.recordFactory = builder.create(JSRecord.INSTANCE);
578-
this.tupleFactory = builder.create(JSTuple.INSTANCE);
577+
if (isRecordAndTupleEnabled()) {
578+
this.recordFactory = builder.create(JSRecord.INSTANCE);
579+
this.tupleFactory = builder.create(JSTuple.INSTANCE);
580+
} else {
581+
this.recordFactory = null;
582+
this.tupleFactory = null;
583+
}
579584

580585
this.factoryCount = builder.finish();
581586

@@ -1732,4 +1737,9 @@ public boolean isOptionTopLevelAwait() {
17321737
public boolean isWaitAsyncEnabled() {
17331738
return getEcmaScriptVersion() >= JSConfig.ECMAScript2022;
17341739
}
1740+
1741+
public boolean isRecordAndTupleEnabled() {
1742+
// TODO: Associate with the correct ECMAScript Version
1743+
return getEcmaScriptVersion() >= JSConfig.ECMAScript2022;
1744+
}
17351745
}

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSRealm.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,7 @@ public JSRealm(JSContext context, TruffleLanguage.Env env) {
763763

764764
this.foreignIterablePrototype = createForeignIterablePrototype();
765765

766-
// TODO: Associate with the correct ECMAScript Version
767-
boolean es13 = context.getContextOptions().getEcmaScriptVersion() >= JSConfig.ECMAScript2022;
768-
if (es13) {
766+
if (context.isRecordAndTupleEnabled()) {
769767
ctor = JSRecord.createConstructor(this);
770768
this.recordConstructor = ctor.getFunctionObject();
771769
this.recordPrototype = ctor.getPrototype();
@@ -1436,7 +1434,8 @@ public void setupGlobals() {
14361434
if (context.getContextOptions().isProfileTime()) {
14371435
System.out.println("SetupGlobals: " + (System.nanoTime() - time) / 1000000);
14381436
}
1439-
if (context.getEcmaScriptVersion() >= 13) { // TODO: Associate with the correct ECMAScript Version
1437+
if (context.isRecordAndTupleEnabled()) {
1438+
putGlobalProperty(JSRecord.CLASS_NAME, getRecordConstructor());
14401439
putGlobalProperty(JSTuple.CLASS_NAME, getTupleConstructor());
14411440
}
14421441
}

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/builtins/JSRecord.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import com.oracle.truffle.js.runtime.JSRuntime;
5050
import com.oracle.truffle.js.runtime.Record;
5151
import com.oracle.truffle.js.runtime.Symbol;
52-
import com.oracle.truffle.js.runtime.objects.JSDynamicObject;
5352
import com.oracle.truffle.js.runtime.objects.JSObject;
5453
import com.oracle.truffle.js.runtime.objects.JSObjectUtil;
5554
import com.oracle.truffle.js.runtime.objects.JSShape;

0 commit comments

Comments
 (0)