]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERecord.java
Merge "Minor refactorings related to SCL constructors"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / ERecord.java
index a859782239caac40c50cf91e34935b43aa303b7e..47ef205df17cbce0d9ff1d74dd8f1154adc1bcfa 100644 (file)
@@ -37,7 +37,7 @@ public class ERecord extends ASTExpression {
     public Expression resolve(TranslationContext context, boolean asPattern) {
         SCLValue constructorValue; 
         try {
-            constructorValue = context.getEnvironment().getLocalNamespace().getValue(constructor.name);
+            constructorValue = context.resolveRecordConstructor(location, constructor.name);
         } catch (AmbiguousNameException e) {
             context.getErrorLog().log(constructor.location, e.getMessage());
             return new EError(constructor.location);
@@ -46,16 +46,12 @@ public class ERecord extends ASTExpression {
             context.getErrorLog().log(constructor.location, "Couldn't resolve the record constructor " + constructor.name + ".");
             return new EError(constructor.location);
         }
-        if(!(constructorValue.getValue() instanceof SCLConstructor)) {
+        String[] parameterNames = constructorValue.parameterNames;
+        if(parameterNames == null) {
             context.getErrorLog().log(constructor.location, "Value " + constructor.name + " is not a record constructor.");
             return new EError(constructor.location);
         }
-        String[] fieldNames = ((SCLConstructor)constructorValue.getValue()).recordFieldNames;
-        if(fieldNames == null) {
-            context.getErrorLog().log(constructor.location, "Value " + constructor.name + " is not a record constructor.");
-            return new EError(constructor.location);
-        }
-        Expression[] parameters = translateFieldsToFunctionParameters(context, fields, fieldNames, false);
+        Expression[] parameters = translateFieldsToFunctionParameters(context, fields, parameterNames, false);
         if(parameters == null)
             return new EError(location);
         if(asPattern)
@@ -73,7 +69,7 @@ public class ERecord extends ASTExpression {
                 if(parameter == null) {
                     ExistentialFrame frame = context.getCurrentExistentialFrame();
                     if(frame == null || frame.disallowNewExistentials) {
-                        context.getErrorLog().log(location, "Field " + fieldNames[i] + " not defined.");
+                        context.getErrorLog().log(location, "Field " + parameterNames[i] + " not defined.");
                         error = true;
                     }
                     else