_f_const = clazz.createField("_const", "[Lanvil/core/Any;", ACC_PUBLIC|ACC_STATIC|ACC_FINAL);
_f_text = clazz.createField("_text", "[[B", ACC_PUBLIC|ACC_STATIC|ACC_FINAL);
_f_switch = clazz.createField("_switch", "[Lanvil/java/util/Hashlist;", ACC_PUBLIC|ACC_STATIC|ACC_FINAL);
Method _m_const = clazz.createMethod("_const", "()V", ACC_PUBLIC|ACC_STATIC);
Method _m_text = clazz.createMethod("_text", "()V", ACC_PUBLIC|ACC_STATIC);
Method _m_switch = clazz.createMethod("_switch", "()V", ACC_PUBLIC|ACC_STATIC);
Method _m_symbols = clazz.createMethod("_symbols", "()V", ACC_PUBLIC|ACC_STATIC);
//Method _m_imports = clazz.createMethod("_imports", "()V", ACC_PUBLIC|ACC_STATIC);
code = clazz.getStatic().getCode();
//code.println("MODULE-START:"+classsig);
code.invokestatic(_m_const.getIndex());
code.invokestatic(_m_text.getIndex());
code.invokestatic(_m_switch.getIndex());
code.invokestatic(_m_symbols.getIndex());
((anvil.script.statements.ModuleStatement)getModule()).compile(this);
//code.println("MODULE-END:"+classsig);
code.vreturn();
/* constants */
code = _m_const.getCode();
if (_constants.size() > 0) {
code.iconst(_constants.size());
code.anewarray(TYPE_ANY);
Enumeration e = _constants.keys();
for(int i=0; e.hasMoreElements(); i++) {
code.dup();
code.iconst(i);
((Any)e.nextElement()).toCode(code);
code.aastore();
}
code.putstatic(_f_const);
}
code.vreturn();
/* texts */
code = _m_text.getCode();
int getBytes = pool.addMethodRef("anvil/util/Conversions", "getBytes", "(Ljava/lang/String;)[B");
if (_texts.size() > 0) {
int size = _texts.size();
code.iconst(size);
code.anewarray("[[B", 1);
Enumeration e = _texts.keys();
for(int i=0; e.hasMoreElements(); i++) {
code.dup();
code.iconst(i);
code.astring((String)e.nextElement());
code.invokestatic(getBytes);
code.aastore();
}
code.putstatic(_f_text);
}
code.vreturn();
/* switchtables */
code = _m_switch.getCode();
int n = _switches.size();
if (_switches.size() > 0 ) {
int hashlistclazz = pool.addClass("anvil/java/util/Hashlist");
int hashlistctor = pool.addMethodRef(hashlistclazz, "<init>", "()V");
int hashlistadd = pool.addMethodRef(hashlistclazz, "add",
"(Ljava/lang/Object;Ljava/lang/Object;)Lanvil/java/util/Hashlist;");
int intclazz = pool.addClass("java/lang/Integer");
int intclazzctor = pool.addMethodRef(intclazz, "<init>", "(I)V");
code.iconst(n);
code.anewarray(hashlistclazz);
for(int i=0; i<n; i++) {
code.dup();
code.iconst(i);
code.anew(hashlistclazz);
code.dup();
code.invokespecial(hashlistctor);
int c = 0;
Enumeration keys = (Enumeration)_switches.elementAt(i);
while(keys.hasMoreElements()) {
Any key = (Any)keys.nextElement();
if (key != SwitchStatement.DEFAULT_MARKER) {
key.toCode(code);
code.anew(intclazz);
code.dup();
code.iconst(c++);
code.invokespecial(intclazzctor);
code.invokevirtual(hashlistadd);
}
}
code.aastore();
}
code.putstatic(_f_switch);
}
code.vreturn();
/* methodindices */
code = _m_symbols.getCode();
if (_symbols.size() > 0) {
int register = pool.addMethodRef(pool.addClass("anvil/core/Register"),
"register", "(Ljava/lang/String;)I");
BindingEnumeration e = _symbols.keysAndElements();
while(e.hasMoreElements()) {