I am getting different results when evaluation js vs compiling that js and evaluating it with jsc_eval_bytecode.
Here is the code :
function add(x, y){
return x + y;
}
function subtract(x, y){
return x - y;
}
function multiply(x, y){
return x * y;
}
function devide(x, y){
return x / y;
}
function pow(x, y){
return Math.pow(x, y);
}
class NMath{
constructor(){
this.add = add;
this.subtract = subtract;
this.multiply = multiply;
this.devide = devide;
this.pow = pow;
}
smors(x){
var arr = x.split('');
var narr = [];
var total = 1;
for (let i=0; i < arr.length; i++){
narr.push(this.multiply(arr[i].charCodeAt(), 2));
}
for (let i=0; i < narr.length; i++){
total = total + narr[i] - this.devide((narr[i - 1])? narr[i-1] : 1, 3);
}
return total;
}
}
let pp = new NMath();
pp.smors('hello');
If I do Module.cwrap('jsc_eval', 'string', ['string']) I get 784 as the result.
If I compile it and evaluate that I get this error :
Exception: SyntaxError: Unexpected identifier ''. Expected an opening '(' before a method's parameter list.
No idea what is causing this as I am just using the string returned from Module.cwrap('jsc_compile') to feed to jsc_eval.
I am getting different results when evaluation js vs compiling that js and evaluating it with jsc_eval_bytecode.
Here is the code :
If I do
Module.cwrap('jsc_eval', 'string', ['string'])I get 784 as the result.If I compile it and evaluate that I get this error :
No idea what is causing this as I am just using the string returned from
Module.cwrap('jsc_compile')to feed to jsc_eval.