for (HStatement stmt : getStatements()){
if (stmt instanceof HVarDeclStatement){
HVarDeclStatement s = (HVarDeclStatement) stmt;
HType oldType = tenv.add(s.getVarName(), HType.STRING_TYPE);
if (oldType != null)
throw new HampiException("multiply defined variable " + s.getVarName());
}
if (stmt instanceof CFGStatement){
CFGStatement s = (CFGStatement) stmt;
HType oldType = tenv.add(s.getVarName(), HType.CFG_TYPE);
if (oldType != null)
throw new HampiException("multiply defined variable " + s.getVarName());
}
if (stmt instanceof HRegDeclStatement){
HRegDeclStatement s = (HRegDeclStatement) stmt;
HType oldType = tenv.add(s.getVarName(), HType.REG_TYPE);
if (oldType != null)
throw new HampiException("multiply defined variable " + s.getVarName());
}
if (stmt instanceof HValDeclStatement){
HValDeclStatement s = (HValDeclStatement) stmt;
HType oldType = tenv.add(s.getVarName(), s.getExpression().getType(tenv));
if (oldType != null)
throw new HampiException("multiply defined variable " + s.getVarName());
}
}
return tenv;
}