Skip to content

Commit ac51c16

Browse files
committed
[js] Hack around the lack of typed attributes support to unbreak nqp-js-on-js.
1 parent 02f0f5e commit ac51c16

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/vm/js/QAST/Compiler.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ class QAST::OperationsJS {
451451
);
452452
}
453453

454+
# HACK - we need this until we handle types on attributes properly
455+
add_simple_op('getattr_i', $T_INT, [$T_OBJ, $T_OBJ, $T_STR], sub ($obj, $type, $attr) {
456+
"nqp.intAttrHack($obj[$attr])"
457+
});
458+
454459
add_simple_op('attrinited', $T_BOOL, [$T_OBJ, $T_OBJ, $T_STR],
455460
sub ($obj, $type, $attr) {
456461
# TODO take second argument into account

src/vm/js/nqp-runtime/runtime.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var op = {};
22
exports.op = op;
33

4-
exports.NQPInt = require("./nqp-int.js");
4+
var NQPInt = require("./nqp-int.js");
5+
exports.NQPInt = NQPInt;
56

67
function load_ops(module) {
78
for (var name in module.op) {
@@ -414,6 +415,14 @@ exports.NYI = function(msg) {
414415
return null;
415416
};
416417

418+
/* HACK - needed until we handle types on attributes */
419+
exports.intAttrHack = function(attrValue) {
420+
if (attrValue instanceof exports.NQPInt) {
421+
return attrValue.value;
422+
} else {
423+
return attrValue;
424+
}
425+
};
417426

418427
exports.args = function(module) {
419428
return require.main === module ? process.argv.slice(1) : [];

0 commit comments

Comments
 (0)