return new FunctionDef(new NameTok(NodeHelper.KEYWORD_INIT, NameTok.FunctionName), args,
body.toArray(new stmtType[0]), null, null);
}
private Expr extractConstructorInit(IClassDefAdapter base) {
FunctionDefAdapter init = base.getFirstInit();
if (init != null) {
if (!init.getArguments().hasOnlySelf()) {
Attribute classInit = new Attribute(new Name(moduleAdapter.getBaseContextName(this.classAdapter,
base.getName()), Name.Load, false), new NameTok(NodeHelper.KEYWORD_INIT, NameTok.Attrib),
Attribute.Load);
List<exprType> constructorParameters = init.getArguments().getSelfFilteredArgs();
Name selfArg = new Name(NodeHelper.KEYWORD_SELF, Name.Load, false);
constructorParameters.add(0, selfArg);
exprType[] argExp = constructorParameters.toArray(new exprType[0]);
Name varArg = null;
Name kwArg = null;
if (init.getArguments().hasVarArg()) {
varArg = new Name(ARGS, Name.Load, false);
}
if (init.getArguments().hasKwArg()) {
kwArg = new Name(KWARGS, Name.Load, false);
}
Call initCall = new Call(classInit, argExp, null, varArg, kwArg);
return new Expr(initCall);