Decorators decorators = (Decorators) stack.popNode();
if (def instanceof ClassDef) {
ClassDef classDef = (ClassDef) def;
classDef.decs = decorators.exp;
} else {
FunctionDef fDef = (FunctionDef) def;
fDef.decs = decorators.exp;
}
return def;
case JJTCALL_OP:
exprType starargs = null;
exprType kwargs = null;
java.util.List<exprType> args = new ArrayList<exprType>();
java.util.List<keywordType> keywords = new ArrayList<keywordType>();
for (int i = arity - 2; i >= 0; i--) {
SimpleNode node = stack.popNode();
if (node instanceof keywordType) {
keywords.add(0, (keywordType) node);
} else if (node.getId() == JJTEXTRAARGVALUELIST) {
ExtraArgValue nstarargs = (ExtraArgValue) node;
starargs = nstarargs.value;
this.addSpecialsAndClearOriginal(nstarargs, starargs);
} else if (node.getId() == JJTEXTRAKEYWORDVALUELIST) {
ExtraArgValue nkwargs = (ExtraArgValue) node;
kwargs = nkwargs.value;
this.addSpecialsAndClearOriginal(nkwargs, kwargs);
} else if (node instanceof ComprehensionCollection) {
//what can happen is something like print sum(x for x in y), where we have already passed x in the args, and then get 'for x in y'
args.add(
0,
new ListComp((exprType) stack.popNode(), ((ComprehensionCollection) node)
.getGenerators(), ListComp.EmptyCtx));
i--; //popped node
} else {
args.add(0, (exprType) node);
}
}
exprType func = (exprType) stack.popNode();
Call c = new Call(func, args.toArray(new exprType[args.size()]),
keywords.toArray(new keywordType[keywords.size()]), starargs, kwargs);
addSpecialsAndClearOriginal(n, c);
return c;
case JJTFUNCDEF:
suite = (Suite) stack.popNode();
body = suite.body;
argumentsType arguments = makeArguments(stack.nodeArity() - 1);
NameTok nameTok = makeName(NameTok.FunctionName);
//decorator is always null at this point... it's decorated later on
FunctionDef funcDef = new FunctionDef(nameTok, arguments, body, null, null);
addSpecialsAndClearOriginal(suite, funcDef);
setParentForFuncOrClass(body, funcDef);
return funcDef;
case JJTDEFAULTARG:
value = (arity == 1) ? null : ((exprType) stack.popNode());