[Swift-commit] r5022 - trunk/src/org/griphyn/vdl/engine

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Mon Aug 29 19:23:33 CDT 2011


Author: hategan
Date: 2011-08-29 19:23:33 -0500 (Mon, 29 Aug 2011)
New Revision: 5022

Modified:
   trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
patch from Yadu to complain when procedures are re-defined

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2011-08-29 21:33:40 UTC (rev 5021)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2011-08-30 00:23:33 UTC (rev 5022)
@@ -250,12 +250,20 @@
 	private void processProcedures(Program prog, VariableScope scope) throws CompilationException {
 
 		// Keep track of declared procedures
+	    // Check for redefinitions of existing procedures
+	    Set<String> procsDefined = new HashSet<String>() ;	    
 		for (int i = 0; i < prog.sizeOfProcedureArray(); i++) {
 			Procedure proc = prog.getProcedureArray(i);
-			ProcedureSignature ps = new ProcedureSignature(proc.getName());
+			String procName = proc.getName().toLowerCase();
+			if (procsDefined.contains(procName)){
+			    // We have a redefinition error
+			    throw new CompilationException("Illegal redefinition of procedure attempted for " + procName );
+			}
+			procsDefined.add(procName);
+			ProcedureSignature ps = new ProcedureSignature(procName);
 			ps.setInputArgs(proc.getInputArray());
 			ps.setOutputArgs(proc.getOutputArray());
-			proceduresMap.put(proc.getName(), ps);
+			proceduresMap.put(procName, ps);
 		}
 
 		for (int i = 0; i < prog.sizeOfProcedureArray(); i++) {




More information about the Swift-commit mailing list