Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] Hack around the lack of typed attributes support to unbreak nqp-…
…js-on-js.
  • Loading branch information
pmurias committed Nov 7, 2015
1 parent 02f0f5e commit ac51c16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/vm/js/QAST/Compiler.nqp
Expand Up @@ -451,6 +451,11 @@ class QAST::OperationsJS {
);
}

# HACK - we need this until we handle types on attributes properly
add_simple_op('getattr_i', $T_INT, [$T_OBJ, $T_OBJ, $T_STR], sub ($obj, $type, $attr) {
"nqp.intAttrHack($obj[$attr])"
});

add_simple_op('attrinited', $T_BOOL, [$T_OBJ, $T_OBJ, $T_STR],
sub ($obj, $type, $attr) {
# TODO take second argument into account
Expand Down
11 changes: 10 additions & 1 deletion src/vm/js/nqp-runtime/runtime.js
@@ -1,7 +1,8 @@
var op = {};
exports.op = op;

exports.NQPInt = require("./nqp-int.js");
var NQPInt = require("./nqp-int.js");
exports.NQPInt = NQPInt;

function load_ops(module) {
for (var name in module.op) {
Expand Down Expand Up @@ -414,6 +415,14 @@ exports.NYI = function(msg) {
return null;
};

/* HACK - needed until we handle types on attributes */
exports.intAttrHack = function(attrValue) {
if (attrValue instanceof exports.NQPInt) {
return attrValue.value;
} else {
return attrValue;
}
};

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

0 comments on commit ac51c16

Please sign in to comment.