private object LuaLoad(object ld, string source, string mode, LuaTable env) { if (String.IsNullOrEmpty(source)) { source = "=(load)"; } if (mode == "b" || !(ld is string || ld is LuaMethod || ld is Delegate)) // binary chunks are not implementeted { throw new NotImplementedException(); } try { // collect the chunks if (Lua.IsCallable(ld)) { StringBuilder sbCode = new StringBuilder(); string sPart; while (!String.IsNullOrEmpty(sPart = (string)new LuaResult(RtInvokeSite(ld))[0])) { sbCode.Append(sPart); } ld = sbCode.ToString(); } // create the chunk return(LuaLoadReturn(lua.CompileChunk((string)ld, source, null), env)); } catch (Exception e) { return(new LuaResult(null, e.Message)); } } // func LuaLoad