scanf bon

This commit is contained in:
Vu Tuan Minh
2025-04-30 09:59:44 +02:00
parent 20f6170168
commit d4a9b1f71d
8 changed files with 17 additions and 3 deletions

View File

@@ -220,7 +220,12 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
for(int i = 0; i<instr.t().size(); i++){
String nomVar = h.getVar(instr.t().get(i).name());
Type typeVar = h.getType(instr.t().get(i).name());
VarLLVMImp newVar = new VarLLVMImp(typeVar.accept(this,h), nomVar,false);
//Ajout * par passant PointerType
TypeLLVM baseType = typeVar.accept(this, h);
TypeLLVM ptrType = new PointerLLVMImp(baseType);
VarLLVMImp newVar = new VarLLVMImp(ptrType, nomVar,false);
strGlobal+="%d"; //2 char de long
size+=2;
params.add(newVar);

View File

@@ -73,6 +73,7 @@ public interface Interface {
public S visitVoidLLVM(VoidLLVMImp e, H h);
public S visitBooleanLLVM(BooleanLLVMImp e, H h);
public S visitCharLLVM(CharLLVMImp e, H h);
public S visitPointerLLVM(PointerLLVMImp e,H h);
}
}

View File

@@ -215,6 +215,8 @@ TypeLLVMVisitor<String,String>
else return "i8";
}
@Override
public String visitPointerLLVM(PointerLLVMImp e, String h) {
return e.type().accept(this, h) + "*";
}
}

View File

@@ -224,4 +224,10 @@ public class ProgramLLVM {
return v.visitCharLLVM(this, h);
}
}
public static record PointerLLVMImp(TypeLLVM type) implements TypeLLVM{
public <H, S> S accept(TypeLLVMVisitor<H, S> v, H h) {
return v.visitPointerLLVM(this, h);
}
}
}

BIN
tests/fragment1/read0 Executable file

Binary file not shown.

BIN
tests/fragment1/read1 Executable file

Binary file not shown.

BIN
tests/fragment1/read2 Executable file

Binary file not shown.

BIN
tests/testsAdvanced/portee Executable file

Binary file not shown.