]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java
Property following functions value and possibleValue to ontology modules
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / EConstant.java
index a668fe12b1cb036f17c69d477283bf01a0dc488f..25cc96019f95175787b63732979b7ce8f4a9bab0 100644 (file)
@@ -15,6 +15,8 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.errors.NotPatternException;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.LhsType;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchingLhs;
+import org.simantics.scl.compiler.elaboration.java.DynamicConstructor;
+import org.simantics.scl.compiler.elaboration.macros.MacroRule;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -124,6 +126,14 @@ public class EConstant extends Expression {
             else
                 return value.getExpression().copy().simplify(context);
         }
+        else {
+            MacroRule macroRule = value.getMacroRule();
+            if(macroRule != null) {
+                Expression newExpression = macroRule.inline(context, typeParameters);
+                if(newExpression != null)
+                    return newExpression;
+            }
+        }
         return this;
     }
 
@@ -190,7 +200,7 @@ public class EConstant extends Expression {
             context.recursiveReferences.add(placeholder);
             return placeholder;
         }
-        else if(context.isInPattern()) {
+        else if(context.isInPattern() && value.getValue() != DynamicConstructor.INSTANCE /* HACK!! */) {
             /* This is little hackish code that handles the following kind of constructors:
              *   data Thunk a = Thunk s (a -> s)
              * in
@@ -260,4 +270,9 @@ public class EConstant extends Expression {
         EConstant other = (EConstant)expression;
         return value == other.value && Types.equals(typeParameters, other.typeParameters);
     }
+    
+    @Override
+    public boolean isConstructorApplication() {
+        return true;
+    }
 }