Comparing version 0.5.2 to 0.5.3
{ | ||
"name": "jsdc", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "compiler ecmascript6 to ecmascript5", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -121,3 +121,3 @@ var homunculus = require('homunculus'); | ||
var arglist = args.leaf(1); | ||
if(arglist.size() > 1) { | ||
if(arglist && arglist.size() > 1) { | ||
var last = arglist.last(); | ||
@@ -124,0 +124,0 @@ var spread = last.prev(); |
@@ -8,4 +8,17 @@ define(function(require, exports, module){var homunculus = require('homunculus'); | ||
this.jsdc = jsdc; | ||
this.hash = {}; | ||
}).methods({ | ||
parse: function(node) { | ||
//var nid = node.nid(); | ||
////遍历查看是否有调用this和arguments,存储引用实现lexical绑定 | ||
//this.recursion(node.last(), nid); | ||
//if(this.hash.hasOwnProperty(nid)) { | ||
// var o = this.hash[nid]; | ||
// if(o.this) { | ||
// this.jsdc.append('var ' + o.this + '=this;'); | ||
// } | ||
// if(o.arguments) { | ||
// this.jsdc.append('var ' + o.arguments + '=arguments;'); | ||
// } | ||
//} | ||
this.jsdc.append('function'); | ||
@@ -40,2 +53,33 @@ }, | ||
} | ||
}, | ||
recursion: function(node, nid) { | ||
var self = this; | ||
if(node.isToken()) { | ||
var token = node.token(); | ||
if(!token.isVirtual()) { | ||
var s = token.content(); | ||
if(s == 'this' || s == 'arguments') { | ||
this.hash[nid] = this.hash[nid] || {}; | ||
this.hash[nid][s] = this.jsdc.uid(); | ||
} | ||
} | ||
} | ||
else { | ||
node.leaves().forEach(function(leaf) { | ||
switch(leaf.name()) { | ||
case JsNode.CLASSDECL: | ||
case JsNode.CLASSEXPR: | ||
case JsNode.FNDECL: | ||
case JsNode.FNEXPR: | ||
case JsNode.ARROWFN: | ||
case JsNode.GENDECL: | ||
case JsNode.GENEXPR: | ||
case JsNode.OBJLTR: | ||
case JsNode.WITHSTMT: | ||
return; | ||
default: | ||
self.recursion(leaf, nid); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -42,0 +86,0 @@ }); |
@@ -121,3 +121,3 @@ define(function(require, exports, module){var homunculus = require('homunculus'); | ||
var arglist = args.leaf(1); | ||
if(arglist.size() > 1) { | ||
if(arglist && arglist.size() > 1) { | ||
var last = arglist.last(); | ||
@@ -124,0 +124,0 @@ var spread = last.prev(); |
Sorry, the diff of this file is not supported yet
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
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
336785
7845