]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/top/ExpressionEvaluator.java
Collect reference hierarchy for SCL values
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / top / ExpressionEvaluator.java
index a5b9a65417e79e095acc83149f49d40ffa47690d..36994d136533435522642855fdf5a8817203fd57 100644 (file)
@@ -42,7 +42,6 @@ import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.internal.codegen.writer.ExternalConstant;
 import org.simantics.scl.compiler.internal.codegen.writer.ModuleWriter;
 import org.simantics.scl.compiler.internal.elaboration.decomposed.DecomposedExpression;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
 import org.simantics.scl.compiler.internal.interpreted.IExpression;
 import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException;
 import org.simantics.scl.compiler.internal.parsing.parser.SCLBlockParser;
@@ -270,7 +269,7 @@ public class ExpressionEvaluator {
         
         // Elaboration
         {
-            TranslationContext context = new TranslationContext(compilationContext, localEnvironment);
+            TranslationContext context = new TranslationContext(compilationContext, localEnvironment, "expression");
             expression = expression.resolve(context);
             if(!errorLog.hasNoErrors())
                 throw new SCLExpressionCompilationException(errorLog.getErrors());
@@ -300,9 +299,9 @@ public class ExpressionEvaluator {
             if(!errorLog.hasNoErrors())
                 throw new SCLExpressionCompilationException(errorLog.getErrors());
             if(decorateExpression && Types.canonical(expectedEffect) != Types.NO_EFFECTS) {
-                ExpressionDecorator decorator =
+                ToplevelEffectDecorator decorator =
                         new ToplevelEffectDecorator(errorLog, environment);
-                expression = expression.decorate(decorator);
+                expression = expression.accept(decorator);
             }
             expression = context.solveConstraints(environment, expression);
             expressionType = expression.getType();
@@ -367,7 +366,7 @@ public class ExpressionEvaluator {
         // Convert to SSA
         ModuleWriter mw = new ModuleWriter(namingPolicy.getModuleClassName());
         DecomposedExpression decomposed = 
-                DecomposedExpression.decompose(expression);
+                DecomposedExpression.decompose(errorLog, expression);
 
         SCLConstant constant = new SCLConstant(
                 Name.create(moduleName, COMPUTATION_METHOD_NAME),
@@ -388,7 +387,7 @@ public class ExpressionEvaluator {
             IVal[] parameterVals = w.getParameters();
             for(int i=0;i<decomposed.parameters.length;++i)
                 decomposed.parameters[i].setVal(parameterVals[i]);
-            w.return_(decomposed.body.toVal(environment, w));
+            w.return_(decomposed.body.toVal(compilationContext, w));
         } catch(RuntimeException e) {
             errorLog.setExceptionPosition(expression.location);
             throw new SCLExpressionCompilationException(errorLog.getErrors());
@@ -430,6 +429,7 @@ public class ExpressionEvaluator {
             throw new SCLExpressionCompilationException(errorLog.getErrors());
         }
         Map<String, byte[]> classes = moduleBuilder.getClasses();
+        ssaModule.cleanup();
         
         // Load generated code and execute
         try {