Skip to content

Commit

Permalink
[js] Decont before converting objects to num or int instead of having…
Browse files Browse the repository at this point in the history
… a hack on containers.
  • Loading branch information
pmurias committed Jan 21, 2017
1 parent ec9f11f commit eebf37f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
42 changes: 0 additions & 42 deletions src/vm/js/nqp-runtime/container-specs.js
Expand Up @@ -83,18 +83,6 @@ class NativeRef {

if (primitiveType == 1) { // int
this.STable.addInternalMethods(class {
$getInt(ctx, value) {
return this.get();
}

$$getNum() {
return this.get();
}

$$getStr() {
return this.get().toString();
}

$$iscont_i() {
return 1;
}
Expand Down Expand Up @@ -136,18 +124,6 @@ class NativeRef {
});
} else if (primitiveType == 2) { // num
this.STable.addInternalMethods(class {
$$getInt(ctx, value) {
return this.get() | 0;
}

$$getNum(ctx, value) {
return this.get();
}

$$getStr(ctx, value) {
return this.get().toString();
}

$$iscont_n() {
return 1;
}
Expand Down Expand Up @@ -189,20 +165,6 @@ class NativeRef {
});
} else if (primitiveType == 3) { // str
this.STable.addInternalMethods(class {
$$getInt(ctx, value) {
var ret = parseFloat(this.get());
return isNaN(ret) ? 0 : ret | 0;
}

$$getNum(ctx, value) {
var ret = parseFloat(this.get());
return isNaN(ret) ? 0 : ret;
}

$$getStr(ctx, value) {
return this.get().toString();
}

$$iscont_s() {
return 1;
}
Expand All @@ -224,10 +186,6 @@ class NativeRef {
return this.get();
}

$$getStr(ctx, value) {
return this.get();
}

$$decont(ctx, value) {
var hll = STable.hllOwner;
if (hll === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion src/vm/js/nqp-runtime/runtime.js
Expand Up @@ -158,7 +158,8 @@ exports.toStr = function(arg_, ctx) {
}
};

exports.toNum = function(arg, ctx) {
exports.toNum = function(arg_, ctx) {
let arg = arg_.$$decont(ctx);
if (typeof arg == 'number') {
return arg;
} else if (arg === Null) {
Expand Down

0 comments on commit eebf37f

Please sign in to comment.