Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle type objects better to so that tests don't break when we defin…
…e NQPMu.
  • Loading branch information
pmurias committed Dec 1, 2014
1 parent 7368510 commit 2063552
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vm/js/nqp-runtime/core.js
Expand Up @@ -161,7 +161,7 @@ op.create = function(obj) {

op.defined = function(obj) {
// TODO - handle more things that aren't defined
if (obj === undefined || obj === null) {
if (obj === undefined || obj === null || obj.type_object_) {
return 0;
}
return 1;
Expand Down
5 changes: 5 additions & 0 deletions src/vm/js/nqp-runtime/deserialization.js
Expand Up @@ -283,6 +283,11 @@ BinaryCursor.prototype.deserialize = function(sc) {
}
sc.root_objects[i] = new (STable_for_obj.obj_constructor)();
sc.root_objects[i]._SC = sc;

if (!objects[i].is_concrete) {
// TODO think more about it
sc.root_objects[i].type_object_ = 1;
}
}

for (var i = 0; i < STables.length; i++) {
Expand Down
5 changes: 5 additions & 0 deletions src/vm/js/nqp-runtime/runtime.js
Expand Up @@ -63,6 +63,9 @@ exports.to_num = function(arg) {
return isNaN(ret) ? 0 : ret;
} else if (arg instanceof Array) {
return arg.length;
} else if (arg.type_object_) {
// TODO - is that a correct way to do that?
return 0;
} else {
console.log(arg);
throw "Can't convert to num";
Expand All @@ -88,6 +91,8 @@ exports.to_bool = function(arg) {
return 0;
} else if (arg.$$to_bool) {
return arg.$$to_bool();
} else if (arg.type_object_) {
return false;
} else {
throw "Can't decide if arg is true";
}
Expand Down

0 comments on commit 2063552

Please sign in to comment.