block presque bon

This commit is contained in:
trochas
2025-04-10 12:28:25 +02:00
parent 2003331025
commit 0dc3b60d12
2 changed files with 18 additions and 9 deletions

View File

@@ -56,9 +56,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
@Override @Override
public DefineLLVM visitFunction(FunctionImp fun, SymTable h) { public DefineLLVM visitFunction(FunctionImp fun, SymTable h) {
ArrayList<InstructionLLVM> instrLLVM = new ArrayList<>(); ArrayList<InstructionLLVM> instrLLVM = new ArrayList<>();
for(int i = 0; i<fun.instructions().size(); i++){ instrLLVM.addAll(fun.instruction().accept(this, h));
instrLLVM.addAll(fun.instructions().get(i).accept(this, h));
}
return new DefineLLVMImpl(fun.nom(), fun.type().accept(this, h), instrLLVM); return new DefineLLVMImpl(fun.nom(), fun.type().accept(this, h), instrLLVM);
} }
@@ -95,14 +93,25 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
@Override @Override
public ArrayList<InstructionLLVM> visitBloc(BlocImp instr, SymTable h) { public ArrayList<InstructionLLVM> visitBloc(BlocImp instr, SymTable h) {
// TODO Auto-generated method stub ArrayList<InstructionLLVM> instrLLVM = new ArrayList<>();
throw new UnsupportedOperationException("Unimplemented method 'visitBloc'"); for(int i = 0; i<instr.instrs().size(); i++){
instrLLVM.addAll(instr.instrs().get(i).accept(this, h));
}
return instrLLVM;
} }
@Override @Override
public ArrayList<InstructionLLVM> visitBlocDec(BlocDecImp instr, SymTable h) { public ArrayList<InstructionLLVM> visitBlocDec(BlocDecImp instr, SymTable h) {
// TODO Auto-generated method stub ArrayList<InstructionLLVM> instrLLVM = new ArrayList<>();
throw new UnsupportedOperationException("Unimplemented method 'visitBlocDec'"); for(int i = 0; i<instr.decls().size(); i++){
InstrAndSymTable temp = instr.decls().get(i).accept(this, h);
h = temp.symTable;
instrLLVM.addAll(temp.instrs);
}
for(int i = 0; i<instr.instrs().size(); i++){
instrLLVM.addAll(instr.instrs().get(i).accept(this, h));
}
return instrLLVM;
} }
@Override @Override

View File

@@ -33,8 +33,8 @@ public interface Interface {
public S visitPrintLLVM(PrintLLVMImpl instr, H h); public S visitPrintLLVM(PrintLLVMImpl instr, H h);
public S visitReadLLVM(ReadLLVMImpl instr, H h); public S visitReadLLVM(ReadLLVMImpl instr, H h);
public S visitIfThenElseLLVM(IfThenElseImp instr, H h); public S visitIfThenElseLLVM(IfThenElseImp instr, H h);
public S visitIfThenLLVM(IfThenImp instr, H h); //public S visitIfThenLLVM(IfThenImp instr, H h); TODO
public S visitWhileLLVM(WhileImp instr, H h); //public S visitWhileLLVM(WhileImp instr, H h);
} }
//////////ExpressionLLVM (expression) //////////ExpressionLLVM (expression)