print read et SymTable
This commit is contained in:
@@ -26,11 +26,11 @@ public interface Interface {
|
||||
}
|
||||
|
||||
public interface InstructionLLVMVisitor<H,S> {
|
||||
public S visitReturnLLVM(ReturnLLVMImp instr, H h);
|
||||
public S visitAssignLLVM(AssignLVMImp instr, H h);
|
||||
public S visitStoreLLVM(StoreLLVMImp instr, H h);
|
||||
public S visitPrintLLVM(PrintLLVMImp instr, H h);
|
||||
public S visitReadLLVM(ReadLLVMImp instr, H h);
|
||||
public S visitReturnLLVM(ReturnLLVMImpl instr, H h);
|
||||
public S visitAssignLLVM(AssignLVMImpl instr, H h);
|
||||
public S visitStoreLLVM(StoreLLVMImpl instr, H h);
|
||||
public S visitPrintLLVM(PrintLLVMImpl instr, H h);
|
||||
public S visitReadLLVM(ReadLLVMImpl instr, H h);
|
||||
}
|
||||
|
||||
//////////ExpressionLLVM (expression)
|
||||
@@ -43,7 +43,7 @@ public interface Interface {
|
||||
}
|
||||
|
||||
public interface ExpressionLLVMVisitor<H,S> {
|
||||
public S visitBinOpLLVM(BinOpLLVMImp e, H h);
|
||||
public S visitBinOpLLVM(BinOpLLVMImpl e, H h);
|
||||
public S visitAllocaLLVM(allocaLLVMImpl e,H h);
|
||||
public S visitLoadLLVM(loadLLVMImpl e,H h);
|
||||
public S visitValLLVM(ValLLVMImpl e,H h);
|
||||
|
||||
@@ -51,17 +51,17 @@ TypeLLVMVisitor<String,String>
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitReturnLLVM(ReturnLLVMImp instr, String h) {
|
||||
public String visitReturnLLVM(ReturnLLVMImpl instr, String h) {
|
||||
return INDENT+"ret " + instr.type().accept(this, h) + " " + instr.e().accept(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitAssignLLVM(AssignLVMImp instr, String h) {
|
||||
public String visitAssignLLVM(AssignLVMImpl instr, String h) {
|
||||
return INDENT+instr.var().accept(this, h) + " = " + instr.e().accept(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitBinOpLLVM(BinOpLLVMImp e, String h) {
|
||||
public String visitBinOpLLVM(BinOpLLVMImpl e, String h) {
|
||||
String str = "";
|
||||
switch(e.op()){
|
||||
case PLUS:
|
||||
@@ -91,24 +91,25 @@ TypeLLVMVisitor<String,String>
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitStoreLLVM(StoreLLVMImp instr, String h) {
|
||||
public String visitStoreLLVM(StoreLLVMImpl instr, String h) {
|
||||
return INDENT+"store " + instr.valType().accept(this, "") + " " + instr.e().accept(this, "") + ", " + instr.varType().accept(this, "") + "* " + instr.var().accept(this,"");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String visitLoadLLVM(loadLLVMImpl e, String h) {
|
||||
return "load" + " i" + e.nbBits() + ", i"+ e.nbBits2() + "* %" + e.val().accept(this, h);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String visitPrintLLVM(PrintLLVMImp instr, String h) {
|
||||
return INDENT+"print";
|
||||
public String visitPrintLLVM(PrintLLVMImpl instr, String h) {
|
||||
return INDENT+"call " + "...TODO..." +" printf " + "...TODO...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitReadLLVM(ReadLLVMImp instr, String h) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'visitReadLLVM'");
|
||||
public String visitReadLLVM(ReadLLVMImpl instr, String h) {
|
||||
return INDENT+"call " + "...TODO..." +" scanf " + "...TODO...";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,35 +40,35 @@ public class ProgramLLVM {
|
||||
*/
|
||||
|
||||
|
||||
public static record AssignLVMImp(VarLLVMImpl var, ExpressionLLVM e) implements InstructionLLVM{
|
||||
public static record AssignLVMImpl(VarLLVMImpl var, ExpressionLLVM e) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitAssignLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record ReturnLLVMImp(TypeLLVM type, ExpressionLLVM e) implements InstructionLLVM{
|
||||
public static record ReturnLLVMImpl(TypeLLVM type, ExpressionLLVM e) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitReturnLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record StoreLLVMImp(TypeLLVM valType, ExpressionLLVM e,TypeLLVM varType, ValLLVM var) implements InstructionLLVM{
|
||||
public static record StoreLLVMImpl(TypeLLVM valType, ExpressionLLVM e,TypeLLVM varType, ValLLVM var) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitStoreLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record PrintLLVMImp(ArrayList<String> l) implements InstructionLLVM{
|
||||
public static record PrintLLVMImpl(ArrayList<Object> l) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitPrintLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record ReadLLVMImp(ArrayList<String> l) implements InstructionLLVM{
|
||||
public static record ReadLLVMImpl(ArrayList<VarLLVMImpl> l) implements InstructionLLVM{
|
||||
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
@@ -78,7 +78,7 @@ public class ProgramLLVM {
|
||||
}
|
||||
|
||||
//Expression :
|
||||
public static record BinOpLLVMImp(TypeLLVM type,Op op, ValLLVM val1,ValLLVM val2) implements ExpressionLLVM{
|
||||
public static record BinOpLLVMImpl(TypeLLVM type,Op op, ValLLVM val1,ValLLVM val2) implements ExpressionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(ExpressionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitBinOpLLVM(this, h);
|
||||
|
||||
Reference in New Issue
Block a user