}
Map<String, FieldDeclaration> fields = new LinkedHashMap<String, FieldDeclaration>();
for(FieldDeclaration fd : cd.getFields()) {
SephCell anno = fd.getAnnotation(SephCell.class);
if (anno == null) {
continue;
}
String name = fd.getSimpleName();
fields.put(name, fd);
}
ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
out = new PrintStream(bytes);
out.println("/* THIS FILE IS GENERATED. DO NOT EDIT */");
out.println("package seph.lang.bim;");
out.println();
out.println("import java.lang.invoke.*;");
out.println("import seph.lang.*;");
out.println("import seph.lang.persistent.*;");
out.println("import static seph.lang.Types.*;");
out.println("import static seph.lang.ActivationHelpers.*;");
out.println();
out.println("public class " + cd.getSimpleName() + "Base {");
out.println();
for(String parent : parents) {
out.println(" public final static SephObject parent_" + parent + " = " + parent + ".instance;");
}
out.println();
for(String cell : methods.keySet()) {
out.println(" public final static SephObject cell_" + cell + " = getSephMethodHandleObject_" + cell + "();");
}
out.println();
for(String cell : fields.keySet()) {
out.println(" public final static SephObject cell_" + cell + " = " + cell + ".instance;");
}
out.println();
out.println(" public final static Object IDENTITY = new Object();");
out.println();
out.println(" public static SephObject get(String name) {");
out.println(" name = name.intern();");
for(Map.Entry<String,MethodDeclaration> entry : methods.entrySet()) {
String name = entry.getKey();
SephMethod anno = entry.getValue().getAnnotation(SephMethod.class);
if(anno.name().length > 0) {
name = anno.name()[0];
}
out.println(" if(name == \"" + name + "\") return cell_" + entry.getKey() + ";");
}
for(Map.Entry<String,FieldDeclaration> entry : fields.entrySet()) {
SephCell c = entry.getValue().getAnnotation(SephCell.class);
String realName = entry.getKey();
String cell = c.name().length > 0 ? c.name()[0] : realName;
out.println(" if(name == \"" + cell + "\") return cell_" + realName + ";");
}
out.println();
out.println(" SephObject result;");
for(String parent : parents) {