1 package org.simantics.scl.compiler.elaboration.java;
3 import org.cojen.classfile.TypeDesc;
4 import org.objectweb.asm.Opcodes;
5 import org.simantics.scl.compiler.constants.FunctionValue;
6 import org.simantics.scl.compiler.internal.codegen.references.Val;
7 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
8 import org.simantics.scl.compiler.types.TVar;
9 import org.simantics.scl.compiler.types.Type;
10 import org.simantics.scl.compiler.types.Types;
11 import org.simantics.scl.runtime.profiling.BranchPoint;
13 public class VisitBranchPoint extends FunctionValue {
14 public static final VisitBranchPoint INSTANCE = new VisitBranchPoint();
16 private static final String CLASS_NAME =
17 BranchPoint.class.getCanonicalName().replace('.', '/');
18 private static final String FIELD_NAME = "visitCounter";
20 private VisitBranchPoint() {
21 super(TVar.EMPTY_ARRAY, Types.PROC, Types.UNIT, Types.BRANCH_POINT);
25 public Type applyExact(MethodBuilder mb, Val[] parameters) {
26 parameters[0].push(mb);
28 mb.loadField(CLASS_NAME, FIELD_NAME, TypeDesc.INT);
30 mb.math(Opcodes.IADD);
31 mb.storeField(CLASS_NAME, FIELD_NAME, TypeDesc.INT);
36 public String toString() {
37 return "visitBranchPoint";