]> gerrit.simantics Code Review - simantics/platform.git/blob
7f1b7ac20f3a5ff54a920c43ce8107fde87dcbd8
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions;
2
3 import org.simantics.scl.compiler.constants.Constant;
4 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
5 import org.simantics.scl.compiler.elaboration.java.VisitBranchPoint;
6 import org.simantics.scl.compiler.environment.Environment;
7 import org.simantics.scl.compiler.internal.codegen.references.IVal;
8 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
9 import org.simantics.scl.compiler.internal.codegen.writer.ModuleWriter;
10 import org.simantics.scl.compiler.types.Types;
11 import org.simantics.scl.runtime.profiling.BranchPoint;
12
13 public class ECoveringBranchPoint extends DecoratingExpression {
14     BranchPoint branchPoint;
15     
16     public ECoveringBranchPoint(Expression expression, BranchPoint branchPoint) {
17         super(expression.location, expression);
18         this.branchPoint = branchPoint;
19     }
20
21     @Override
22     public void accept(ExpressionVisitor visitor) {
23         visitor.visit(this);
24     }
25     
26     @Override
27     public Expression accept(ExpressionTransformer transformer) {
28         return transformer.transform(this);
29     }
30     
31     @Override
32     public IVal toVal(Environment env, CodeWriter w) {
33         ModuleWriter mw = w.getModuleWriter();
34         Constant constant = mw.getExternalConstant(branchPoint, Types.BRANCH_POINT);
35         w.applyWithEffect(location, Types.PROC, Types.UNIT, VisitBranchPoint.INSTANCE, constant);
36         return expression.toVal(env, w);
37     }
38
39     @Override
40     public Expression replace(ReplaceContext context) {
41         return new ECoveringBranchPoint(expression.replace(context), branchPoint);
42     }
43 }