def(AST_Call, function(tw, descend) {
tw.find_parent(AST_Scope).may_call_this();
var exp = this.expression;
- if (exp instanceof AST_Function) {
+ var tail = exp.tail_node();
+ if (tail instanceof AST_Function) {
+ if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
+ node.walk(tw);
+ });
this.args.forEach(function(arg) {
arg.walk(tw);
});
- exp.walk(tw);
+ tail.walk(tw);
return true;
- } else if (exp instanceof AST_SymbolRef) {
- var def = exp.definition();
+ } else if (tail instanceof AST_SymbolRef) {
+ var def = tail.definition();
if (this.TYPE == "Call" && tw.in_boolean_context()) def.bool_fn++;
if (!(def.fixed instanceof AST_Defun)) return;
var defun = mark_defun(tw, def);
defun.walk(tw);
return true;
} else if (this.TYPE == "Call"
- && exp instanceof AST_Assign
- && exp.operator == "="
- && exp.left instanceof AST_SymbolRef
+ && tail instanceof AST_Assign
+ && tail.operator == "="
+ && tail.left instanceof AST_SymbolRef
&& tw.in_boolean_context()) {
- exp.left.definition().bool_fn++;
+ tail.left.definition().bool_fn++;
}
});
def(AST_Conditional, function(tw) {
if (!(target instanceof AST_IterationStatement)) insert(target);
return true;
}
+ if (node instanceof AST_Call) {
+ var exp = node.expression;
+ var tail = exp.tail_node();
+ if (!(tail instanceof AST_Function)) return;
+ if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
+ node.walk(tw);
+ });
+ node.args.forEach(function(arg) {
+ arg.walk(tw);
+ });
+ tail.walk(tw);
+ return true;
+ }
if (node instanceof AST_Conditional) {
node.condition.walk(tw);
push();