boolean hasAnonymousClassDeclaration = false;
// only static fields
for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCVariableDecl){
JCVariableDecl f = (JCVariableDecl)tr;
hasAnonymousClassDeclaration |= anonymousTester.test(f);
if(!isStatic(f.getModifiers())) continue;
if(null==f.getInitializer() || "null".equals(f.getInitializer().toString())) continue;
cl.selfPrefix = getObfuscatedName(cl.name)+ ".";
// parse(f.getName());
String fName = f.getName().toString();
// if("name".equals(fName)) fName = "__name";
code.append(cl.selfPrefix + getObfuscatedName(fName) + (obfuscate ? "=" : " = "));
parse(f.getInitializer());
code.append(";\n");
}
code.append(getObfuscatedName(cl.name) + ".prototype."+getObfuscatedName(cl.name+"_initInstanceFields") + " = function()" + ifObfuscated("{", " {\n"));
if(null!=superType && classes.containsKey(superType) && !classes.get(superType).isNative) {
code.append("this."+getObfuscatedName(superType+"_initInstanceFields") + "();" + ifObfuscated("", "\n"));
}
// only NOT static fields
if(hasAnonymousClassDeclaration) {
code.append("var "+(cl.selfPrefix = getObfuscatedName("self"))+" = this;\n");
} else cl.selfPrefix = "this";
for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCVariableDecl){
JCVariableDecl f = (JCVariableDecl)tr;
if(isStatic(f.getModifiers())) continue;
if(null==f.getInitializer() || "null".equals(f.getInitializer().toString())) continue;
//cl.selfPrefix = "this";
parse(f.getName());
code.append(obfuscate ? "=" : " = ");
parse(f.getInitializer());
code.append(";\n");
}
code.append("}\n");