/// <summary> /// Loads a string containing a Lua/MoonSharp function. /// </summary> /// <param name="code">The code.</param> /// <param name="globalTable">The global table to bind to this chunk.</param> /// <param name="funcFriendlyName">Name of the function used to report errors, etc.</param> /// <returns> /// A DynValue containing a function which will execute the loaded code. /// </returns> public DynValue LoadFunction(string code, Table globalTable = null, string funcFriendlyName = null) { string chunkName = string.Format("libfunc_{0}", funcFriendlyName ?? m_Sources.Count.ToString()); SourceCode source = new SourceCode(chunkName, code, m_Sources.Count, this); m_Sources.Add(source); int address = Loader_Antlr.LoadFunction(this, source, m_ByteCode, globalTable ?? m_GlobalTable); SignalSourceCodeChange(source); SignalByteCodeChange(); return(MakeClosure(address)); }
/// <summary> /// Creates a new dynamic expression. /// </summary> /// <param name="code">The code of the expression.</param> /// <returns></returns> public DynamicExpression CreateDynamicExpression(string code) { DynamicExprExpression dee = Loader_Antlr.LoadDynamicExpr(this, new SourceCode("__dynamic", code, -1, this)); return(new DynamicExpression(this, code, dee)); }