[Swift-commit] r7776 - trunk/src/org/griphyn/vdl/engine
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Thu Apr 17 15:56:54 CDT 2014
Author: hategan
Date: 2014-04-17 15:56:54 -0500 (Thu, 17 Apr 2014)
New Revision: 7776
Modified:
trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
fixed function invocation (bug 1235)
Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java 2014-04-17 20:33:29 UTC (rev 7775)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java 2014-04-17 20:56:54 UTC (rev 7776)
@@ -598,7 +598,7 @@
public void assign(Assign assign, VariableScope scope) throws CompilationException {
try {
XmlObject value = assign.getAbstractExpressionArray(1);
- if (isCall(value)) {
+ if (isProcedureCall(value)) {
Call call = (Call) value;
ActualParameter out = call.addNewOutput();
XmlObject src = assign.getAbstractExpressionArray(0);
@@ -613,30 +613,8 @@
StringTemplate valueST = expressionToKarajan(assign.getAbstractExpressionArray(1), scope, false, lValueType);
- String rValueType = datatype(valueST);
+ checkOrInferReturnedType(varST, valueST);
- if (isAnyType(lValueType)) {
- if (isAnyType(rValueType)) {
- // any <- any
- }
- else {
- // any <- someType, so infer lValueType as rValueType
- setDatatype(varST, rValueType);
- }
- }
- else {
- if (isAnyType(rValueType)) {
- // someType <- any
- // only expressions that are allowed to return 'any' are procedures
- // for example readData(ret, file). These are special procedures that
- // need to look at the return type at run-time.
- }
- else if (!lValueType.equals(rValueType)){
- throw new CompilationException("You cannot assign value of type " + rValueType +
- " to a variable of type " + lValueType);
- }
- }
-
assignST.setAttribute("var", varST);
assignST.setAttribute("value", valueST);
assignST.setAttribute("line", getLine(assign));
@@ -648,16 +626,45 @@
throw new CompilationException("Compile error in assignment at "+assign.getSrc()+": "+re.getMessage(),re);
}
}
-
- private boolean isCall(XmlObject value) {
- Node expressionDOM = value.getDomNode();
- String namespaceURI = expressionDOM.getNamespaceURI();
- String localName = expressionDOM.getLocalName();
- QName expressionQName = new QName(namespaceURI, localName);
- return expressionQName.equals(CALL_EXPR);
+
+ private void checkOrInferReturnedType(StringTemplate varST, StringTemplate valueST) throws CompilationException {
+ String lValueType = datatype(varST);
+ String rValueType = datatype(valueST);
+ if (isAnyType(lValueType)) {
+ if (isAnyType(rValueType)) {
+ // any <- any
+ }
+ else {
+ // any <- someType, so infer lValueType as rValueType
+ setDatatype(varST, rValueType);
+ }
+ }
+ else {
+ if (isAnyType(rValueType)) {
+ // someType <- any
+ // only expressions that are allowed to return 'any' are procedures
+ // for example readData(ret, file). These are special procedures that
+ // need to look at the return type at run-time.
+ }
+ else if (!lValueType.equals(rValueType)){
+ throw new CompilationException("You cannot assign value of type " + rValueType +
+ " to a variable of type " + lValueType);
+ }
+ }
}
-
+
+ private boolean isProcedureCall(XmlObject value) {
+ if (value instanceof Call) {
+ Call call = (Call) value;
+ return proceduresMap.get(call.getProc().getLocalPart()) != null;
+ }
+ else {
+ return false;
+ }
+ }
+
+
private boolean isAnyType(String type) {
return ProcedureSignature.ANY.equals(type);
}
More information about the Swift-commit
mailing list