} // func CreateUniqueTypeName LuaChunk ILuaDebug.CreateChunk(Lua lua, LambdaExpression expr) { lock (this) { // create the dynamic assembly if (assembly == null) { assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(GetLuaDynamicName(), AssemblyBuilderAccess.RunAndCollect); module = assembly.DefineDynamicModule("lua", true); } // create a type for the expression var type = module.DefineType(CreateUniqueTypeName(expr.Name), TypeAttributes.NotPublic | TypeAttributes.Sealed); // transform the expression var reduce = new ReduceDynamic(lua, this, type); expr = (LambdaExpression)reduce.Visit(expr); // compile the function var method = type.DefineMethod(expr.Name, MethodAttributes.Static | MethodAttributes.Public); var chunk = new LuaStackTraceChunk(lua, expr.Name); var collectedDebugInfo = new LuaDebugInfoGenerator(chunk); expr.CompileToMethod(method, collectedDebugInfo); // create the type and build the delegate var typeFinished = type.CreateType(); // Initialize fields, create the static callsite's reduce.InitMethods(typeFinished); // return chunk return(chunk.InitChunk(Delegate.CreateDelegate(expr.Type, typeFinished.GetMethod(expr.Name)))); } } // func ILuaDebug.CreateChunk
public LuaDebugInfoGenerator(LuaStackTraceChunk chunk) { this.chunk = chunk ?? throw new ArgumentNullException(nameof(chunk)); } // ctor
public LuaDebugInfoGenerator(LuaStackTraceChunk chunk) { this.chunk = chunk; } // ctor