package org.simantics.scl.compiler.elaboration.expressions; import org.simantics.scl.compiler.constants.Constant; import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; import org.simantics.scl.compiler.elaboration.java.VisitBranchPoint; import org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.internal.codegen.writer.ModuleWriter; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.runtime.profiling.BranchPoint; public class ECoveringBranchPoint extends DecoratingExpression { BranchPoint branchPoint; public ECoveringBranchPoint(Expression expression, BranchPoint branchPoint) { super(expression.location, expression); this.branchPoint = branchPoint; } @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); } @Override public Expression accept(ExpressionTransformer transformer) { return transformer.transform(this); } @Override public IVal toVal(Environment env, CodeWriter w) { ModuleWriter mw = w.getModuleWriter(); Constant constant = mw.getExternalConstant(branchPoint, Types.BRANCH_POINT); w.applyWithEffect(location, Types.PROC, Types.UNIT, VisitBranchPoint.INSTANCE, constant); return expression.toVal(env, w); } @Override public Expression replace(ReplaceContext context) { return new ECoveringBranchPoint(expression.replace(context), branchPoint); } }