Comparing version 0.0.10 to 0.0.11
# code-red changelog | ||
## 0.0.11 | ||
* Handle deconfliction edge case | ||
## 0.0.10 | ||
@@ -4,0 +8,0 @@ |
@@ -23,5 +23,12 @@ (function (global, factory) { | ||
const { map: scope_map } = perisopic.analyze(node); | ||
let { map: scope_map, scope: current_scope } = perisopic.analyze(node); | ||
const deconflicted = new WeakMap(); | ||
const set_scope = (type) => function( node, state) { | ||
const previous_scope = current_scope; | ||
current_scope = scope_map.get(node); | ||
(astring.baseGenerator )[type].call(this, node, state); | ||
current_scope = previous_scope; | ||
}; | ||
const generator = Object.assign({}, astring.baseGenerator, { | ||
@@ -67,7 +74,10 @@ handle( node, state) { | ||
AwaitExpression( node, state) { | ||
state.write('await '); | ||
const { argument } = node; | ||
this[argument.type](argument, state); | ||
}, | ||
ArrowFunctionExpression: set_scope('ArrowFunctionExpression'), | ||
BlockStatement: set_scope('BlockStatement'), | ||
CatchClause: set_scope('CatchClause'), | ||
ForStatement: set_scope('ForStatement'), | ||
ForInStatement: set_scope('ForInStatement'), | ||
ForOfStatement: set_scope('ForOfStatement'), | ||
FunctionDeclaration: set_scope('FunctionDeclaration'), | ||
FunctionExpression: set_scope('FunctionExpression'), | ||
@@ -80,11 +90,8 @@ Identifier( node, state) { | ||
if (node.name[0] === '@') { | ||
node = { ...node, name: getName(node.name.slice(1)) }; | ||
const name = getName(node.name.slice(1)); | ||
state.write(name, node); | ||
} | ||
if (node.name[0] === '#') { | ||
const scope = scope_map.get(node); | ||
if (!scope) { | ||
throw new Error(`Could not find scope for node`); | ||
} | ||
const owner = scope.find_owner(node.name); | ||
else if (node.name[0] === '#') { | ||
const owner = current_scope.find_owner(node.name); | ||
@@ -107,6 +114,8 @@ if (!owner) { | ||
const name = deconflict_map.get(node.name); | ||
node = { ...node, name }; | ||
state.write(name, node); | ||
} | ||
return astring.baseGenerator.Identifier.call(this, node, state); | ||
else { | ||
state.write(node.name, node); | ||
} | ||
}, | ||
@@ -113,0 +122,0 @@ |
{ | ||
"name": "code-red", | ||
"description": "code-red", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"repository": "Rich-Harris/code-red", | ||
@@ -6,0 +6,0 @@ "main": "dist/code-red.js", |
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
21038
557