X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEConstant.java;h=25cc96019f95175787b63732979b7ce8f4a9bab0;hb=0861b325fcbbfa8c5985f1e11cfc39154a3808d1;hp=a668fe12b1cb036f17c69d477283bf01a0dc488f;hpb=fe1a2f532761669e67da4db4ae15096ced8a04db;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java index a668fe12b..25cc96019 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java @@ -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; + } }