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