1 package org.simantics.scl.compiler.elaboration.expressions;
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;
13 public class ECoveringBranchPoint extends DecoratingExpression {
14 BranchPoint branchPoint;
16 public ECoveringBranchPoint(Expression expression, BranchPoint branchPoint) {
17 super(expression.location, expression);
18 this.branchPoint = branchPoint;
22 public void accept(ExpressionVisitor visitor) {
27 public Expression accept(ExpressionTransformer transformer) {
28 return transformer.transform(this);
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);
40 public Expression replace(ReplaceContext context) {
41 return new ECoveringBranchPoint(expression.replace(context), branchPoint);