public MethodInfo Compile() { var locals = LocalTypes.ToList(); var instructions = Instructions.ToList(); var tokenResolver = new ILInstructionResolver(Module); Dictionary <int, Label> labels = null; return(DynamicCompiler.CompileMethod(Name, ReturnType, ParameterTypes, (gen) => { locals.ForEach(x => gen.DeclareLocal(x)); labels = instructions.Where(x => x.Label.HasValue).ToDictionary(x => (int)x.Label, x => gen.DefineLabel()); instructions.ToList().ForEach(x => x.Emit(gen, tokenResolver, labels)); })); }