Comparing version 0.3.4 to 0.3.5-1
{ | ||
"name": "jsdc", | ||
"version": "0.3.4", | ||
"version": "0.3.5-1", | ||
"description": "transform ecmascript6 to ecmascript5", | ||
@@ -31,3 +31,4 @@ "maintainers": [ | ||
"jsdc/src/Str.js", | ||
"jsdc/src/Obj.js" | ||
"jsdc/src/Obj.js", | ||
"jsdc/src/join.js" | ||
] | ||
@@ -43,3 +44,5 @@ } | ||
"ecmascript6", | ||
"ecmascript5" | ||
"ecmascript5", | ||
"transform", | ||
"compiler" | ||
], | ||
@@ -52,3 +55,3 @@ "author": "army8735", | ||
"dependencies": { | ||
"homunculus": "^0.2.7-3" | ||
"homunculus": "^0.3.0-2" | ||
}, | ||
@@ -55,0 +58,0 @@ "devDependencies": { |
@@ -226,3 +226,3 @@ # Javascript Downcast | ||
```js | ||
function method(a, b ) {if(b ===void 0) b = 1; | ||
function method(a, b ) {if(b ===void 0)b=1; | ||
} | ||
@@ -356,3 +356,3 @@ ``` | ||
``` | ||
getter/setter会巧妙地设置到原型上: | ||
getter/setter会通过`Object.defineProperty`巧妙地设置到原型上: | ||
```js | ||
@@ -366,7 +366,7 @@ class A{ | ||
function A(){} | ||
A.prototype.b={get b(){}}["b"]; | ||
A.prototype.c={set c(d){}}["c"]; | ||
Object.defineProperty(A.prototype, "b", {get :function(){}}); | ||
Object.defineProperty(A.prototype, "c", {set :function(d){}}); | ||
``` | ||
`static`静态属性会附加在`function`本身: | ||
`static`静态方法会附加在`function`本身: | ||
```js | ||
@@ -418,3 +418,3 @@ class A{ | ||
!function(){var _=Object.create(B.prototype);_.constructor=A;A.prototype=_;}(); | ||
function A(){B.a.call(this)} | ||
function A(){B.prototype.a.call(this)} | ||
Object.keys(B).forEach(function(k){A[k]=B[k]}); | ||
@@ -421,0 +421,0 @@ ``` |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -54,3 +55,3 @@ var ArrayCmph = Class(function(jsdc) { | ||
this.jsdc.appendBefore('='); | ||
this.jsdc.appendBefore(this.join(node.leaf(4))); | ||
this.jsdc.appendBefore(join(node.leaf(4))); | ||
this.jsdc.appendBefore('['); | ||
@@ -80,19 +81,2 @@ this.jsdc.appendBefore(id); | ||
} | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -99,0 +83,0 @@ }); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -34,21 +35,6 @@ var DefaultValue = Class(function(jsdc) { | ||
self.jsdc.append('if(' + id + '===void 0)' + id); | ||
self.recursion(sgname.last()); | ||
self.jsdc.append(join(sgname.last())); | ||
self.jsdc.append(';'); | ||
}); | ||
} | ||
}, | ||
recursion: function(node) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
self.jsdc.append(' ' + node.token().content()); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf); | ||
}); | ||
} | ||
} | ||
@@ -55,0 +41,0 @@ }); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -108,3 +109,3 @@ var Destruct = Class(function(jsdc) { | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -156,3 +157,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -207,3 +208,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -244,3 +245,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -329,3 +330,3 @@ break; | ||
self.jsdc.appendBefore('if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + '=' + self.join(leaf.next().next()) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + '=' + join(leaf.next().next()) + (end ? '' : ';')); | ||
break; | ||
@@ -395,3 +396,3 @@ case JsNode.ARRLTR: | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -466,3 +467,3 @@ break; | ||
self.jsdc.appendBefore('if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + '=' + self.join(leaf.next().next()) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + '=' + join(leaf.next().next()) + (end ? '' : ';')); | ||
break; | ||
@@ -498,3 +499,3 @@ case JsNode.ARRLTR: | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -546,19 +547,2 @@ break; | ||
}); | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -565,0 +549,0 @@ }); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -49,3 +50,3 @@ var Forof = Class(function(jsdc) { | ||
else { | ||
k = this.join(k); | ||
k = join(k); | ||
} | ||
@@ -83,25 +84,5 @@ this.jsdc.append(k + '.done;') | ||
else { | ||
k = this.join(k); | ||
k = join(k); | ||
} | ||
this.jsdc.append(k + '=' + k + '.value;'); | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -108,0 +89,0 @@ }); |
@@ -246,2 +246,5 @@ var homunculus = require('homunculus'); | ||
break; | ||
case JsNode.PROPTNAME: | ||
this.klass.prptn(node); | ||
break; | ||
case JsNode.MODULEBODY: | ||
@@ -248,0 +251,0 @@ this.module.enter(node); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -12,2 +13,3 @@ var Klass = Class(function(jsdc) { | ||
this.sup = {}; | ||
this.gs = {}; | ||
}).methods({ | ||
@@ -29,3 +31,3 @@ parse: function(node, start) { | ||
this.jsdc.ignore(node.leaf(5)); | ||
o.extend = this.join(node.leaf(2).last()); | ||
o.extend = join(node.leaf(2).last()); | ||
this.body(node.last().prev(), o.name, o.extend); | ||
@@ -58,3 +60,3 @@ this.jsdc.append('!function(){'); | ||
if(node.leaf(1).name() == JsNode.HERITAGE) { | ||
o.extend = this.join(node.leaf(1).last()); | ||
o.extend = join(node.leaf(1).last()); | ||
o.name = this.jsdc.uid(); | ||
@@ -70,3 +72,3 @@ } | ||
o.name = node.leaf(1).first().token().content(); | ||
o.extend = this.join(node.leaf(2).last()); | ||
o.extend = join(node.leaf(2).last()); | ||
} | ||
@@ -123,4 +125,8 @@ else { | ||
if(start) { | ||
var prptn = first.next(); | ||
this.gs[prptn.nid()] = true; | ||
this.jsdc.ignore(prptn); | ||
this.jsdc.append('Object.defineProperty('); | ||
this.jsdc.append(o.name); | ||
this.jsdc.append('.prototype.'); | ||
this.jsdc.append('.prototype, "'); | ||
if(token.content() == 'get') { | ||
@@ -136,13 +142,6 @@ var n = first.next().first().first().token(); | ||
} | ||
this.jsdc.append('={'); | ||
this.jsdc.append('", {'); | ||
} | ||
else { | ||
this.jsdc.appendBefore('}["'); | ||
if(token.content() == 'get') { | ||
this.jsdc.appendBefore(o.g); | ||
} | ||
else { | ||
this.jsdc.appendBefore(o.s); | ||
} | ||
this.jsdc.appendBefore('"];'); | ||
this.jsdc.appendBefore('});'); | ||
} | ||
@@ -159,2 +158,7 @@ } | ||
}, | ||
prptn: function(node) { | ||
if(this.gs.hasOwnProperty(node.nid())) { | ||
this.jsdc.append(':function'); | ||
} | ||
}, | ||
super: function(node) { | ||
@@ -244,22 +248,2 @@ this.jsdc.ignore(node); | ||
} | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -266,0 +250,0 @@ }); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -43,3 +44,3 @@ var Obj = Class(function(jsdc) { | ||
temp: temp, | ||
id: this.join(first) | ||
id: join(first) | ||
}); | ||
@@ -91,19 +92,2 @@ this.jsdc.append(temp); | ||
} | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -110,0 +94,0 @@ }); |
@@ -6,2 +6,3 @@ var homunculus = require('homunculus'); | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -59,7 +60,7 @@ var Rest = Class(function(jsdc) { | ||
//主表达式无需设置apply的context,成员需设 | ||
this.jsdc.append(mmb.name() == JsNode.MMBEXPR ? this.join(mmb.first()) : 'this'); | ||
this.jsdc.append(mmb.name() == JsNode.MMBEXPR ? join(mmb.first()) : 'this'); | ||
this.jsdc.append(', ['); | ||
var leaves = node.leaves(); | ||
for(var i = 0; i < leaves.length - 3; i++) { | ||
this.jsdc.append(this.join(leaves[i])); | ||
this.jsdc.append(join(leaves[i])); | ||
} | ||
@@ -71,22 +72,2 @@ this.jsdc.append(']'); | ||
} | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -93,0 +74,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -55,3 +56,3 @@ var ArrayCmph = Class(function(jsdc) { | ||
this.jsdc.appendBefore('='); | ||
this.jsdc.appendBefore(this.join(node.leaf(4))); | ||
this.jsdc.appendBefore(join(node.leaf(4))); | ||
this.jsdc.appendBefore('['); | ||
@@ -81,19 +82,2 @@ this.jsdc.appendBefore(id); | ||
} | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -100,0 +84,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -35,21 +36,6 @@ var DefaultValue = Class(function(jsdc) { | ||
self.jsdc.append('if(' + id + '===void 0)' + id); | ||
self.recursion(sgname.last()); | ||
self.jsdc.append(join(sgname.last())); | ||
self.jsdc.append(';'); | ||
}); | ||
} | ||
}, | ||
recursion: function(node) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
self.jsdc.append(' ' + node.token().content()); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf); | ||
}); | ||
} | ||
} | ||
@@ -56,0 +42,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -109,3 +110,3 @@ var Destruct = Class(function(jsdc) { | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -157,3 +158,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -208,3 +209,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -245,3 +246,3 @@ break; | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -330,3 +331,3 @@ break; | ||
self.jsdc.appendBefore('if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + '=' + self.join(leaf.next().next()) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + '=' + join(leaf.next().next()) + (end ? '' : ';')); | ||
break; | ||
@@ -396,3 +397,3 @@ case JsNode.ARRLTR: | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -467,3 +468,3 @@ break; | ||
self.jsdc.appendBefore('if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + '=' + self.join(leaf.next().next()) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + '=' + join(leaf.next().next()) + (end ? '' : ';')); | ||
break; | ||
@@ -499,3 +500,3 @@ case JsNode.ARRLTR: | ||
self.jsdc.appendBefore((end ? ';' : '') + 'if(' + id + '===void 0)') | ||
self.jsdc.appendBefore(id + self.join(init) + (end ? '' : ';')); | ||
self.jsdc.appendBefore(id + join(init) + (end ? '' : ';')); | ||
} | ||
@@ -547,19 +548,2 @@ break; | ||
}); | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -566,0 +550,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -50,3 +51,3 @@ var Forof = Class(function(jsdc) { | ||
else { | ||
k = this.join(k); | ||
k = join(k); | ||
} | ||
@@ -84,25 +85,5 @@ this.jsdc.append(k + '.done;') | ||
else { | ||
k = this.join(k); | ||
k = join(k); | ||
} | ||
this.jsdc.append(k + '=' + k + '.value;'); | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -109,0 +90,0 @@ }); |
@@ -247,2 +247,5 @@ define(function(require, exports, module) { | ||
break; | ||
case JsNode.PROPTNAME: | ||
this.klass.prptn(node); | ||
break; | ||
case JsNode.MODULEBODY: | ||
@@ -249,0 +252,0 @@ this.module.enter(node); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -13,2 +14,3 @@ var Klass = Class(function(jsdc) { | ||
this.sup = {}; | ||
this.gs = {}; | ||
}).methods({ | ||
@@ -30,3 +32,3 @@ parse: function(node, start) { | ||
this.jsdc.ignore(node.leaf(5)); | ||
o.extend = this.join(node.leaf(2).last()); | ||
o.extend = join(node.leaf(2).last()); | ||
this.body(node.last().prev(), o.name, o.extend); | ||
@@ -59,3 +61,3 @@ this.jsdc.append('!function(){'); | ||
if(node.leaf(1).name() == JsNode.HERITAGE) { | ||
o.extend = this.join(node.leaf(1).last()); | ||
o.extend = join(node.leaf(1).last()); | ||
o.name = this.jsdc.uid(); | ||
@@ -71,3 +73,3 @@ } | ||
o.name = node.leaf(1).first().token().content(); | ||
o.extend = this.join(node.leaf(2).last()); | ||
o.extend = join(node.leaf(2).last()); | ||
} | ||
@@ -124,4 +126,8 @@ else { | ||
if(start) { | ||
var prptn = first.next(); | ||
this.gs[prptn.nid()] = true; | ||
this.jsdc.ignore(prptn); | ||
this.jsdc.append('Object.defineProperty('); | ||
this.jsdc.append(o.name); | ||
this.jsdc.append('.prototype.'); | ||
this.jsdc.append('.prototype, "'); | ||
if(token.content() == 'get') { | ||
@@ -137,13 +143,6 @@ var n = first.next().first().first().token(); | ||
} | ||
this.jsdc.append('={'); | ||
this.jsdc.append('", {'); | ||
} | ||
else { | ||
this.jsdc.appendBefore('}["'); | ||
if(token.content() == 'get') { | ||
this.jsdc.appendBefore(o.g); | ||
} | ||
else { | ||
this.jsdc.appendBefore(o.s); | ||
} | ||
this.jsdc.appendBefore('"];'); | ||
this.jsdc.appendBefore('});'); | ||
} | ||
@@ -160,2 +159,7 @@ } | ||
}, | ||
prptn: function(node) { | ||
if(this.gs.hasOwnProperty(node.nid())) { | ||
this.jsdc.append(':function'); | ||
} | ||
}, | ||
super: function(node) { | ||
@@ -245,22 +249,2 @@ this.jsdc.ignore(node); | ||
} | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -267,0 +251,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -44,3 +45,3 @@ var Obj = Class(function(jsdc) { | ||
temp: temp, | ||
id: this.join(first) | ||
id: join(first) | ||
}); | ||
@@ -92,19 +93,2 @@ this.jsdc.append(temp); | ||
} | ||
}, | ||
join: function(node, res) { | ||
res = res || { s: '' }; | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.join(leaf, res); | ||
}); | ||
} | ||
return res.s; | ||
} | ||
@@ -111,0 +95,0 @@ }); |
@@ -7,2 +7,3 @@ define(function(require, exports, module) { | ||
var Class = require('./util/Class'); | ||
var join = require('./join'); | ||
@@ -60,7 +61,7 @@ var Rest = Class(function(jsdc) { | ||
//主表达式无需设置apply的context,成员需设 | ||
this.jsdc.append(mmb.name() == JsNode.MMBEXPR ? this.join(mmb.first()) : 'this'); | ||
this.jsdc.append(mmb.name() == JsNode.MMBEXPR ? join(mmb.first()) : 'this'); | ||
this.jsdc.append(', ['); | ||
var leaves = node.leaves(); | ||
for(var i = 0; i < leaves.length - 3; i++) { | ||
this.jsdc.append(this.join(leaves[i])); | ||
this.jsdc.append(join(leaves[i])); | ||
} | ||
@@ -72,22 +73,2 @@ this.jsdc.append(']'); | ||
} | ||
}, | ||
join: function(node) { | ||
var res = { s: '' }; | ||
this.recursion(node, res); | ||
return res.s; | ||
}, | ||
recursion: function(node, res) { | ||
var self = this; | ||
var isToken = node.name() == JsNode.TOKEN; | ||
var isVirtual = isToken && node.token().type() == Token.VIRTUAL; | ||
if(isToken) { | ||
if(!isVirtual) { | ||
res.s += node.token().content(); | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, res); | ||
}); | ||
} | ||
} | ||
@@ -94,0 +75,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
54
0
211087
33
4709
1
+ Addedhomunculus@0.3.8(transitive)
- Removedhomunculus@0.2.9(transitive)
Updatedhomunculus@^0.3.0-2