tableau update
This commit is contained in:
@@ -104,15 +104,21 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
|||||||
@Override
|
@Override
|
||||||
public InstrAndSymTable visitDeclaration(DeclarationImp instr, SymTable h) {
|
public InstrAndSymTable visitDeclaration(DeclarationImp instr, SymTable h) {
|
||||||
ArrayList<InstructionLLVM> list = new ArrayList<>();
|
ArrayList<InstructionLLVM> list = new ArrayList<>();
|
||||||
/*
|
|
||||||
for(int i = 0; i<instr.s().size();i++){
|
for(int i = 0; i<instr.s().size();i++){
|
||||||
TypeLLVM t2 = instr.t().accept(this,h);
|
TypeLLVM t2 = instr.t().accept(this,h);
|
||||||
Result r = h.addVar(instr.s().get(i),t2);
|
Result r;
|
||||||
String name = r.var;
|
String nom= instr.s().get(i).nom();
|
||||||
|
Integer size=instr.s().get(i).size();
|
||||||
|
if(size==null){
|
||||||
|
r= h.addVar(nom,t2);
|
||||||
|
}else {
|
||||||
|
TypeLLVM arrayType = new ArrayLLVMImp(t2, size);
|
||||||
|
r = h.addVar(nom, arrayType);
|
||||||
|
}
|
||||||
h = r.symTable;
|
h = r.symTable;
|
||||||
list.add(new AssignLLVMImp(new VarLLVMImp(t2, name,false),new allocaLLVMImp(t2)));
|
list.add(new AssignLLVMImp(new VarLLVMImp(t2, nom,false),new allocaLLVMImp(t2)));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return new InstrAndSymTable(list,h);
|
return new InstrAndSymTable(list,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public interface Interface {
|
|||||||
public S visitBooleanLLVM(BooleanLLVMImp e, H h);
|
public S visitBooleanLLVM(BooleanLLVMImp e, H h);
|
||||||
public S visitCharLLVM(CharLLVMImp e, H h);
|
public S visitCharLLVM(CharLLVMImp e, H h);
|
||||||
public S visitPointerLLVM(PointerLLVMImp e,H h);
|
public S visitPointerLLVM(PointerLLVMImp e,H h);
|
||||||
|
public S visitArrayLLVM(ArrayLLVMImp e, H h);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,4 +219,9 @@ TypeLLVMVisitor<String,String>
|
|||||||
public String visitPointerLLVM(PointerLLVMImp e, String h) {
|
public String visitPointerLLVM(PointerLLVMImp e, String h) {
|
||||||
return e.type().accept(this, h) + "*";
|
return e.type().accept(this, h) + "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitArrayLLVM(ArrayLLVMImp e, String h){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,4 +230,10 @@ public class ProgramLLVM {
|
|||||||
return v.visitPointerLLVM(this, h);
|
return v.visitPointerLLVM(this, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static record ArrayLLVMImp(TypeLLVM type, Integer size) implements TypeLLVM{
|
||||||
|
public <H,S> S accept(TypeLLVMVisitor<H, S> v, H h) {
|
||||||
|
return v.visitArrayLLVM(this, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user