public void SetMetadataIndexTable(LuatTable table) { // Skip a meta-table so we don't start adding // entries into table with calls to AddAlias() Metatable.CreateIndex(); Metatable.Index.Metatable.Index = table; }
/// <summary> /// Clears the entire database /// </summary> private void DoClear() { lock (this) { m_stdLibs = new LuatTable(null); m_unresolvedVariableTypes = new List <LuatVariable>(); m_scripts = new List <LuatScript>(); } }
private static bool CheckVariableNameInUse(VariableExpression expression, string variableName) { if (expression == null) { return(false); } var scripts = new List <LuatScript>(); var bs = expression.FindAncestor <BlockStatement>(); while (bs != null) { foreach (var i in bs.Locals.Entries) { LuatTable table = i.Value; if (!scripts.Contains(i.Key)) { scripts.Add(i.Key); } foreach (var v in table.Children) { string name = v.Key; if (name == variableName) { return(true); } } } bs = bs.FindAncestor <BlockStatement>(); } foreach (LuatScript script in scripts) { var visited = new HashSet <LuatValue>(); IEnumerable <KeyValuePair <string, LuatValue> > children = script.Table.GetChildren(ref visited); foreach (KeyValuePair <string, LuatValue> child in children) { if (child.Key == variableName) { return(true); } } } return(false); }
private void RegisterScript(ILuaIntellisenseDocument script, LuatTable parentPublicTable) { var table = new LuatTable(null); var publicTable = new LuatTable(table); // Chain the public tables using metatable indices so that a child script can // access the content of the parent's public table at global scope. publicTable.SetMetadataIndexTable(parentPublicTable); // Expose the content of the public table at global scope table.SetMetadataIndexTable(publicTable); // Register the script var luatScript = LuatScript.Create(); luatScript.Name = script.Name; luatScript.Table = table; luatScript.Path = script.Uri.LocalPath; luatScript.Reference = script; m_scripts.Add(luatScript); table.Description = Helpers.Decorate(script.Name, DecorationType.Code); }