public void CreateNewIndex() { if (NewIndex == null) { NewIndex = new LuatTable(null); } }
public LuatVariable AddLocal(LuatScript script, Identifier Name, string type) { string name = Name.Text; LuatVariable variable = Locals[script].Index(name, false) as LuatVariable; if (null == variable) { LuatTable localTable = Locals[script]; if (null != type) { variable = Database.Instance.CreateReflectedVariable(type, localTable); } if (null == variable) { variable = new LuatVariable(localTable); } localTable.AddChild(name, variable); } else { Name.AddWarning(script, WarningType.DuplicateLocal, "Warning: Local '" + name + "' already defined"); } return(variable); }
public void CreateIndex() { if (Index == null) { Index = new LuatTable(null); } }
private static void AddSledSpecificFunctions(LuatTable table) { if (table == null) { return; } // add libsleddebugger table { var debuggerTable = new LuatTable { Description = "libsleddebugger injected functionality" }; debuggerTable.AddChild("version", new LuatLiteral(LuatTypeString.Instance)); debuggerTable.AddChild("instance", new LuatLiteral(LuatTypeNumber.Instance)); table.AddChild("libsleddebugger", debuggerTable); } // add libsledluaplugin table { var luaPluginTable = new LuatTable { Description = "libsledluaplugin injected functionality" }; luaPluginTable.AddChild("version", new LuatLiteral(LuatTypeString.Instance)); luaPluginTable.AddChild("instance", new LuatLiteral(LuatTypeNumber.Instance)); { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "message" }) { ExpectsSelf = false }; luaPluginTable.AddChild("tty", function); } { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "condition", "message" }) { ExpectsSelf = false }; luaPluginTable.AddChild("assert", function); } { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "error" }) { ExpectsSelf = false }; luaPluginTable.AddChild("errorhandler", function); } table.AddChild("libsledluaplugin", luaPluginTable); } }
public override LuatValue Resolve(LuatScript script) { LuatValue value = base.Resolve(script); if (null != value) { return(value); } LuatTable table = new LuatTable(null); int fieldIndex = 1; foreach (Field field in Fields) { string key; if (null == field.Key) { key = (fieldIndex++).ToString(); } else if (field.Key is StringExpression) { key = (field.Key as StringExpression).String; } else if (field.Key is NumberExpression) { key = (field.Key as NumberExpression).Number.ToString(); } else if (field.Key is Identifier) { key = (field.Key as Identifier).Text; } else { continue; } if (null != table.Index(key, false)) { field.AddWarning(script, WarningType.DuplicateTableKey, string.Format("Table already contains key '{0}'", key)); continue; } LuatVariable entry = table.AddChild(key, new LuatVariable(table)); entry.Description = Description; if (null != field.Value) { entry.AddAssignment(new Parser.AST.Expression.Reference(script, field.Value, this.DisplayText)); } } this.ResolvedValues[script] = table; return(table); }
private static LuatScript CreateLuatScript(ILuaIntellisenseDocument document) { var table = new LuatTable(null) { Description = Helpers.Decorate(document.Name, DecorationType.Code) }; var luatScript = LuatScript.Create(); luatScript.Table = table; luatScript.Path = document.Uri.LocalPath; luatScript.Reference = document; luatScript.Name = document.Name; return luatScript; }
private void CustomScriptRegistrationHandler(LuatTable stdlibs, ref List <LuatScript> scripts, ref List <ILuaIntellisenseDocument> documents) { m_customScriptRegistrationWorking = false; if (m_project == null) { return; } LuaIntellisenseServiceHelpers.RegisterProject(m_project, stdlibs, ref scripts, ref documents); m_customScriptRegistrationWorking = true; }
public static void RegisterProject(ILuaIntellisenseProject project, LuatTable stdLibs, ref List<LuatScript> scripts, ref List<ILuaIntellisenseDocument> documents) { if (project == null) return; var allDocuments = new List<ILuaIntellisenseDocument>(project.AllDocuments); documents.AddRange(allDocuments); foreach (var document in allDocuments) { var script = CreateLuatScript(document); script.Table.SetMetadataIndexTable(stdLibs); AddSledSpecificFunctions(script.Table); scripts.Add(script); } }
private static LuatScript CreateLuatScript(ILuaIntellisenseDocument document) { var table = new LuatTable(null) { Description = Helpers.Decorate(document.Name, DecorationType.Code) }; var luatScript = LuatScript.Create(); luatScript.Table = table; luatScript.Path = document.Uri.LocalPath; luatScript.Reference = document; luatScript.Name = document.Name; return(luatScript); }
private static void AddSledSpecificFunctions(LuatTable table) { if (table == null) return; // add libsleddebugger table { var debuggerTable = new LuatTable { Description = "libsleddebugger injected functionality" }; debuggerTable.AddChild("version", new LuatLiteral(LuatTypeString.Instance)); debuggerTable.AddChild("instance", new LuatLiteral(LuatTypeNumber.Instance)); table.AddChild("libsleddebugger", debuggerTable); } // add libsledluaplugin table { var luaPluginTable = new LuatTable { Description = "libsledluaplugin injected functionality" }; luaPluginTable.AddChild("version", new LuatLiteral(LuatTypeString.Instance)); luaPluginTable.AddChild("instance", new LuatLiteral(LuatTypeNumber.Instance)); { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "message" }) { ExpectsSelf = false }; luaPluginTable.AddChild("tty", function); } { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "condition", "message" }) { ExpectsSelf = false }; luaPluginTable.AddChild("assert", function); } { var retVal = new LuatVariable(null, LuatTypeNil.Instance, LuatVariableFlags.None); var function = new LuatFunction(retVal, new[] { "error" }) { ExpectsSelf = false }; luaPluginTable.AddChild("errorhandler", function); } table.AddChild("libsledluaplugin", luaPluginTable); } }
public static void RegisterProject(ILuaIntellisenseProject project, LuatTable stdLibs, ref List <LuatScript> scripts, ref List <ILuaIntellisenseDocument> documents) { if (project == null) { return; } var allDocuments = new List <ILuaIntellisenseDocument>(project.AllDocuments); documents.AddRange(allDocuments); foreach (var document in allDocuments) { var script = CreateLuatScript(document); script.Table.SetMetadataIndexTable(stdLibs); AddSledSpecificFunctions(script.Table); scripts.Add(script); } }
public void CreateNewIndex() { if (NewIndex == null) NewIndex = new LuatTable(null); }
public void CreateIndex() { if (Index == null) Index = new LuatTable(null); }
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); }
/// <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 void CustomScriptRegistrationHandler(LuatTable stdlibs, ref List<LuatScript> scripts, ref List<ILuaIntellisenseDocument> documents) { m_customScriptRegistrationWorking = false; if (m_project == null) return; LuaIntellisenseServiceHelpers.RegisterProject(m_project, stdlibs, ref scripts, ref documents); m_customScriptRegistrationWorking = true; }