@Override
public void compileEasy() {
compiler.addWeaselCompilerMessage(new WeaselCompilerMessage(MessageType.INFO, 0, getFileName(), "Compiling Class"));
List<WeaselToken> modifiers = readModifier();
WeaselToken token = getNextToken();
try{
WeaselCompiler.expectKeyWord(token, WeaselKeyWord.CLASS, WeaselKeyWord.INTERFACE, WeaselKeyWord.ENUM);
}catch(WeaselCompilerException e){
onException(e);
}
boolean isEnum = token.param == WeaselKeyWord.ENUM;
isInterface = token.param == WeaselKeyWord.INTERFACE;
boolean isClass = !(isEnum||isInterface);
modifier = getModifier(modifiers, isEnum?enumModifier:isInterface?interfaceModifier:classModifier);
modifiers = null;
if(isInterface)
modifier |= WeaselModifier.ABSTRACT;
if(isEnum)
modifier |= WeaselModifier.FINAL;
token = getNextToken();
try{
WeaselCompiler.expect(token, WeaselTokenType.IDENT);
if(!name.equals(token.param)){
onException(token.line, "ClassFile name %s and classname %s is not epual", name, token.param);
}
}catch(WeaselCompilerException e){
onException(e);
}
token = getNextToken();
if(isEnum){
genericInformation = new WeaselGenericInformation[0];
}else{
try{
genericInformation = makeGenericInformations(token);
}catch(WeaselCompilerException e){
onException(e);
}
token = getNextToken();
}
genericInterfaces = new WeaselGenericClassInfo[0];
try{
if(isClass){
token = readClassHead(token);
}
if(isInterface){
token = readInterfaceHead(token);
}
if(isEnum){
token = readEnumHead(token);
}
WeaselCompiler.expect(token, WeaselTokenType.OPENBLOCK);
}catch(WeaselCompilerException e){
onException(e);
while(getNextToken().tokenType!=WeaselTokenType.OPENBLOCK);
}
token = getNextToken();
ids.staticMethod++;
methods = new WeaselMethod[isInterface()?1:2];
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);
}