[Swift-commit] r2666 - trunk/src/org/griphyn/vdl/engine
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Mon Mar 9 11:03:35 CDT 2009
Author: hategan
Date: 2009-03-09 11:03:35 -0500 (Mon, 09 Mar 2009)
New Revision: 2666
Modified:
trunk/src/org/griphyn/vdl/engine/Karajan.java
trunk/src/org/griphyn/vdl/engine/VariableScope.java
Log:
fixed nested procedure calls causing variable redefinition error
Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java 2009-03-09 15:23:13 UTC (rev 2665)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java 2009-03-09 16:03:35 UTC (rev 2666)
@@ -1131,7 +1131,7 @@
StringTemplate call = template("callexpr");
String type = funcSignature.getOutputArray(0).getType();
- subscope.addVariable("swift#callintermediate", type);
+ subscope.addInternalVariable("swift#callintermediate", type);
call.setAttribute("datatype", type);
call.setAttribute("call", call(c, subscope, true));
Modified: trunk/src/org/griphyn/vdl/engine/VariableScope.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/VariableScope.java 2009-03-09 15:23:13 UTC (rev 2665)
+++ trunk/src/org/griphyn/vdl/engine/VariableScope.java 2009-03-09 16:03:35 UTC (rev 2666)
@@ -91,8 +91,24 @@
varTypes.put(name, type);
if(!added) throw new CompilationException("Could not add variable "+name+" to scope.");
}
+
+ /**
+ * Does pretty much the same as addVariable() except it doesn't throw
+ * an exception if the variable is defined in a parent scope
+ */
+ public void addInternalVariable(String name, String type) throws CompilationException {
+ logger.info("Adding internal variable " + name + " of type " + type + " to scope " + hashCode());
+
+ if(isVariableLocallyDefined(name)) {
+ throw new CompilationException("Variable " + name + " is already defined.");
+ }
+ boolean added = variables.add(name);
+ varTypes.put(name, type);
+ if(!added) throw new CompilationException("Could not add variable "+name+" to scope.");
+ }
+
public boolean isVariableDefined(String name) {
if(isVariableLocallyDefined(name)) return true;
if(parentScope != null && parentScope.isVariableDefined(name)) return true;
More information about the Swift-commit
mailing list