--- /dev/null
+package org.simantics.scl.compiler.internal.codegen.utils;
+
+import org.simantics.scl.compiler.internal.codegen.utils.LocalVariable;
+import org.cojen.classfile.TypeDesc;
+import org.simantics.scl.runtime.SCLContext;
+
+public enum SCLContextPreparationStep implements PreparationStep<LocalVariable> {
+ INSTANCE;
+
+ public final static TypeDesc SCL_CONTEXT = TypeDesc.forClass(SCLContext.class);
+
+ public static LocalVariable getCurrent(MethodBuilder mb) {
+ LocalVariable var = mb.getPreparation(INSTANCE);
+ if(var == null) {
+ var = mb.createLocalVariable("sclContext", SCL_CONTEXT);
+ mb.invokeStatic(SCL_CONTEXT, "getCurrent", SCL_CONTEXT, Constants.EMPTY_TYPEDESC_ARRAY);
+ mb.storeLocal(var);
+ mb.addPreparation(INSTANCE, var);
+ }
+ return var;
+ }
+}