[Swift-commit] r5108 - trunk/src/org/griphyn/vdl/engine
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Tue Sep 13 16:18:28 CDT 2011
Author: hategan
Date: 2011-09-13 16:18:28 -0500 (Tue, 13 Sep 2011)
New Revision: 5108
Modified:
trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
fixed case issues with procs
Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java 2011-09-13 18:39:57 UTC (rev 5107)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java 2011-09-13 21:18:28 UTC (rev 5108)
@@ -254,7 +254,7 @@
Set<String> procsDefined = new HashSet<String>() ;
for (int i = 0; i < prog.sizeOfProcedureArray(); i++) {
Procedure proc = prog.getProcedureArray(i);
- String procName = proc.getName().toLowerCase();
+ String procName = proc.getName();
if (procsDefined.contains(procName)){
// We have a redefinition error
throw new CompilationException("Illegal redefinition of procedure attempted for " + procName );
@@ -326,7 +326,7 @@
StringTemplate procST = template("procedure");
containingScope.bodyTemplate.setAttribute("procedures", procST);
procST.setAttribute("line", proc.getSrc().substring(proc.getSrc().indexOf(' ') + 1));
- procST.setAttribute("name", proc.getName());
+ procST.setAttribute("name", mangle(proc.getName()));
for (int i = 0; i < proc.sizeOfOutputArray(); i++) {
FormalParameter param = proc.getOutputArray(i);
StringTemplate paramST = parameter(param, innerScope);
@@ -365,7 +365,23 @@
}
}
- public StringTemplate parameter(FormalParameter param, VariableScope scope) throws CompilationException {
+ /**
+ * Convert to a case-insensitive representation by
+ * pre-pending a '^' to upper case letters
+ */
+ private String mangle(String name) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < name.length(); i++) {
+ char c = name.charAt(i);
+ if (Character.isUpperCase(c)) {
+ sb.append('-');
+ }
+ sb.append(Character.toLowerCase(c));
+ }
+ return sb.toString();
+ }
+
+ public StringTemplate parameter(FormalParameter param, VariableScope scope) throws CompilationException {
StringTemplate paramST = new StringTemplate("parameter");
StringTemplate typeST = new StringTemplate("type");
paramST.setAttribute("name", param.getName());
@@ -624,7 +640,7 @@
throw new CompilationException
("Unknown procedure invocation mode "+proc.getInvocationMode());
}
- callST.setAttribute("func", call.getProc().getLocalPart());
+ callST.setAttribute("func", mangle(procName));
/* Does number of input arguments match */
for (int i = 0; i < proc.sizeOfInputArray(); i++) {
if (proc.getInputArray(i).isOptional())
More information about the Swift-commit
mailing list