Permalink
Browse files

Merge pull request #21 from zjj010104/master

Instrument UnaryStatement and Identifier in certain context.
  • Loading branch information...
2 parents f139414 + f579eae commit a6f027c775d0ba643906e82bda676effa1e2628c @itay committed May 8, 2012
Showing with 19 additions and 2 deletions.
  1. +19 −2 instrument.js
View
@@ -358,7 +358,24 @@ Instrumentor.prototype.wrap = function(tree) {
case esprima.Syntax.BinaryExpression:
case esprima.Syntax.UpdateExpression:
case esprima.Syntax.LogicalExpression:
- case esprima.Syntax.CallExpression: {
+ case esprima.Syntax.CallExpression:
+ case esprima.Syntax.UnaryExpression:
+ case esprima.Syntax.Identifier: {
+ // Only instrument Identifier in certain context.
+ if (node.type === esprima.Syntax.Identifier) {
+ if (!(parent && (parent.type == 'UnaryExpression' ||
+ parent.type == 'BinaryExpression' ||
+ parent.type == 'LogicalExpression' ||
+ parent.type == 'ConditionalExpression' ||
+ parent.type == 'SwitchStatement' ||
+ parent.type == 'SwitchCase' ||
+ parent.type == 'ForStatement' ||
+ parent.type == 'IfStatement' ||
+ parent.type == 'WhileStatement' ||
+ parent.type == 'DoWhileStatement'))) {
+ return;
+ }
+ }
var newNode = {
"type": "SequenceExpression",
"expressions": [
@@ -486,4 +503,4 @@ Instrumentor.prototype.wrap = function(tree) {
}
}
});
-}
+}

0 comments on commit a6f027c

Please sign in to comment.