public static ILGenerator CreateGenerator(params VeinArgumentRef[] args) { var module = new VeinModuleBuilder(Guid.NewGuid().ToString()); var @class = module.DefineClass("global::foo/bar"); var method = @class.DefineMethod("foo", VeinTypeCode.TYPE_VOID.AsClass(), args); var gen = method.GetGenerator(); var ctx = new GeneratorContext(); ctx.Module = module; ctx.Classes.Add(@class.FullName, @class); ctx.CurrentMethod = method; gen.StoreIntoMetadata("context", ctx); ctx.CreateScope(); return(gen); }