staticMethodBodys = new WeaselMethodBody[ids.staticMethod];
if(!isInterface())
methodBodys = new WeaselMethodBody[ids.method];
fields = new WeaselField[0];
methods[0] = createMethod("<staticInit>", WeaselModifier.STATIC, this, new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], ids.staticMethod-1);
staticMethodBodys[ids.staticMethod-1] = new WeaselMethodBodyCompilerV2(methods[0], this, classStaticInit, new ArrayList<String>(), new ArrayList<Integer>(), compiler);
if(!isInterface()){
methods[1] = createMethod("<preInit>", 0, this, new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], 0);
methodBodys[0] = new WeaselMethodBodyCompilerV2(methods[1], this, classPreInit, new ArrayList<String>(), new ArrayList<Integer>(), compiler);
}
if(isEnum){
try {
token = readEnumConstants(token);
} catch (WeaselCompilerException e) {
onException(e);
while(getNextToken().tokenType!=WeaselTokenType.SEMICOLON);
}
}
while(token.tokenType!=WeaselTokenType.CLOSEBLOCK&&token.tokenType!=WeaselTokenType.NONE){
try{
setNextToken(token);
modifiers = readModifier();
token = getNextToken();
//WeaselGenericInformation[] genericInformations = makeGenericInformations(token);
//token = getNextToken();
String name;
boolean isConstructor=token.tokenType == WeaselTokenType.IDENT && token.param.equals(this.name);
if(isConstructor){
WeaselToken token2 = getNextToken();
if(token2.tokenType!=WeaselTokenType.OPENBRACKET){
isConstructor = false;
}
setNextToken(token2);
}
WeaselGenericClassInfo typeInfo;
if(isConstructor){
if(isInterface)
onException(token.line, "Interface can't have a constructor");
//if(genericInformations.length>0)
//onException(token.line, "Constructor can't have generic informations");
typeInfo = new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]);
name = "<init>";
typeInfo = new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]);
}else{
ListIterator<WeaselToken> iterator;
typeInfo = readGenericClass(token, iterator=tokenParser.listIterator());
WeaselCompiler.expect(token = iterator.next(), WeaselTokenType.IDENT);
name = (String)token.param;
if(name.equals("operator")){
WeaselCompiler.expect(token = getNextToken(), WeaselTokenType.OPERATOR, WeaselTokenType.COMMA);
name += ((Properties)token.param).operator;
}
}
token = getNextToken();
if(isConstructor){
WeaselCompiler.expect(token, WeaselTokenType.OPENBRACKET);
try{
compileMethod(modifiers, typeInfo, name, token, new WeaselGenericInformation[0]);
}catch(WeaselCompilerException e){
onException(e);
}
}else{
if(token.tokenType==WeaselTokenType.OPENBRACKET){
try{
compileMethod(modifiers, typeInfo, name, token, new WeaselGenericInformation[0]);
}catch(WeaselCompilerException e){
onException(e);
}
}else{
//if(genericInformations.length>0)
// onException(token.line, "Fields can't have generic informations");
try{
compileField(modifiers, typeInfo, name, token);
}catch(WeaselCompilerException e){
onException(e);
}
}
}
token = getNextToken();
}catch(WeaselCompilerException e){
onException(e);
token = getNextToken();
}
}
try {
WeaselCompiler.expect(token, WeaselTokenType.CLOSEBLOCK);
WeaselCompiler.expect(getNextToken(), WeaselTokenType.NONE);
} catch (WeaselCompilerException e) {
onException(e);
}
tokenParser = null;
if(!isInterface()){
boolean hasConstructor = false;
for(int i=0; i<methods.length; i++){
if(methods[i].getName().equals("<init>")){
hasConstructor = true;
break;
}
}
if(!hasConstructor){
System.out.println("ADDCONSTRUCTOR to "+name);
int id = ids.method++;
WeaselMethod method = createMethod("<init>", isEnum?0:WeaselModifier.PUBLIC, this, new WeaselGenericClassInfo(compiler.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], id);
System.out.println(method);
WeaselMethod[] newMethods = new WeaselMethod[methods.length+1];
for(int i=0; i<methods.length; i++){
newMethods[i] = methods[i];
}