diff --git a/src/ts/Sa2ts.java b/src/ts/Sa2ts.java index 238982db82e3bd7e4674caf6c1bca0ad005ff6fa..0620ea116233f06ebd67f91f07dab77ea032b652 100644 --- a/src/ts/Sa2ts.java +++ b/src/ts/Sa2ts.java @@ -88,25 +88,23 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> { } - public Void visit(SaDecVarSimple node) { - boolean isGlobal = false; - if (tableLocaleCourante.getVar(node.getNom()) != null) { - if (tableGlobale.getVar(node.getNom()) != null) { - throw new RuntimeException("Erreur"); - } else { - isGlobal = true; + public Void visit(SaVarSimple node) throws Exception { + defaultIn(node); + if (tableLocaleCourante.getVar(node.getNom()) != null){ + if (tableLocaleCourante.getVar(node.getNom()).getTaille() != 1) throw new ErrorException(Error.TS,"Var not find"); + node.tsItem = (TsItemVarSimple) tableLocaleCourante.getVar(node.getNom()); + } + else if (tableGlobale.getVar(node.getNom()) != null){ + if (tableGlobale.getVar(node.getNom()).getTaille() != 1) throw new ErrorException(Error.TS,"Var not find"); + node.tsItem = (TsItemVarSimple) tableGlobale.getVar(node.getNom()); + } + else { + throw new ErrorException(Error.TS,"Var not find"); } + defaultOut(node); + return super.visit(node); } - TsItemVar tsItemVar; - if(isGlobal){ - tsItemVar = tableGlobale.getVar(node.getNom()); - }else{ - tsItemVar = tableLocaleCourante.getVar(node.getNom()); - } - node.tsItem = tsItemVar; - return null; - } public Void visit(SaVarIndicee node) throws Exception { defaultIn(node); if(tableGlobale.getVar(node.getNom()) != null){