jit 的bug?
Closed this issue · 4 comments
caizongchao commented
jscex 是我用过的最好的javascript的库之一,现在没有它日子已经没法过了。在使用过程中发现一个jit的问题:delete obj.key 会被翻译成 deleteobj.key, 中间缺少一个空格。我做了一点修改不知是否正确:
jscex-jit.js中,this._both(op) 改成 this._both(op + " ");
"unary-prefix": function (ast) {
var op = ast[1];
var item = ast[2];
this._both(op + " ");
if (op == "typeof") {
this._both("(")._visitRaw(item)._both(")");
} else {
this._visitRaw(item);
}
},
JeffreyZhao commented
多谢!这么做应该是可以的。我会尽快修复这个问题。关于JIT的单元测试现在也在紧锣密鼓中。
caizongchao commented
我又考虑了一下,仅仅把 this._both(op) 改成 this._both(op + " "); 可能并不完善,因为 表达式 !(a && b) 还是会被翻译成 ! a && b。是不是可以去掉 if( op == "typeof")的判断,直接都加上括号呢?
"unary-prefix": function (ast) {
var op = ast[1];
var item = ast[2];
this._both(op);
this._both("(")._visitRaw(item)._both(")");
},
JeffreyZhao commented
直接加上括号肯定是没有问题的,你可以先这么改,完整的场景交给我来考虑就行了。
caizongchao commented
好的,多谢多谢。