instructions.add(0, new WeaselInstructionInvoke(method.getParentClass().getSuperClass().getRealName()+".<preInit>()"));
}
}else if(method.getName().equals("<init>")){
boolean auto = true;
if(iterator.hasNext()){
WeaselToken token = iterator.next();
if(token!=null && token.tokenType==WeaselTokenType.KEYWORD){
if(iterator.next().tokenType==WeaselTokenType.OPENBRACKET){
try{
if(token.param==WeaselKeyWord.THIS){
superCaller = false;
auto = false;
WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
List<WeaselGenericMethod2> methods = classCompiler.genericClass.getGenericMethodsOfThis("<init>", true);
WeaselParameterCompileReturn wpcr = WeaselTree.compileParamList(token.line, "<init>", compiler, this, tree, methods);
instructions.addAll(wpcr.instructions);
instructions.add(token.line, new WeaselInstructionInvoke(wpcr.method.getMethod().getMethod().getClassNameAndDesk()));
token = iterator.next();
if(token.tokenType!=WeaselTokenType.SEMICOLON)
throw new WeaselCompilerException(token.line, "Expect ; but got %s", token);
}else if(token.param==WeaselKeyWord.SUPER){
superCaller = true;
auto = false;
WeaselTree tree = WeaselTree.parse(iterator, WeaselTokenType.CLOSEBRACKET);
List<WeaselGenericMethod2> methods = classCompiler.genericClass.getGenericSuperClass().getGenericMethodsOfThis("<init>", true);
WeaselParameterCompileReturn wpcr = WeaselTree.compileParamList(token.line, "<init>", compiler, this, tree, methods);
instructions.addAll(wpcr.instructions);
instructions.add(token.line, new WeaselInstructionInvoke(wpcr.method.getMethod().getMethod().getClassNameAndDesk()));
token = iterator.next();
if(token.tokenType!=WeaselTokenType.SEMICOLON)
throw new WeaselCompilerException(token.line, "Expect ; but got %s", token);
}else{
iterator.previous();
iterator.previous();
}
}catch(WeaselCompilerException e){
compiler.addWeaselCompilerMessage(new WeaselCompilerMessage(MessageType.ERROR, e.getLine(), parentClass.getFileName(), e.getMessage()));
iterator.previous();
token = iterator.next();
while(token.tokenType!=WeaselTokenType.SEMICOLON && iterator.hasNext()){
token = iterator.next();
}
}
}else{
iterator.previous();
iterator.previous();
}
}else{
iterator.previous();
}
}
if(auto){
superCaller = true;
if(classCompiler.genericClass.getGenericSuperClass()!=null){
WeaselGenericMethod2 method = classCompiler.genericClass.getGenericSuperClass().getGenericMethodOfThis("<init>()", new WeaselGenericClass[0]);
if(method==null){
compiler.addWeaselCompilerMessage(
new WeaselCompilerMessage(MessageType.ERROR, 0, parentClass.getFileName(),
String.format("No default constructor in %s found", classCompiler.genericClass.getGenericSuperClass())));
}else{
instructions.add(0, new WeaselInstructionInvoke(method.getMethod().getMethod().getClassNameAndDesk()));
}
}
}
}
while(iterator.hasNext()){
try{
instructions.addAll(WeaselTree.parseAndCompile(compiler, this, iterator));
}catch(WeaselCompilerException e){
compiler.addWeaselCompilerMessage(new WeaselCompilerMessage(MessageType.ERROR, e.getLine(), parentClass.getFileName(), e.getMessage()));
iterator.previous();
WeaselToken token = iterator.next();
while(token.tokenType!=WeaselTokenType.SEMICOLON && iterator.hasNext()){
token = iterator.next();
}
}
}