Skip to content

Commit

Permalink
[js] Migrate _STable to $$STable
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Dec 10, 2018
1 parent 74c31e2 commit f776e58
Show file tree
Hide file tree
Showing 21 changed files with 242 additions and 242 deletions.
12 changes: 6 additions & 6 deletions src/vm/js/Operations.nqp
Expand Up @@ -1583,10 +1583,10 @@ class QAST::OperationsJS {
%ops<die_s> := %ops<die>;


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));
Expand All @@ -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"});
Expand Down
4 changes: 2 additions & 2 deletions 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);
};
4 changes: 2 additions & 2 deletions src/vm/js/nqp-runtime/bignum.js
Expand Up @@ -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;
}
Expand Down
58 changes: 29 additions & 29 deletions src/vm/js/nqp-runtime/bootstrap.js
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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';
Expand All @@ -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;
});
Expand All @@ -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... */
Expand Down Expand Up @@ -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;
});
Expand All @@ -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);
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/vm/js/nqp-runtime/container-specs.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f776e58

Please sign in to comment.