/** * Declare fields in the parent's (partial) class. * * @param context the parent (class) context. * @param partial the code emitter (basically an abstraction for producing the partial class). */ public void preAnalyze(Context context, CLEmitter partial) { // Fields may not be declared abstract. if (mods.contains("abstract")) { JAST.compilationUnit.reportSemanticError(line(), "Field cannot be declared abstract"); } for (JVariableDeclarator decl : decls) { // Add field to (partial) class decl.setType(decl.type().resolve(context)); partial.addField(mods, decl.name(), decl.type().toDescriptor(), false); } }
/** * Code generation for field declaration involves generate field the header. * * @param output the code emitter (basically an abstraction for producing the .class file). */ public void codegen(CLEmitter output) { for (JVariableDeclarator decl : decls) { // Add field to class output.addField(mods, decl.name(), decl.type().toDescriptor(), false); } }