]> gerrit.simantics Code Review - simantics/platform.git/blob
bf2143c9c903cf24ca463dd3dfb8b42c47e3d092
[simantics/platform.git] /
1 package org.simantics.scl.compiler.internal.codegen.utils;
2
3 import org.simantics.scl.compiler.internal.codegen.utils.LocalVariable;
4 import org.cojen.classfile.TypeDesc;
5 import org.simantics.scl.runtime.SCLContext;
6
7 public enum SCLContextPreparationStep implements PreparationStep<LocalVariable> {
8     INSTANCE;
9     
10     public final static TypeDesc SCL_CONTEXT = TypeDesc.forClass(SCLContext.class);
11     
12     public static LocalVariable getCurrent(MethodBuilder mb) {
13         LocalVariable var = mb.getPreparation(INSTANCE);
14         if(var == null) {
15             var = mb.createLocalVariable("sclContext", SCL_CONTEXT);
16             mb.invokeStatic(SCL_CONTEXT, "getCurrent", SCL_CONTEXT, Constants.EMPTY_TYPEDESC_ARRAY);
17             mb.storeLocal(var);
18             mb.addPreparation(INSTANCE, var);
19         }
20         return var;
21     }
22 }