]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/VisitBranchPoint.java
Adding Marker-support to Logging-module
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / java / VisitBranchPoint.java
1 package org.simantics.scl.compiler.elaboration.java;
2
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;
12
13 public class VisitBranchPoint extends FunctionValue {
14     public static final VisitBranchPoint INSTANCE = new VisitBranchPoint();
15     
16     private static final String CLASS_NAME =
17             BranchPoint.class.getCanonicalName().replace('.', '/');
18     private static final String FIELD_NAME = "visitCounter";
19     
20     private VisitBranchPoint() {
21         super(TVar.EMPTY_ARRAY, Types.PROC, Types.UNIT, Types.BRANCH_POINT);
22     }
23     
24     @Override
25     public Type applyExact(MethodBuilder mb, Val[] parameters) {
26         parameters[0].push(mb);
27         mb.dup();
28         mb.loadField(CLASS_NAME, FIELD_NAME, TypeDesc.INT);
29         mb.loadConstant(1);
30         mb.math(Opcodes.IADD);
31         mb.storeField(CLASS_NAME, FIELD_NAME, TypeDesc.INT);
32         return Types.UNIT;
33     }
34     
35     @Override
36     public String toString() {
37         return "visitBranchPoint";
38     }
39 }