Esempio n. 1
0
        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.RtInvokeable(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