package org.simantics.scl.compiler.internal.codegen.utils; import org.cojen.classfile.TypeDesc; import org.simantics.scl.runtime.SCLContext; public enum SCLContextPreparationStep implements PreparationStep { 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; } }