boolean foundInit = false ;
FieldAttrs fa = new FieldAttrs().setVisibility(Visibility.PUBLIC).setStatic(true) ;
ImmutableCollection<Statement> body = new FIFO<Statement>() ;
for(FieldOrMethod fom: cdecl.decls) {
if (fom instanceof MethodDecl) {
MethodDecl mdd = (MethodDecl)fom ;
if (mdd.name.equals("<clinit>")) {
body = body.insertAll(mdd.body) ;
continue ;
}
try {
MethodDef def = getDef(converter,classPool,cdecl,mdd,fuinfo,fdcls,errors);
if (def.name.equals("<init>")) {
foundInit = true ;
}
cd = cd.addMethod(def) ;
} catch (CompilerException e) {
errors.add(e) ;
}
}
else if (fom instanceof FieldDecl) {
FieldDecl fdecl = (FieldDecl)fom ;
if (fdecl.fieldAttrs.isStatic && fdecl.intializer != null) {
SetValueExpr se = new SetValueExpr(new FieldVarExpr(cname.toString(),fdecl.name,null),fdecl.intializer,null) ;
body = body.insert(new ExprStatement(se,null)) ;
}
}
}
MethodDecl clinit = new MethodDecl(fa,"void","<clinit>",new FIFO<VarDecl>(),new FIFO<String>(),body) ;
if (!foundInit && cdecl.classType != ClassType.INTERFACE) {
FieldAttrs ifa = new FieldAttrs().setVisibility(Visibility.PUBLIC) ;
MethodDecl mdd = new MethodDecl(ifa,"void","<init>",new FIFO<VarDecl>(),new FIFO<String>(),new FIFO<Statement>()) ;
try {
cd = cd.addMethod(getDef(converter,classPool,cdecl,mdd,fuinfo,fdcls,errors)) ;
} catch (CompilerException e) {
errors.add(e) ;
}