decl_array
This commit is contained in:
@@ -107,8 +107,8 @@ declaration returns [Declaration out]
|
||||
|
||||
var_decl returns [VarDeclImp out]:
|
||||
id=ident
|
||||
(CroO n=NUMBER CroF
|
||||
{$out= new VarDeclImp($id.out,$n.int);}
|
||||
(CroO e=expression CroF
|
||||
{$out= new VarDeclImp($id.out,$e.out);}
|
||||
|
|
||||
{$out= new VarDeclImp($id.out, null);}
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
if(instr.size()==null){
|
||||
str+= instr.nom();
|
||||
}else{
|
||||
str+= instr.nom()+ "["+instr.size()+"]";
|
||||
str+= instr.nom()+ "["+instr.size().accept(this, indent)+"]";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
public static record VarDeclImp(String nom, Integer size) implements Declaration{
|
||||
public static record VarDeclImp(String nom, Expression size) implements Declaration{
|
||||
@Override
|
||||
public <H, S> S accept(DeclVisitor<H, S> v, H h) {
|
||||
return v.visitVarDecl(this, h);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
TypeLLVM t2 = instr.t().accept(this,h);
|
||||
Result r;
|
||||
String nom= instr.s().get(i).nom();
|
||||
Integer size=instr.s().get(i).size();
|
||||
Expression size=instr.s().get(i).size();
|
||||
if(size==null){
|
||||
r= h.addVar(nom,t2);
|
||||
h = r.symTable;
|
||||
|
||||
@@ -231,7 +231,7 @@ public class ProgramLLVM {
|
||||
}
|
||||
}
|
||||
|
||||
public static record ArrayLLVMImp(TypeLLVM type, Integer size) implements TypeLLVM{
|
||||
public static record ArrayLLVMImp(TypeLLVM type, Expression 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