From f776e58306e77da20c28edd00c62ef40723f9eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Murias?= Date: Mon, 10 Dec 2018 13:20:11 +0100 Subject: [PATCH] [js] Migrate _STable to $$STable --- src/vm/js/Operations.nqp | 12 +- src/vm/js/nqp-runtime/BOOT.js | 4 +- src/vm/js/nqp-runtime/bignum.js | 4 +- src/vm/js/nqp-runtime/bootstrap.js | 58 ++++---- src/vm/js/nqp-runtime/container-specs.js | 16 +-- src/vm/js/nqp-runtime/core.js | 126 +++++++++--------- src/vm/js/nqp-runtime/ctx.js | 6 +- src/vm/js/nqp-runtime/deserialization.js | 14 +- src/vm/js/nqp-runtime/hll.js | 26 ++-- src/vm/js/nqp-runtime/io.js | 6 +- src/vm/js/nqp-runtime/multicache.js | 20 +-- src/vm/js/nqp-runtime/nativecall.js | 14 +- src/vm/js/nqp-runtime/nfa.js | 2 +- src/vm/js/nqp-runtime/nqp-exception.js | 2 +- src/vm/js/nqp-runtime/nqp-str.js | 4 +- src/vm/js/nqp-runtime/refs.js | 28 ++-- src/vm/js/nqp-runtime/reprs.js | 70 +++++----- src/vm/js/nqp-runtime/runtime.js | 16 +-- .../js/nqp-runtime/serialization-context.js | 6 +- src/vm/js/nqp-runtime/serialization.js | 24 ++-- src/vm/js/nqp-runtime/sixmodel.js | 26 ++-- 21 files changed, 242 insertions(+), 242 deletions(-) diff --git a/src/vm/js/Operations.nqp b/src/vm/js/Operations.nqp index 3c87a91cfa..66b5995ba6 100644 --- a/src/vm/js/Operations.nqp +++ b/src/vm/js/Operations.nqp @@ -1583,10 +1583,10 @@ class QAST::OperationsJS { %ops := %ops; - add_simple_op('how', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj._STable.HOW"}, :decont(0)); - add_simple_op('how_nd', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj._STable.HOW"}); - add_simple_op('who', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj._STable.WHO"}, :decont(0)); - add_simple_op('setwho', $T_OBJ, [$T_OBJ, $T_OBJ], sub ($obj, $who) {"($obj._STable.WHO = $who, $obj)"}, :side_effects, :decont(0)); + add_simple_op('how', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj.$$STable.HOW"}, :decont(0)); + add_simple_op('how_nd', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj.$$STable.HOW"}); + add_simple_op('who', $T_OBJ, [$T_OBJ], sub ($obj) {"$obj.$$STable.WHO"}, :decont(0)); + add_simple_op('setwho', $T_OBJ, [$T_OBJ, $T_OBJ], sub ($obj, $who) {"($obj.$$STable.WHO = $who, $obj)"}, :side_effects, :decont(0)); # TODO decont second argument add_simple_op('rebless', $T_OBJ, [$T_OBJ, $T_OBJ], :side_effects, :decont(0, 1)); @@ -1603,8 +1603,8 @@ class QAST::OperationsJS { # HACK # TODO think what we should return on 1.WHAT and "foo".WHAT - add_simple_op('what', $T_OBJ, [$T_OBJ], sub ($obj) {"($obj._STable ? $obj._STable.WHAT : nqp.Null)"}, :decont(0)); - add_simple_op('what_nd', $T_OBJ, [$T_OBJ], sub ($obj) {"($obj._STable ? $obj._STable.WHAT : nqp.Null)"}); + add_simple_op('what', $T_OBJ, [$T_OBJ], sub ($obj) {"($obj.$$STable ? $obj.$$STable.WHAT : nqp.Null)"}, :decont(0)); + add_simple_op('what_nd', $T_OBJ, [$T_OBJ], sub ($obj) {"($obj.$$STable ? $obj.$$STable.WHAT : nqp.Null)"}); add_simple_op('knowhowattr', $T_OBJ, [], sub () {"nqp.knowhowattr"}); add_simple_op('knowhow', $T_OBJ, [], sub () {"nqp.knowhow"}); diff --git a/src/vm/js/nqp-runtime/BOOT.js b/src/vm/js/nqp-runtime/BOOT.js index 2f6ac92119..6637594d47 100644 --- a/src/vm/js/nqp-runtime/BOOT.js +++ b/src/vm/js/nqp-runtime/BOOT.js @@ -1,9 +1,9 @@ /* exports.Array is actually set in bootstrap.js */ module.exports.createArray = function(array) { - return exports.Array._STable.REPR.allocateFromArray(exports.Array._STable, array); + return exports.Array.$$STable.REPR.allocateFromArray(exports.Array.$$STable, array); }; module.exports.createIntArray = function(array) { - return exports.IntArray._STable.REPR.allocateFromArray(exports.IntArray._STable, array); + return exports.IntArray.$$STable.REPR.allocateFromArray(exports.IntArray.$$STable, array); }; diff --git a/src/vm/js/nqp-runtime/bignum.js b/src/vm/js/nqp-runtime/bignum.js index f100466fc5..c40d25115c 100644 --- a/src/vm/js/nqp-runtime/bignum.js +++ b/src/vm/js/nqp-runtime/bignum.js @@ -22,13 +22,13 @@ function intishBool(b) { } function makeNum(type, num) { - const instance = type._STable.REPR.allocate(type._STable); + const instance = type.$$STable.REPR.allocate(type.$$STable); instance.$$setNum(num); return instance; } function makeBI(type, num) { - const instance = type._STable.REPR.allocate(type._STable); + const instance = type.$$STable.REPR.allocate(type.$$STable); instance.$$setBignum(num); return instance; } diff --git a/src/vm/js/nqp-runtime/bootstrap.js b/src/vm/js/nqp-runtime/bootstrap.js index 56a1148a35..90ecccb9fb 100644 --- a/src/vm/js/nqp-runtime/bootstrap.js +++ b/src/vm/js/nqp-runtime/bootstrap.js @@ -26,14 +26,14 @@ globalContext.initialize(context => context.scs['__6MODEL_CORE__'] = core); function addToScWithSt(obj) { core.rootObjects.push(obj); - core.rootSTables.push(obj._STable); + core.rootSTables.push(obj.$$STable); obj._SC = core; - obj._STable._SC = core; + obj.$$STable._SC = core; } /* Creates and installs the KnowHOWAttribute type. */ function createKnowHOWAttribute() { - const metaObj = KnowHowHOW._STable.REPR.allocate(KnowHowHOW._STable); + const metaObj = KnowHowHOW.$$STable.REPR.allocate(KnowHowHOW.$$STable); const r = new reprs.KnowHOWAttribute(); const typeObj = r.typeObjectFor(metaObj); @@ -43,19 +43,19 @@ function createKnowHOWAttribute() { return new NQPStr(self.__name); }; methods['new'] = function(ctx, _NAMED, self) { - const attr = r.allocate(self._STable); + const attr = r.allocate(self.$$STable); attr.__name = _NAMED.name.$$getStr(); attr.__type = _NAMED.type; attr.__boxTarget = _NAMED.box_target ? _NAMED.box_target.$$getInt() : 0; return attr; }; - typeObj._STable.methodCache = new Map(); - typeObj._STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; + typeObj.$$STable.methodCache = new Map(); + typeObj.$$STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; for (const method of Object.keys(methods)) { - typeObj._STable.ObjConstructor.prototype[method] = methods[method]; - typeObj._STable.methodCache.set(method, wrapMethod(method, methods[method])); + typeObj.$$STable.ObjConstructor.prototype[method] = methods[method]; + typeObj.$$STable.methodCache.set(method, wrapMethod(method, methods[method])); } return typeObj; @@ -74,12 +74,12 @@ KnowHowHOW.__name = 'KnowHOW'; addToScWithSt(KnowHowHOW); -KnowHOW._STable.HOW = KnowHowHOW; +KnowHOW.$$STable.HOW = KnowHowHOW; -KnowHOW._STable.methodCache = new Map(); -KnowHOW._STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; -KnowHowHOW._STable.methodCache = new Map(); -KnowHowHOW._STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; +KnowHOW.$$STable.methodCache = new Map(); +KnowHOW.$$STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; +KnowHowHOW.$$STable.methodCache = new Map(); +KnowHowHOW.$$STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; function wrapMethod(name, method) { const codeRef = new CodeRef(name, undefined); @@ -89,12 +89,12 @@ function wrapMethod(name, method) { function addKnowhowHowMethod(name, method) { /* TODO - think if setting the object cache would be better */ - KnowHowHOW._STable.ObjConstructor.prototype[name] = method; - KnowHOW._STable.ObjConstructor.prototype[name] = method; + KnowHowHOW.$$STable.ObjConstructor.prototype[name] = method; + KnowHOW.$$STable.ObjConstructor.prototype[name] = method; const wrapped = wrapMethod(name, method); - KnowHOW._STable.methodCache.set(name, wrapped); - KnowHowHOW._STable.methodCache.set(name, wrapped); + KnowHOW.$$STable.methodCache.set(name, wrapped); + KnowHowHOW.$$STable.methodCache.set(name, wrapped); } addKnowhowHowMethod('name', function(ctx, _NAMED, self) { @@ -111,7 +111,7 @@ addKnowhowHowMethod('methods', function(ctx, _NAMED, self) { addKnowhowHowMethod('new_type', function(ctx, _NAMED, self) { /* We first create a new HOW instance. */ - const HOW = self._STable.REPR.allocate(self._STable); + const HOW = self.$$STable.REPR.allocate(self.$$STable); /* See if we have a representation name; if not default to P6opaque. */ const reprName = (_NAMED && _NAMED.repr) ? _NAMED.repr.$$getStr() : 'P6opaque'; @@ -129,7 +129,7 @@ addKnowhowHowMethod('new_type', function(ctx, _NAMED, self) { } /* Set .WHO to an empty hash. */ - typeObject._STable.WHO = new Hash(); + typeObject.$$STable.WHO = new Hash(); return typeObject; }); @@ -144,12 +144,12 @@ addKnowhowHowMethod('add_method', function(ctx, _NAMED, self, type, name, code) addKnowhowHowMethod('compose', function(ctx, _NAMED, self, typeObject) { /* Set method cache */ - typeObject._STable.setMethodCache(self.__methods.content); - typeObject._STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; + typeObject.$$STable.setMethodCache(self.__methods.content); + typeObject.$$STable.modeFlags = constants.METHOD_CACHE_AUTHORITATIVE; /* Set type check cache. */ - typeObject._STable.typeCheckCache = [typeObject]; + typeObject.$$STable.typeCheckCache = [typeObject]; /* Use any attribute information to produce attribute protocol * data. The protocol consists of an array... */ @@ -188,7 +188,7 @@ addKnowhowHowMethod('compose', function(ctx, _NAMED, self, typeObject) { /* Compose the representation using it. */ - typeObject._STable.REPR.compose(typeObject._STable, reprInfoHash); + typeObject.$$STable.REPR.compose(typeObject.$$STable, reprInfoHash); return typeInfo; }); @@ -205,7 +205,7 @@ module.exports.knowhowattr = KnowHOWAttribute; addToScWithSt(KnowHOWAttribute); function bootType(typeName, reprName) { - const metaObj = KnowHowHOW._STable.REPR.allocate(KnowHowHOW._STable); + const metaObj = KnowHowHOW.$$STable.REPR.allocate(KnowHowHOW.$$STable); metaObj.__name = typeName; const typeObj = (new reprs[reprName]).typeObjectFor(metaObj); @@ -220,15 +220,15 @@ function bootType(typeName, reprName) { function bootArray(type) { const array = bootType('BOOTArray', 'VMArray'); - array._STable.REPR.type = Null; - array._STable.REPR.primType = type; - array._STable.REPR.setupSTableWhenComposed(array._STable); - array._STable.setboolspec(8, Null); + array.$$STable.REPR.type = Null; + array.$$STable.REPR.primType = type; + array.$$STable.REPR.setupSTableWhenComposed(array.$$STable); + array.$$STable.setboolspec(8, Null); return array; } BOOT.Array = bootArray(0); -BOOT.Array._STable.hllRole = 4; +BOOT.Array.$$STable.hllRole = 4; BOOT.IntArray = bootArray(1); BOOT.NumArray = bootArray(2); diff --git a/src/vm/js/nqp-runtime/container-specs.js b/src/vm/js/nqp-runtime/container-specs.js index 3d5bf02e1f..c71615418b 100644 --- a/src/vm/js/nqp-runtime/container-specs.js +++ b/src/vm/js/nqp-runtime/container-specs.js @@ -131,8 +131,8 @@ class NativeRef { // HACK - nqp still uses NQPInt instead of the thing in the hll config return new NQPInt(this.get()); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setInt(this.get()); return obj; } @@ -183,8 +183,8 @@ class NativeRef { // HACK - nqp still uses raw javascript numbers instead of the thing in the hll config return this.get(); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setNum(this.get()); return obj; } @@ -239,8 +239,8 @@ class NativeRef { // HACK - nqp still uses raw javascript strings instead of the thing in the hll config return this.get(); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setStr(this.get()); return obj; } @@ -296,8 +296,8 @@ class NativeRef { const type = hll.get('int_box'); - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setInt64(this.get()); return obj; } diff --git a/src/vm/js/nqp-runtime/core.js b/src/vm/js/nqp-runtime/core.js index 54c379dafa..128c070a7e 100644 --- a/src/vm/js/nqp-runtime/core.js +++ b/src/vm/js/nqp-runtime/core.js @@ -66,7 +66,7 @@ const nullStr = require('./null_s.js'); exports.CodeRef = CodeRef; op.isinvokable = function(obj) { - return (obj instanceof CodeRef || (obj._STable && obj._STable.invocationSpec) ? 1 : 0); + return (obj instanceof CodeRef || (obj.$$STable && obj.$$STable.invocationSpec) ? 1 : 0); }; op.escape = function(str) { @@ -180,7 +180,7 @@ op.radix = function(currentHLL, radix, str, zpos, flags) { }; op.setdebugtypename = function(type, debugName) { - type._STable.debugName = debugName; + type.$$STable.debugName = debugName; return type; }; @@ -201,8 +201,8 @@ const intToObj = exports.intToObj = function(currentHLL, i) { if (!type) { return new NQPInt(i); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setInt(i); return obj; } @@ -213,8 +213,8 @@ exports.int64ToObj = function(currentHLL, i) { if (!type) { throw new NQPException(`Can't box 64 bit integer: HLL doesn't have int_box`); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setInt64(i); return obj; } @@ -225,8 +225,8 @@ const numToObj = exports.numToObj = function(currentHLL, n) { if (!type) { return new NQPNum(n); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setNum(n); return obj; } @@ -237,8 +237,8 @@ const strToObj = exports.strToObj = function(currentHLL, s) { if (!type) { return new NQPStr(s); } else { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setStr(s); return obj; } @@ -294,11 +294,11 @@ exports.named = function(parts) { }; exports.op.ishash = function(obj) { - return obj instanceof Hash || (obj._STable && obj._STable.REPR instanceof reprs.VMHash) ? 1 : 0; + return obj instanceof Hash || (obj.$$STable && obj.$$STable.REPR instanceof reprs.VMHash) ? 1 : 0; }; op.create = function(obj) { - return obj._STable.REPR.allocate(obj._STable); + return obj.$$STable.REPR.allocate(obj.$$STable); }; op.bootarray = function() { @@ -315,13 +315,13 @@ op.defined = function(obj) { op.setinvokespec = function(obj, classHandle, attrName, invocationHandler) { - obj._STable.setinvokespec(classHandle, attrName, invocationHandler); + obj.$$STable.setinvokespec(classHandle, attrName, invocationHandler); return obj; }; // Stub op.setboolspec = function(obj, mode, method) { - obj._STable.setboolspec(mode, method); + obj.$$STable.setboolspec(mode, method); return obj; }; @@ -376,14 +376,14 @@ op.getcodeobj = function(codeRef) { }; op.settypecache = function(obj, cache) { - obj._STable.typeCheckCache = cache.array; - if (obj._STable._SC !== undefined) obj._STable.scwb(); + obj.$$STable.typeCheckCache = cache.array; + if (obj.$$STable._SC !== undefined) obj.$$STable.scwb(); return obj; }; op.settypecheckmode = function(obj, mode) { const TYPE_CHECK_CACHE_FLAG_MASK = 3; - obj._STable.modeFlags = mode | (obj.STable.modeFlags & TYPE_CHECK_CACHE_FLAG_MASK); + obj.$$STable.modeFlags = mode | (obj.STable.modeFlags & TYPE_CHECK_CACHE_FLAG_MASK); return obj; }; @@ -391,24 +391,24 @@ op.setmethcache = function(obj, cache) { if (!cache instanceof Hash) { console.log('we expect a hash here'); } - obj._STable.setMethodCache(cache.content); - if (obj._STable._SC !== undefined) obj._STable.scwb(); + obj.$$STable.setMethodCache(cache.content); + if (obj.$$STable._SC !== undefined) obj.$$STable.scwb(); return obj; }; op.setmethcacheauth = function(obj, isAuth) { if (isAuth) { - obj._STable.modeFlags |= constants.METHOD_CACHE_AUTHORITATIVE; + obj.$$STable.modeFlags |= constants.METHOD_CACHE_AUTHORITATIVE; } else { - obj._STable.modeFlags &= ~constants.METHOD_CACHE_AUTHORITATIVE; + obj.$$STable.modeFlags &= ~constants.METHOD_CACHE_AUTHORITATIVE; } - if (obj._STable._SC !== undefined) obj._STable.scwb(); + if (obj.$$STable._SC !== undefined) obj.$$STable.scwb(); return obj; }; op.reprname = function(obj) { - if (obj._STable) { - return obj._STable.REPR.name; + if (obj.$$STable) { + return obj.$$STable.REPR.name; } else if (obj instanceof Capture) { return 'MVMCallCapture'; } else if (obj instanceof NQPInt) { @@ -435,7 +435,7 @@ op.newtype = function(how, repr) { op.findmethod = /*async*/ function(ctx, obj, name) { const method = /*await*/ sixmodel.findMethod(ctx, obj, name); if (method === Null) { - throw new NQPException(`Cannot find method '${name}' on object of type '${obj._STable.debugName}'`); + throw new NQPException(`Cannot find method '${name}' on object of type '${obj.$$STable.debugName}'`); } return method; }; @@ -454,18 +454,18 @@ op.setcodename = function(code, name) { }; op.rebless = function(obj, newType) { - obj._STable.REPR.changeType(obj, newType); + obj.$$STable.REPR.changeType(obj, newType); if (obj._SC !== undefined) obj.$$scwb(); return obj; }; op.composetype = function(obj, reprinfo) { - obj._STable.REPR.compose(obj._STable, reprinfo); + obj.$$STable.REPR.compose(obj.$$STable, reprinfo); }; let whereCounter = 0; op.where = function(obj) { - if (obj._STable || obj instanceof CodeRef || obj === Null || obj instanceof NQPInt) { // HACK + if (obj.$$STable || obj instanceof CodeRef || obj === Null || obj instanceof NQPInt) { // HACK if (!obj._WHERE) { obj._WHERE = ++whereCounter; } @@ -492,8 +492,8 @@ op.curlexpad = function(get, set) { op.setcontspec = function(type, specType, conf) { if (containerSpecs[specType]) { - type._STable.containerSpec = new containerSpecs[specType](type._STable); - type._STable.containerSpec.configure(conf); + type.$$STable.containerSpec = new containerSpecs[specType](type.$$STable); + type.$$STable.containerSpec.configure(conf); } else { throw 'NYI cont spec: ' + specType; } @@ -528,8 +528,8 @@ op.isrwcont = function(cont) { }; op.box_n = function(n, type) { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setNum(n); return obj; }; @@ -539,8 +539,8 @@ op.unbox_n = function(obj) { }; op.box_s = function(value, type) { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setStr(value); return obj; }; @@ -551,8 +551,8 @@ op.unbox_s = function(obj) { op.box_i = function(i, type) { - const repr = type._STable.REPR; - const obj = repr.allocate(type._STable); + const repr = type.$$STable.REPR; + const obj = repr.allocate(type.$$STable); obj.$$setInt(i); return obj; }; @@ -656,7 +656,7 @@ function fromJS(HLL, obj, isReturnValue, isArgument) { return new NativeNumArg(obj); } else { const type = HLL.get('int_box'); - const boxed = type._STable.REPR.allocate(type._STable); + const boxed = type.$$STable.REPR.allocate(type.$$STable); boxed.$$setInt(obj); return boxed; } @@ -667,7 +667,7 @@ function fromJS(HLL, obj, isReturnValue, isArgument) { return new NativeStrArg(obj); } else { const type = HLL.get('str_box'); - const boxed = type._STable.REPR.allocate(type._STable); + const boxed = type.$$STable.REPR.allocate(type.$$STable); boxed.$$setStr(obj); return boxed; } @@ -677,7 +677,7 @@ function fromJS(HLL, obj, isReturnValue, isArgument) { return obj; } else { const type = HLL.get('js_box'); - const wrapped = type._STable.REPR.allocate(type._STable); + const wrapped = type.$$STable.REPR.allocate(type.$$STable); wrapped.$$jsObject = obj; return wrapped; } @@ -723,7 +723,7 @@ function toJSWithCtx(ctx, obj) { } return returnValueToJSWithCtx(ctx, obj.$$apply(converted)); }; - } else if (obj._STable === BOOT.StrArray._STable) { + } else if (obj.$$STable === BOOT.StrArray.$$STable) { return obj.array; } else { throw new NQPException(`Can't pass object to js`); @@ -971,8 +971,8 @@ class FakePerl6HOW extends NQPObject { } } -FakePerl6.prototype._STable = {}; -FakePerl6.prototype._STable.HOW = new FakePerl6HOW; +FakePerl6.prototype.$$STable = {}; +FakePerl6.prototype.$$STable.HOW = new FakePerl6HOW; const fakePerl6 = new FakePerl6(); @@ -1055,15 +1055,15 @@ op.setpayload = function(exception, payload) { }; op.isnum = function(value) { - return (value instanceof NQPNum || (value._STable && value._STable.REPR instanceof reprs.P6int)) ? 1 : 0; + return (value instanceof NQPNum || (value.$$STable && value.$$STable.REPR instanceof reprs.P6int)) ? 1 : 0; }; op.isint = function(value) { - return (value instanceof NQPInt || (value._STable && value._STable.REPR instanceof reprs.P6int)) ? 1 : 0; + return (value instanceof NQPInt || (value.$$STable && value.$$STable.REPR instanceof reprs.P6int)) ? 1 : 0; }; op.isstr = function(value) { - return (value instanceof NQPStr || (value._STable && value._STable.REPR instanceof reprs.P6int)) ? 1 : 0; + return (value instanceof NQPStr || (value.$$STable && value.$$STable.REPR instanceof reprs.P6int)) ? 1 : 0; }; function renameEncoding(encoding) { @@ -1079,7 +1079,7 @@ exports.isKnownEncoding = isKnownEncoding; function byteSize(buf) { - const bits = buf._STable.REPR.type._STable.REPR.bits; + const bits = buf.$$STable.REPR.type.$$STable.REPR.bits; if (bits % 8) { throw 'only buffer sizes that are a multiple of 8 are supported'; @@ -1092,7 +1092,7 @@ exports.byteSize = byteSize; function writeBuffer(highLevel, lowLevel) { const elementSize = byteSize(highLevel); - const isUnsigned = highLevel._STable.REPR.type._STable.REPR.isUnsigned; + const isUnsigned = highLevel.$$STable.REPR.type.$$STable.REPR.isUnsigned; let offset = 0; for (let i = 0; i < lowLevel.length / elementSize; i++) { @@ -1154,7 +1154,7 @@ op.encoderep = function(str, encoding, replacement, output) { function toRawBuffer(buf) { const elementSize = byteSize(buf); - const isUnsigned = buf._STable.REPR.type._STable.REPR.isUnsigned; + const isUnsigned = buf.$$STable.REPR.type.$$STable.REPR.isUnsigned; const array = buf.array; const buffer = Buffer.allocUnsafe(array.length * elementSize); @@ -1250,7 +1250,7 @@ op.objprimspec = function(obj) { } else if (obj instanceof NQPStr) { return 3; } else { - return (obj._STable && obj._STable.REPR.boxedPrimitive ? obj._STable.REPR.boxedPrimitive() : 0); + return (obj.$$STable && obj.$$STable.REPR.boxedPrimitive ? obj.$$STable.REPR.boxedPrimitive() : 0); } } else { throw new NQPException(`objprimspec can't handle things of type: ${typeof obj}`); @@ -1258,16 +1258,16 @@ op.objprimspec = function(obj) { }; op.objprimbits = function(type) { - return type._STable.REPR.bits; + return type.$$STable.REPR.bits; }; op.objprimunsigned = function(type) { - return type._STable.REPR.isUnsigned ? 1 : 0; + return type.$$STable.REPR.isUnsigned ? 1 : 0; }; /* Parametricity operations. */ op.setparameterizer = function(ctx, type, parameterizer) { - const st = type._STable; + const st = type.$$STable; /* Ensure that the type is not already parametric or parameterized. */ if (st.parameterizer) { throw new NQPException('This type is already parametric'); @@ -1288,7 +1288,7 @@ op.setparameterizer = function(ctx, type, parameterizer) { op.parameterizetype = /*async*/ function(ctx, type, params) { /* Ensure we have a parametric type. */ - const st = type._STable; + const st = type.$$STable; if (!st.parameterizer) { throw new NQPException('This type is not parametric'); } @@ -1302,7 +1302,7 @@ op.parameterizetype = /*async*/ function(ctx, type, params) { const result = /*await*/ st.parameterizer.$$call(ctx, {}, st.WHAT, params); - const newSTable = result._STable; + const newSTable = result.$$STable; newSTable.parametricType = type; newSTable.parameters = params; newSTable.modeFlags |= constants.PARAMETERIZED_TYPE; @@ -1357,7 +1357,7 @@ op.isnanorinf = function(n) { }; function typeparameters(ctx, type) { - const st = type._STable; + const st = type.$$STable; if (!st.parametricType) { throw new NQPException('This type is not parameterized'); } @@ -1372,7 +1372,7 @@ op.typeparameterat = function(ctx, type, idx) { }; op.typeparameterized = function(type) { - const st = type._STable; + const st = type.$$STable; return st.parametricType ? st.parametricType : Null; }; @@ -1534,12 +1534,12 @@ op.setdimensions = function(array, dimensions) { /* TODO HLL support */ op.newexception = function() { const exType = BOOT.Exception; - return exType._STable.REPR.allocate(exType._STable); + return exType.$$STable.REPR.allocate(exType.$$STable); }; op.throwextype = function(ctx, category) { const exType = BOOT.Exception; - const ex = exType._STable.REPR.allocate(exType._STable); + const ex = exType.$$STable.REPR.allocate(exType.$$STable); ex.$$category = category; return ctx.throw(ex); }; @@ -1662,8 +1662,8 @@ op.backtracestrings = function(currentHLL, exception) { }; op.hintfor = function(classHandle, attrName) { - if (!classHandle._STable.REPR.hintfor) return -1; - return classHandle._STable.REPR.hintfor(classHandle, attrName); + if (!classHandle.$$STable.REPR.hintfor) return -1; + return classHandle.$$STable.REPR.hintfor(classHandle, attrName); }; op.ctxcaller = function(ctx) { @@ -1844,7 +1844,7 @@ op.codes = function(str) { }; op.islist = function(list) { - return (list._STable && list._STable.REPR instanceof reprs.VMArray) ? 1 : 0; + return (list.$$STable && list.$$STable.REPR instanceof reprs.VMArray) ? 1 : 0; }; op.split = function(currentHLL, separator, string) { @@ -1884,7 +1884,7 @@ op.pow_n = function(base, exponent) { op.getlockcondvar = function(lock, type) { // STUB - return type._STable.REPR.allocate(type._STable); + return type.$$STable.REPR.allocate(type.$$STable); }; op.condwait = function(cv) { @@ -1980,7 +1980,7 @@ const getrusage = null; //require('qrusage'); op.getrusage = function() { throw 'getrusage is currently broken'; const usage = getrusage(); - const stable = BOOT.IntArray._STable; + const stable = BOOT.IntArray.$$STable; const utime_sec = Math.floor(usage.utime); const utime_usec = (usage.utime - Math.floor(usage.utime)) * 1000000; diff --git a/src/vm/js/nqp-runtime/ctx.js b/src/vm/js/nqp-runtime/ctx.js index 4e327833bb..10dda96451 100644 --- a/src/vm/js/nqp-runtime/ctx.js +++ b/src/vm/js/nqp-runtime/ctx.js @@ -89,14 +89,14 @@ class Ctx extends NQPObject { controlException(category) { const exType = BOOT.Exception; - const exception = exType._STable.REPR.allocate(exType._STable); + const exception = exType.$$STable.REPR.allocate(exType.$$STable); exception.$$category = category; return this.propagateControlException(exception); } controlExceptionLabeled(label, category) { const exType = BOOT.Exception; - const exception = exType._STable.REPR.allocate(exType._STable); + const exception = exType.$$STable.REPR.allocate(exType.$$STable); exception.$$category = category | LABELED; exception.$$payload = label; return this.propagateControlException(exception); @@ -259,7 +259,7 @@ class Ctx extends NQPObject { /*async*/ $$throwLexicalException(lookFrom, category, payload) { const exType = BOOT.Exception; - const exception = exType._STable.REPR.allocate(exType._STable); + const exception = exType.$$STable.REPR.allocate(exType.$$STable); exception.$$category = category; exception.$$payload = payload; diff --git a/src/vm/js/nqp-runtime/deserialization.js b/src/vm/js/nqp-runtime/deserialization.js index 12ba119395..6e616ace6d 100644 --- a/src/vm/js/nqp-runtime/deserialization.js +++ b/src/vm/js/nqp-runtime/deserialization.js @@ -432,7 +432,7 @@ class BinaryCursor { params[i] = this.variant(); } - const ptable = STable.parametricType._STable; + const ptable = STable.parametricType.$$STable; if (!ptable.parameterizerCache) { ptable.parameterizerCache = []; @@ -753,7 +753,7 @@ class BinaryCursor { continue; } if (objects[i].isConcrete) { - const repr = this.sc.rootObjects[i]._STable.REPR; + const repr = this.sc.rootObjects[i].$$STable.REPR; if (repr.deserializeFinish) { this.sc.currentObject = this.sc.rootObjects[i]; repr.deserializeFinish(this.sc.rootObjects[i], objects[i].data); @@ -784,7 +784,7 @@ class BinaryCursor { if (entry.type === 0) { const origObj = this.sc.deps[entry.origSC].rootObjects[entry.origIndex]; if (origObj._SC !== this.sc.deps[entry.origSC]) { - const backup = origObj.$$typeObject ? origObj._STable.createTypeObject() : origObj.$$clone(); + const backup = origObj.$$typeObject ? origObj.$$STable.createTypeObject() : origObj.$$clone(); conflicts.$$push(backup); conflicts.$$push(origObj); } @@ -799,7 +799,7 @@ class BinaryCursor { * repossession (perhaps due to mixing in to it), so put the * STable it should now have in place. */ - if (STableForObj !== origObj._STable) { + if (STableForObj !== origObj.$$STable) { Object.setPrototypeOf(origObj, STableForObj.ObjConstructor.prototype); } } @@ -851,20 +851,20 @@ class BinaryCursor { params.push(data.objRef(true)); } - const ptypeSTableIndex = this.sc.rootSTables.indexOf(ptype._STable); + const ptypeSTableIndex = this.sc.rootSTables.indexOf(ptype.$$STable); if (ptypeSTableIndex !== -1) { if (this.sc.rootSTables[ptypeSTableIndex].HOW === undefined) { STables[ptypeSTableIndex][1].stable(this.sc.rootSTables[ptypeSTableIndex]); } } - const matching = ptype._STable.lookupParametric(params); + const matching = ptype.$$STable.lookupParametric(params); /* Try to find a matching parameterization. */ if (matching) { this.sc.rootObjects[typeIdx] = matching; this.sc.rootObjects[typeIdx].$$avoid = 1; - this.sc.rootSTables[stIdx] = matching._STable; + this.sc.rootSTables[stIdx] = matching.$$STable; this.sc.rootSTables[stIdx].$$avoid = 1; } } diff --git a/src/vm/js/nqp-runtime/hll.js b/src/vm/js/nqp-runtime/hll.js index 52da5d42d9..34f374aedc 100644 --- a/src/vm/js/nqp-runtime/hll.js +++ b/src/vm/js/nqp-runtime/hll.js @@ -37,11 +37,11 @@ op.hllizefor = function(ctx, obj, language) { const languageHash = getHLL(language); const config = languageHash; let role; - if (obj !== null && obj._STable) { - if (obj._STable.hllOwner === languageHash) { + if (obj !== null && obj.$$STable) { + if (obj.$$STable.hllOwner === languageHash) { return obj; } - if (!(role = obj._STable.hllRole)) { + if (!(role = obj.$$STable.hllRole)) { return obj; } } @@ -63,20 +63,20 @@ op.hllizefor = function(ctx, obj, language) { // TODO handle already boxed ones } else if (obj instanceof NQPInt) { const foreignTypeInt = config.get('foreign_type_int'); - const repr = foreignTypeInt._STable.REPR; - const boxed = repr.allocate(foreignTypeInt._STable); + const repr = foreignTypeInt.$$STable.REPR; + const boxed = repr.allocate(foreignTypeInt.$$STable); boxed.$$setInt(obj.value); return boxed; } else if (obj instanceof NQPNum) { const foreignTypeNum = config.get('foreign_type_num'); - const repr = foreignTypeNum._STable.REPR; - const boxed = repr.allocate(foreignTypeNum._STable); + const repr = foreignTypeNum.$$STable.REPR; + const boxed = repr.allocate(foreignTypeNum.$$STable); boxed.$$setNum(obj.value); return boxed; } else if (obj instanceof NQPStr) { const foreignTypeStr = config.get('foreign_type_str'); - const repr = foreignTypeStr._STable.REPR; - const boxed = repr.allocate(foreignTypeStr._STable); + const repr = foreignTypeStr.$$STable.REPR; + const boxed = repr.allocate(foreignTypeStr.$$STable); boxed.$$setStr(obj.value); return boxed; } else if (obj === Null) { @@ -120,23 +120,23 @@ op.sethllconfig = function(language, configHash) { op.settypehll = function(type, language) { - type._STable.hllOwner = getHLL(language); + type.$$STable.hllOwner = getHLL(language); return type; }; op.settypehllrole = function(type, role) { - type._STable.hllRole = role; + type.$$STable.hllRole = role; return type; }; exports.slurpyArray = function(currentHLL, array) { const slurpyArray = currentHLL.get('slurpy_array'); - return slurpyArray._STable.REPR.allocateFromArray(slurpyArray._STable, array); + return slurpyArray.$$STable.REPR.allocateFromArray(slurpyArray.$$STable, array); }; exports.list = function(currentHLL, array) { const list = currentHLL.get('list'); - return list._STable.REPR.allocateFromArray(list._STable, array); + return list.$$STable.REPR.allocateFromArray(list.$$STable, array); }; op.hllbool = function(currentHLL, value) { diff --git a/src/vm/js/nqp-runtime/io.js b/src/vm/js/nqp-runtime/io.js index 4ca7165db4..514cbd75a2 100644 --- a/src/vm/js/nqp-runtime/io.js +++ b/src/vm/js/nqp-runtime/io.js @@ -227,7 +227,7 @@ class FileHandle extends IOHandle { } $$readfh(buf, bytes) { - const isUnsigned = buf._STable.REPR.type._STable.REPR.isUnsigned; + const isUnsigned = buf.$$STable.REPR.type.$$STable.REPR.isUnsigned; const buffer = Buffer.allocUnsafe(bytes); const read = fs.readSync(this.fd, buffer, 0, bytes, null); if (read === 0) { @@ -489,9 +489,9 @@ op.rename = function(oldPath, newPath) { function wrapBuffer(buffer, type) { const elementSize = core.byteSize(type); - const isUnsigned = type._STable.REPR.type._STable.REPR.isUnsigned; + const isUnsigned = type.$$STable.REPR.type.$$STable.REPR.isUnsigned; - const wrapped = type._STable.REPR.allocate(type._STable); + const wrapped = type.$$STable.REPR.allocate(type.$$STable); let offset = 0; for (let i = 0; i < buffer.length / elementSize; i++) { diff --git a/src/vm/js/nqp-runtime/multicache.js b/src/vm/js/nqp-runtime/multicache.js index 764228a78f..0b43b3887a 100644 --- a/src/vm/js/nqp-runtime/multicache.js +++ b/src/vm/js/nqp-runtime/multicache.js @@ -37,28 +37,28 @@ class MultiCache { if (obj instanceof NQPStr) { types[i] = 3; - } else if (obj._STable) { + } else if (obj.$$STable) { const deconted = /*await*/ obj.$$decont(ctx); /* TODO - think if having flags wouldn't be faster/cleaner then weird objects */ if (obj.$$isrwcont()) { - if (obj._STable.REPR instanceof reprs.NativeRef) { - types[i] = obj._STable; + if (obj.$$STable.REPR instanceof reprs.NativeRef) { + types[i] = obj.$$STable; } else { if (deconted.$$typeObject) { - if (deconted._STable.typeObjectCachedAsRW === undefined) { - deconted._STable.typeObjectCachedAsRW = {}; + if (deconted.$$STable.typeObjectCachedAsRW === undefined) { + deconted.$$STable.typeObjectCachedAsRW = {}; } - types[i] = deconted._STable.typeObjectCachedAsRW; + types[i] = deconted.$$STable.typeObjectCachedAsRW; } else { - if (deconted._STable.cachedAsRW === undefined) { - deconted._STable.cachedAsRW = {}; + if (deconted.$$STable.cachedAsRW === undefined) { + deconted.$$STable.cachedAsRW = {}; } - types[i] = deconted._STable.cachedAsRW; + types[i] = deconted.$$STable.cachedAsRW; } } } else { - types[i] = deconted.$$typeObject ? deconted : deconted._STable; + types[i] = deconted.$$typeObject ? deconted : deconted.$$STable; } } else if (obj instanceof NativeIntArg) { types[i] = 1; diff --git a/src/vm/js/nqp-runtime/nativecall.js b/src/vm/js/nqp-runtime/nativecall.js index 338a539eee..9ab9987ab1 100644 --- a/src/vm/js/nqp-runtime/nativecall.js +++ b/src/vm/js/nqp-runtime/nativecall.js @@ -75,24 +75,24 @@ op.nativecall = function(returns, callObject, args) { if (ret === null) { return returns; } else { - const boxed = returns._STable.REPR.allocate(returns._STable); + const boxed = returns.$$STable.REPR.allocate(returns.$$STable); boxed.$$setStr(ret); return boxed; } } else if (callObject.$$ret === 'cpointer') { - const boxed = returns._STable.REPR.allocate(returns._STable); + const boxed = returns.$$STable.REPR.allocate(returns.$$STable); boxed.$$setPointer(ret); return boxed; } else if (callObject.$$ret in shortInts) { - const boxed = returns._STable.REPR.allocate(returns._STable); + const boxed = returns.$$STable.REPR.allocate(returns.$$STable); boxed.$$setInt(ret); return boxed; } else if (callObject.$$ret in longInts) { - const boxed = returns._STable.REPR.allocate(returns._STable); + const boxed = returns.$$STable.REPR.allocate(returns.$$STable); boxed.$$setBignum(JSBI.BigInt(ret)); return boxed; } else if (callObject.$$ret in floats) { - const boxed = returns._STable.REPR.allocate(returns._STable); + const boxed = returns.$$STable.REPR.allocate(returns.$$STable); boxed.$$setNum(ret); return boxed; } else { @@ -102,8 +102,8 @@ op.nativecall = function(returns, callObject, args) { }; op.nativecallsizeof = function(obj) { - if (obj._STable.REPR.nativeCallSize) { - return obj._STable.REPR.nativeCallSize(); + if (obj.$$STable.REPR.nativeCallSize) { + return obj.$$STable.REPR.nativeCallSize(); } else { throw new NQPException('can\'t do nativecallsizeof'); } diff --git a/src/vm/js/nqp-runtime/nfa.js b/src/vm/js/nqp-runtime/nfa.js index 2234c9cfc0..5cfde5c061 100644 --- a/src/vm/js/nqp-runtime/nfa.js +++ b/src/vm/js/nqp-runtime/nfa.js @@ -43,7 +43,7 @@ function convertState(thing) { // TODO think about type conversions of the stuff inside the array op.nfafromstatelist = /*async*/ function(ctx, rawStates, type) { - const nfa = type._STable.REPR.allocate(type._STable); + const nfa = type.$$STable.REPR.allocate(type.$$STable); nfa.fates = rawStates.$$toArray()[0]; diff --git a/src/vm/js/nqp-runtime/nqp-exception.js b/src/vm/js/nqp-runtime/nqp-exception.js index 44961ed82c..6ea2685207 100644 --- a/src/vm/js/nqp-runtime/nqp-exception.js +++ b/src/vm/js/nqp-runtime/nqp-exception.js @@ -28,7 +28,7 @@ class NQPException extends Error { }; const proto = NQPException.prototype; /* Avoid gjslint warning */ -proto._STable = { +proto.$$STable = { HOW: { name: function(ctx, _NAMED, how, obj) { return 'BOOTException'; diff --git a/src/vm/js/nqp-runtime/nqp-str.js b/src/vm/js/nqp-runtime/nqp-str.js index 76fd16ba3e..ff9b6bd333 100644 --- a/src/vm/js/nqp-runtime/nqp-str.js +++ b/src/vm/js/nqp-runtime/nqp-str.js @@ -31,7 +31,7 @@ class NQPStr extends NQPObject { } }; -NQPStr.prototype._STable = new FakeStable('NQPStr'); -NQPStr.prototype._STable.hllRole = 1; +NQPStr.prototype.$$STable = new FakeStable('NQPStr'); +NQPStr.prototype.$$STable.hllRole = 1; module.exports = NQPStr; diff --git a/src/vm/js/nqp-runtime/refs.js b/src/vm/js/nqp-runtime/refs.js index de7109f046..704e826296 100644 --- a/src/vm/js/nqp-runtime/refs.js +++ b/src/vm/js/nqp-runtime/refs.js @@ -8,7 +8,7 @@ function attrRef_i(currentHLL, get, set) { if (refType === undefined) { throw 'No int attribute reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -20,7 +20,7 @@ function attrRef_n(currentHLL, get, set) { if (refType === undefined) { throw 'No num attribute reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -32,7 +32,7 @@ function attrRef_s(currentHLL, get, set) { if (refType === undefined) { throw 'No str attribute reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -44,7 +44,7 @@ function attrRef_i64(currentHLL, get, set) { if (refType === undefined) { throw 'No int64 attribute reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -75,7 +75,7 @@ op.multidimref_i = function(currentHLL, array, indexes) { if (refType === undefined) { throw new NQPException('No int multidim positional reference type registered for current HLL'); } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => array.$$atposnd_i(indexes); ref.set = value => array.$$bindposnd_i(indexes, value); @@ -87,7 +87,7 @@ op.multidimref_n = function(currentHLL, array, indexes) { if (refType === undefined) { throw new NQPException('No num multidim positional reference type registered for current HLL'); } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => array.$$atposnd_n(indexes); ref.set = value => array.$$bindposnd_n(indexes, value); @@ -99,7 +99,7 @@ op.multidimref_s = function(currentHLL, array, indexes) { if (refType === undefined) { throw new NQPException('No str multidim positional reference type registered for current HLL'); } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => array.$$atposnd_s(indexes); ref.set = value => array.$$bindposnd_s(indexes, value); @@ -111,7 +111,7 @@ helpers.lexRef_i = function(currentHLL, get, set) { if (refType === undefined) { throw 'No int lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -123,7 +123,7 @@ helpers.lexRef_i64 = function(currentHLL, get, set) { if (refType === undefined) { throw 'No int64 lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -137,7 +137,7 @@ helpers.lexRef_s = function(currentHLL, get, set) { if (refType === undefined) { throw 'No str lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -149,7 +149,7 @@ helpers.lexRef_n = function(currentHLL, get, set) { if (refType === undefined) { throw 'No num lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = get; ref.set = set; @@ -161,7 +161,7 @@ op.atposref_i = function(currentHLL, obj, index) { if (refType === undefined) { throw 'No int lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => obj.$$atpos_i(index); ref.set = value => obj.$$bindpos_i(index, value); @@ -173,7 +173,7 @@ op.atposref_n = function(currentHLL, obj, index) { if (refType === undefined) { throw 'No num lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => obj.$$atpos_n(index); ref.set = value => obj.$$bindpos_n(index, value); @@ -185,7 +185,7 @@ op.atposref_s = function(currentHLL, obj, index) { if (refType === undefined) { throw 'No str lexical reference type registered for current HLL'; } - const STable = refType._STable; + const STable = refType.$$STable; const ref = STable.REPR.allocate(STable); ref.get = () => obj.$$atpos_s(index); ref.set = value => obj.$$bindpos_s(index, value); diff --git a/src/vm/js/nqp-runtime/reprs.js b/src/vm/js/nqp-runtime/reprs.js index 6c48839cf7..2989d1f3f3 100644 --- a/src/vm/js/nqp-runtime/reprs.js +++ b/src/vm/js/nqp-runtime/reprs.js @@ -55,7 +55,7 @@ const bignum = require('./bignum.js'); function methodNotFoundError(ctx, obj, name) { const handler = ctx ? ctx.$$getHLL().get('method_not_found_error') : undefined; if (handler === undefined) { - throw new NQPException(`Cannot find method '${name}' on object of type ${obj._STable.debugName}`); + throw new NQPException(`Cannot find method '${name}' on object of type ${obj.$$STable.debugName}`); } else { return handler.$$call(ctx, null, obj, new NativeStrArg(name)); } @@ -69,10 +69,10 @@ function slotToAttr(slot) { class REPR { typeObjectFor(HOW) { const st = new sixmodel.STable(this, HOW); - this._STable = st; + this.$$STable = st; const obj = st.createTypeObject(); - this._STable.WHAT = obj; + this.$$STable.WHAT = obj; return obj; } @@ -110,7 +110,7 @@ class REPR { return /*async*/ function() { - const how = this._STable.HOW; + const how = this.$$STable.HOW; const method = /*await*/ how.find_method(null, null, how, this, new NativeStrArg(name)); @@ -127,7 +127,7 @@ class REPR { }; ObjConstructor.prototype = Object.create(new Proxy({}, handler)); - ObjConstructor.prototype._STable = STable; + ObjConstructor.prototype.$$STable = STable; ObjConstructor.prototype._SC = undefined; ObjConstructor.prototype._WHERE = undefined; @@ -200,7 +200,7 @@ class REPRWithAttributes extends REPR { classKeyIndex++; } } - code += `default: throw new NQPException('P6opaque: no such attribute \\'' + attrName + '\\' in type ' + classHandle._STable.debugName + ' when trying to ${actionDescription}')`; + code += `default: throw new NQPException('P6opaque: no such attribute \\'' + attrName + '\\' in type ' + classHandle.$$STable.debugName + ' when trying to ${actionDescription}')`; code += '}\n}\n'; STable.compileAccessor(name, code, setup); } @@ -356,7 +356,7 @@ class P6opaque extends REPRWithAttributes { } serialize(cursor, obj) { - const flattened = obj._STable.REPR.flattenedSTables; + const flattened = obj.$$STable.REPR.flattenedSTables; if (!flattened) { throw 'Representation must be composed before it can be serialized'; } @@ -373,16 +373,16 @@ class P6opaque extends REPRWithAttributes { } changeType(obj, newType) { - if (!(newType._STable.REPR instanceof P6opaque)) { + if (!(newType.$$STable.REPR instanceof P6opaque)) { throw new NQPException( - `New type for ${obj._STable.debugName} must have a matching representation (P6opaque vs ${newType._STable.REPR.name})"` + `New type for ${obj.$$STable.debugName} must have a matching representation (P6opaque vs ${newType.$$STable.REPR.name})"` ); } - const newREPR = newType._STable.REPR; + const newREPR = newType.$$STable.REPR; const newMapping = newREPR.nameToIndexMapping; - const currentMapping = obj._STable.REPR.nameToIndexMapping; + const currentMapping = obj.$$STable.REPR.nameToIndexMapping; /* Ensure the MRO prefixes match up. */ let currentIndex = 0; @@ -418,7 +418,7 @@ class P6opaque extends REPRWithAttributes { } } - Object.setPrototypeOf(obj, newType._STable.ObjConstructor.prototype); + Object.setPrototypeOf(obj, newType.$$STable.ObjConstructor.prototype); } compose(STable, reprInfoHash) { @@ -462,33 +462,33 @@ class P6opaque extends REPRWithAttributes { const attrType = attr.get('type'); /* old boxing method generation */ if (attr.get('box_target')) { - const REPR = attrType._STable.REPR; + const REPR = attrType.$$STable.REPR; if (!this.unboxSlots) this.unboxSlots = []; this.unboxSlots.push({slot: curAttr, reprId: REPR.ID}); if (!REPR.generateBoxingMethods) { console.log('we do not have a generateBoxingMethods'); console.log(REPR.name); } - REPR.generateBoxingMethods(STable, slotToAttr(curAttr), attrType._STable); + REPR.generateBoxingMethods(STable, slotToAttr(curAttr), attrType.$$STable); } slots.push(curAttr); names.push(attr.get('name').$$getStr()); - if (attrType !== undefined && attrType !== Null && attrType._STable.REPR.flattenSTable) { - this.flattenedSTables.push(attrType._STable); + if (attrType !== undefined && attrType !== Null && attrType.$$STable.REPR.flattenSTable) { + this.flattenedSTables.push(attrType.$$STable); } else { this.flattenedSTables.push(null); } if (attr.get('positional_delegate')) { this.positionalDelegateSlot = curAttr; - this._STable.setPositionalDelegate(slotToAttr(this.positionalDelegateSlot)); + this.$$STable.setPositionalDelegate(slotToAttr(this.positionalDelegateSlot)); } if (attr.get('associative_delegate')) { this.associativeDelegateSlot = curAttr; - this._STable.setAssociativeDelegate(slotToAttr(this.associativeDelegateSlot)); + this.$$STable.setAssociativeDelegate(slotToAttr(this.associativeDelegateSlot)); } if (attr.get('auto_viv_container')) { @@ -582,7 +582,7 @@ class P6opaque extends REPRWithAttributes { } STable.compileAccessor('$$setDefaults', 'function() {\n' + defaults + '}'); - STable.compileAccessor('$$clone', 'function() {var cloned = new this._STable.ObjConstructor();' + clone + 'return cloned}'); + STable.compileAccessor('$$clone', 'function() {var cloned = new this.$$STable.ObjConstructor();' + clone + 'return cloned}'); STable.evalGatheredCode(); } @@ -1102,7 +1102,7 @@ class NFA extends REPR { reprs.NFA = NFA; function primType(type) { - return type !== Null ? (type._STable.REPR.boxedPrimitive()): 0; + return type !== Null ? (type.$$STable.REPR.boxedPrimitive()): 0; } // TODO rework VMArray to be more correct @@ -1253,12 +1253,12 @@ class VMArray extends REPR { } else if (this.primType === 1 || this.primType === 4 || this.primType == 5) { let mangle; if (this.type !== Null) { - const repr = this.type._STable.REPR; + const repr = this.type.$$STable.REPR; if (repr instanceof P6int) { - const bits = this.type._STable.REPR.bits; + const bits = this.type.$$STable.REPR.bits; const shift = 32 - bits; - if (this.type._STable.REPR.isUnsigned) { + if (this.type.$$STable.REPR.isUnsigned) { mangle = function(value) { const trimmed = (value << shift >> shift); const ret = trimmed < 0 ? (1 << bits) + trimmed : trimmed; @@ -2030,10 +2030,10 @@ class Decoder extends REPR { return Null; } - const buf = bufType._STable.REPR.allocate(bufType._STable); + const buf = bufType.$$STable.REPR.allocate(bufType.$$STable); const elementSize = core.byteSize(buf); - const isUnsigned = buf._STable.REPR.type._STable.REPR.isUnsigned; + const isUnsigned = buf.$$STable.REPR.type.$$STable.REPR.isUnsigned; let offset = 0; @@ -2085,7 +2085,7 @@ class MultiDimArray extends REPR { } $$clone() { - const clone = new this._STable.ObjConstructor(); + const clone = new this.$$STable.ObjConstructor(); clone.storage = this.storage.slice(); clone.dimensions = this.dimensions; return clone; @@ -2262,12 +2262,12 @@ class MultiDimArray extends REPR { } serialize(cursor, obj) { - for (let i = 0; i < obj._STable.dimensions; i++) { + for (let i = 0; i < obj.$$STable.dimensions; i++) { cursor.varint(obj.dimensions[i]); } const size = this.valuesSize(obj); for (let i = 0; i < size; i++) { - switch (obj._STable.primType) { + switch (obj.$$STable.primType) { case 0: cursor.ref(obj.storage[i]); break; @@ -2286,13 +2286,13 @@ class MultiDimArray extends REPR { deserializeFinish(obj, data) { obj.dimensions = []; - for (let i = 0; i < obj._STable.dimensions; i++) { + for (let i = 0; i < obj.$$STable.dimensions; i++) { obj.dimensions[i] = data.varint(); } const size = this.valuesSize(obj); obj.storage = []; for (let i = 0; i < size; i++) { - switch (obj._STable.primType) { + switch (obj.$$STable.primType) { case 0: obj.storage[i] = data.variant(); break; @@ -2330,7 +2330,7 @@ class NativeRef extends REPR { compose(STable, reprInfoHash) { const nativeref = reprInfoHash.content.get('nativeref').content; const type = nativeref.get('type'); - this.primitiveType = type._STable.REPR.boxedPrimitive(); + this.primitiveType = type.$$STable.REPR.boxedPrimitive(); this.refkind = nativeref.get('refkind'); } @@ -2399,7 +2399,7 @@ class CREPR extends REPRWithAttributes { this.slotTypes[curAttr] = attrType; - if (!attrType._STable.REPR.asRefType) { + if (!attrType.$$STable.REPR.asRefType) { throw new NQPException(`CUnion: Can't use attr ${attr.get('name').$$getStr()} as CUnion attr`); } @@ -2422,8 +2422,8 @@ class CREPR extends REPRWithAttributes { build(STable) { const refTypes = {}; for (let slot = 0; slot < this.slotTypes.length; slot++) { - refTypes[slotToAttr(slot)] = this.slotTypes[slot]._STable.REPR.asRefType(); - this.slotTypes[slot]._STable.REPR.generateRefAccessors(STable, this.slotTypes[slot]._STable, slot); + refTypes[slotToAttr(slot)] = this.slotTypes[slot].$$STable.REPR.asRefType(); + this.slotTypes[slot].$$STable.REPR.generateRefAccessors(STable, this.slotTypes[slot].$$STable, slot); } this.UnionConstructor = this.createLowlevelConstructor(refTypes); @@ -2503,7 +2503,7 @@ class WrappedJSObject extends REPR { }; ObjConstructor.prototype = Object.create(new Proxy({}, handler)); - ObjConstructor.prototype._STable = STable; + ObjConstructor.prototype.$$STable = STable; ObjConstructor.prototype._SC = undefined; ObjConstructor.prototype._WHERE = undefined; diff --git a/src/vm/js/nqp-runtime/runtime.js b/src/vm/js/nqp-runtime/runtime.js index f33a2b388c..22baa3be4a 100644 --- a/src/vm/js/nqp-runtime/runtime.js +++ b/src/vm/js/nqp-runtime/runtime.js @@ -262,7 +262,7 @@ op.setdispatcherfor = function(dispatcher, dispatcherFor) { let spec; if (dispatcherFor instanceof CodeRef) { exports.currentDispatcherFor = dispatcherFor; - } else if (spec = dispatcherFor._STable.invocationSpec) { + } else if (spec = dispatcherFor.$$STable.invocationSpec) { if (spec.classHandle) { exports.currentDispatcherFor = dispatcherFor.$$getattr(spec.classHandle, spec.attrName); } else { @@ -310,7 +310,7 @@ exports.toNum = /*async*/ function(arg_, ctx) { return 0; } else if (arg instanceof NQPStr) { return coercions.strToNum(arg.value); - } else if (arg._STable && arg._STable.methodCache && arg._STable.methodCache.get('Num')) { + } else if (arg.$$STable && arg.$$STable.methodCache && arg.$$STable.methodCache.get('Num')) { const result = /*await*/ arg.Num(ctx, null, arg); // eslint-disable-line new-cap if (typeof result === 'number') { return result; @@ -470,17 +470,17 @@ exports.list = hll.list; exports.list_i = function lowlevelList(array) { - const stable = BOOT.IntArray._STable; + const stable = BOOT.IntArray.$$STable; return stable.REPR.allocateFromArray(stable, array); }; exports.list_n = function lowlevelList(array) { - const stable = BOOT.NumArray._STable; + const stable = BOOT.NumArray.$$STable; return stable.REPR.allocateFromArray(stable, array); }; exports.list_s = function lowlevelList(array) { - const stable = BOOT.StrArray._STable; + const stable = BOOT.StrArray.$$STable; return stable.REPR.allocateFromArray(stable, array); }; @@ -491,9 +491,9 @@ exports.createIntArray = require('./BOOT.js').createIntArray; exports.dumpObj = function(obj) { console.log(typeof obj); if (typeof obj === 'object') { - if (obj._STable) { - console.log(obj._STable.REPR.name); - const name = obj._STable.HOW.name(null, null, obj._STable.HOW, obj); + if (obj.$$STable) { + console.log(obj.$$STable.REPR.name); + const name = obj.$$STable.HOW.name(null, null, obj.$$STable.HOW, obj); console.log(name instanceof NQPStr ? name.value : name); } else { console.log('no STable', obj.constructor.name); diff --git a/src/vm/js/nqp-runtime/serialization-context.js b/src/vm/js/nqp-runtime/serialization-context.js index 4983b7a0d1..ada6881e94 100644 --- a/src/vm/js/nqp-runtime/serialization-context.js +++ b/src/vm/js/nqp-runtime/serialization-context.js @@ -45,9 +45,9 @@ class SerializationContext extends NQPObject { setObj(idx, obj) { this.rootObjects[idx] = obj; - if (!obj._STable._SC) { - this.rootSTables.push(obj._STable); - obj._STable._SC = this; + if (!obj.$$STable._SC) { + this.rootSTables.push(obj.$$STable); + obj.$$STable._SC = this; } } diff --git a/src/vm/js/nqp-runtime/serialization.js b/src/vm/js/nqp-runtime/serialization.js index ec546615a4..f029db13b2 100644 --- a/src/vm/js/nqp-runtime/serialization.js +++ b/src/vm/js/nqp-runtime/serialization.js @@ -224,7 +224,7 @@ class BinaryWriteCursor { objRef(ref) { const writerSc = this.writer.sc; - if (!ref._STable) { + if (!ref.$$STable) { throw new NQPException('trying to serialize an object without an STable'); } if (!ref._SC) { @@ -260,7 +260,7 @@ class BinaryWriteCursor { discrim = REFVAR_VM_NUM; } else if (ref instanceof NQPStr) { discrim = REFVAR_VM_STR; - } else if (ref._STable === BOOT.Array._STable) { + } else if (ref.$$STable === BOOT.Array.$$STable) { discrim = REFVAR_VM_ARR_VAR; } else if (ref instanceof Hash) { discrim = REFVAR_VM_HASH_STR_VAR; @@ -316,7 +316,7 @@ class BinaryWriteCursor { case REFVAR_VM_ARR_INT: case REFVAR_VM_ARR_STR: case REFVAR_VM_ARR_VAR: - ref._STable.REPR.serialize(this, ref); + ref.$$STable.REPR.serialize(this, ref); break; case REFVAR_VM_HASH_STR_VAR: this.varint(ref.$$elems()); @@ -366,10 +366,10 @@ class SerializationWriter { serializeObject(obj) { /* Get index of SC that holds the STable and its index. */ - if (!obj._STable) { + if (!obj.$$STable) { throw new NQPException(`Can't serialize an object without an STable`); } - const ref = this.getSTableRefInfo(obj._STable); + const ref = this.getSTableRefInfo(obj.$$STable); const sc = ref[0]; const scIdx = ref[1]; @@ -391,10 +391,10 @@ class SerializationWriter { /* Delegate to its serialization REPR function. */ if (!obj.$$typeObject) { - if (!obj._STable.REPR.serialize) { - console.trace(`don't know how to serialize ${obj._STable.REPR.name}`); + if (!obj.$$STable.REPR.serialize) { + console.trace(`don't know how to serialize ${obj.$$STable.REPR.name}`); } else { - obj._STable.REPR.serialize(this.objectsData, obj); + obj.$$STable.REPR.serialize(this.objectsData, obj); } } } @@ -641,11 +641,11 @@ class SerializationWriter { this.paramInterns.int32(this.sc.rootObjects.indexOf(type)); - if (type._STable._SC !== this.sc) { + if (type.$$STable._SC !== this.sc) { throw new NQPException('Serialization error: STable of parameterized type to intern not in current SC'); } - this.paramInterns.int32(this.sc.rootSTables.indexOf(type._STable)); + this.paramInterns.int32(this.sc.rootSTables.indexOf(type.$$STable)); /* Write parameter count and parameter object refs. */ this.paramInterns.int32(params.length); @@ -828,7 +828,7 @@ class SerializationWriter { if (origIdx < 0) { throw 'Could not find object when writing repossessions; ' + - (isST != 0 ? 'STable' : 'REPR = ' + this.sc.rootObjects[objIdx]._STable.REPR.name); + (isST != 0 ? 'STable' : 'REPR = ' + this.sc.rootObjects[objIdx].$$STable.REPR.name); } /* Write table row. */ @@ -1003,7 +1003,7 @@ op.serialize = function(sc, sh) { op.serializetobuf = function(sc, sh, type) { const writer = new SerializationWriter(sc, sh.array); - const buffer = type._STable.REPR.allocate(type._STable); + const buffer = type.$$STable.REPR.allocate(type.$$STable); core.writeBuffer(buffer, writer.serialize()); return buffer; }; diff --git a/src/vm/js/nqp-runtime/sixmodel.js b/src/vm/js/nqp-runtime/sixmodel.js index e8ad087003..d0a41677f4 100644 --- a/src/vm/js/nqp-runtime/sixmodel.js +++ b/src/vm/js/nqp-runtime/sixmodel.js @@ -27,18 +27,18 @@ const nativeArgs = require('./native-args.js'); const NativeStrArg = nativeArgs.NativeStrArg; /*async*/ function findMethod(ctx, obj, name) { - if (obj._STable.methodCache) { - const method = obj._STable.methodCache.get(name); + if (obj.$$STable.methodCache) { + const method = obj.$$STable.methodCache.get(name); if (method !== undefined) { return method; } - if (obj._STable.modeFlags & constants.METHOD_CACHE_AUTHORITATIVE) { + if (obj.$$STable.modeFlags & constants.METHOD_CACHE_AUTHORITATIVE) { return Null; } } - if (/*await*/ obj._STable.HOW.$$can(ctx, 'find_method')) { - return /*await*/ obj._STable.HOW.find_method(ctx, null, obj._STable.HOW, obj, new NativeStrArg(name)); + if (/*await*/ obj.$$STable.HOW.$$can(ctx, 'find_method')) { + return /*await*/ obj.$$STable.HOW.find_method(ctx, null, obj.$$STable.HOW, obj, new NativeStrArg(name)); } else { return Null; } @@ -73,7 +73,7 @@ class STable { /* HACK - it's a bit hackish - think how correct it is */ this.ObjConstructor.prototype.$$clone = function() { - const clone = new this._STable.ObjConstructor(); + const clone = new this.$$STable.ObjConstructor(); for (const i in this) { if (Object.prototype.hasOwnProperty.call(this, i) && i != '_SC') { clone[i] = this[i]; @@ -101,7 +101,7 @@ class STable { this.ObjConstructor.prototype.$$scwb = scwb; this.ObjConstructor.prototype.$$istype = /*async*/ function(ctx, type) { - const cache = this._STable.typeCheckCache; + const cache = this.$$STable.typeCheckCache; if (cache) { for (let i = 0; i < cache.length; i++) { if (cache[i] === type) { @@ -112,7 +112,7 @@ class STable { /* If we get here, need to call .^type_check on the value we're * checking. */ - const HOW = this._STable.HOW; + const HOW = this.$$STable.HOW; /* This "hack" is stolen from the JVM */ if (!/*await*/ HOW.$$can(ctx, 'type_check')) { return 0; @@ -125,8 +125,8 @@ class STable { } const TYPE_CHECK_NEEDS_ACCEPTS = 2; - if (type._STable.modeFlags & TYPE_CHECK_NEEDS_ACCEPTS) { - return (/*await*/ type._STable.HOW.accepts_type(ctx, null, type._STable.HOW, type, this)).$$toBool(ctx); + if (type.$$STable.modeFlags & TYPE_CHECK_NEEDS_ACCEPTS) { + return (/*await*/ type.$$STable.HOW.accepts_type(ctx, null, type.$$STable.HOW, type, this)).$$toBool(ctx); } return 0; @@ -258,15 +258,15 @@ class STable { }; obj.$$getInt = function() { - throw new NQPException(`Cannot unbox a type object (${this._STable.debugName}) to an int.`); + throw new NQPException(`Cannot unbox a type object (${this.$$STable.debugName}) to an int.`); }; obj.$$getNum = function() { - throw new NQPException(`Cannot unbox a type object (${this._STable.debugName}) to an num.`); + throw new NQPException(`Cannot unbox a type object (${this.$$STable.debugName}) to an num.`); }; obj.$$getStr = function() { - throw new NQPException(`Cannot unbox a type object (${this._STable.debugName}) to an str.`); + throw new NQPException(`Cannot unbox a type object (${this.$$STable.debugName}) to an str.`); }; return obj;