/Aurora/AuroraDotNetEngine/CompilerTools/CSCodeGenerator.cs
C# | 3413 lines | 2479 code | 407 blank | 527 comment | 602 complexity | 7996c0e698533e0a6ab24dd9d668b6c2 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (c) Contributors, http://aurora-sim.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Aurora-Sim Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Tools;
- using Aurora.ScriptEngineParser;
-
- namespace Aurora.ScriptEngine.AuroraDotNetEngine.CompilerTools
- {
- public static class Extension
- {
- public static bool CompareWildcards(this string WildString, string Mask, bool IgnoreCase)
- {
- int i = 0;
-
- if (String.IsNullOrEmpty(Mask))
- return false;
- if (Mask == "*")
- return true;
-
- while (i != Mask.Length)
- {
- if (CompareWildcard(WildString, Mask.Substring(i), IgnoreCase))
- return true;
-
- while (i != Mask.Length && Mask[i] != ';')
- i += 1;
-
- if (i != Mask.Length && Mask[i] == ';')
- {
- i += 1;
-
- while (i != Mask.Length && Mask[i] == ' ')
- i += 1;
- }
- }
-
- return false;
- }
-
- public static bool CompareWildcard(this string WildString, string Mask, bool IgnoreCase)
- {
- int i = 0, k = 0;
-
- while (k != WildString.Length)
- {
- if ((i + 1) > Mask.Length)
- return true;
- switch (Mask[i])
- {
- case '*':
-
- if ((i + 1) >= Mask.Length)
- return true;
-
- while (k != WildString.Length)
- {
- if (CompareWildcard(WildString.Substring(k + 1), Mask.Substring(i + 1), IgnoreCase))
- return true;
-
- k += 1;
- }
-
- return false;
-
- case '?':
-
- break;
-
- default:
-
- if (IgnoreCase == false && WildString[k] != Mask[i])
- return false;
- if (IgnoreCase && Char.ToLower(WildString[k]) != Char.ToLower(Mask[i]))
- return false;
-
- break;
- }
-
- i += 1;
- k += 1;
- }
-
- if (k == WildString.Length)
- {
- if (i == Mask.Length || Mask[i] == ';' || Mask[i] == '*')
- return true;
- }
-
- return false;
- }
- }
-
- public class CSCodeGenerator : IDisposable
- {
- private readonly List<string> AfterFuncCalls = new List<string>();
- private readonly HashSet<string> DTFunctions = new HashSet<string>();
- private readonly List<string> FuncCalls = new List<string>();
- // public Dictionary<string, string> IenFunctions = new Dictionary<string, string>();
- private readonly Dictionary<string, GlobalVar> GlobalVariables = new Dictionary<string, GlobalVar>();
- private Dictionary<string, SYMBOL> DuplicatedGlobalVariables = new Dictionary<string, SYMBOL>();
- private Dictionary<string, Dictionary<string, SYMBOL>> DuplicatedLocalVariables = new Dictionary<string, Dictionary<string, SYMBOL>>();
-
- /// <summary>
- /// This saves the variables in methods so that we can make sure multiple variables do not have the same name, and if they do, rename/assign them to the correct variable name
- /// </summary>
- private readonly Dictionary<string, GlobalVar> MethodVariables = new Dictionary<string, GlobalVar>();
-
- private readonly List<string> MethodsToAdd = new List<string>();
-
- /// <summary>
- /// This contains a list of variables that we need to rename because of some constraint
- /// </summary>
- private readonly Dictionary<string, VarRename> VariablesToRename = new Dictionary<string, VarRename>();
-
- private readonly Dictionary<string, List<ArgumentDeclarationList>> m_allMethods =
- new Dictionary<string, List<ArgumentDeclarationList>>();
-
- /// <summary>
- /// Param 1 - the API function name, Param 2 - the API name
- /// </summary>
- private readonly Dictionary<string, IScriptApi> m_apiFunctions = new Dictionary<string, IScriptApi>();
-
- private readonly Compiler m_compiler;
-
- private bool FuncCntr;
- private bool IsParentEnumerable;
- private bool IsaGlobalVar;
- public Dictionary<string, ObjectList> LocalMethodArguements = new Dictionary<string, ObjectList>();
- public Dictionary<string, string> LocalMethods = new Dictionary<string, string>();
- private string OriginalScript = "";
- private bool isAdditionExpression;
- private int m_CSharpCol; // the current column of generated C# code
- private int m_CSharpLine; // the current line of generated C# code
- private SYMBOL m_astRoot;
- private int m_braceCount; // for indentation
- private int m_indentWidth = 4; // for indentation
- private bool m_isInEnumeratedDeclaration;
- private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
- private Parser p;
-
-
- /// <summary>
- /// Creates an 'empty' CSCodeGenerator instance.
- /// </summary>
- public CSCodeGenerator(Compiler compiler)
- {
- #region DTFunctions
-
- // api funtions that can return a time delay only
- // must be type DateTime in stub files and implementation
- DTFunctions.Add("llAddToLandBanList");
- DTFunctions.Add("llAddToLandPassList");
- DTFunctions.Add("llAdjustSoundVolume");
- DTFunctions.Add("llCloseRemoteDataChannel");
- DTFunctions.Add("llCreateLink");
- DTFunctions.Add("llDialog");
- DTFunctions.Add("llEjectFromLand");
- DTFunctions.Add("llEmail");
- DTFunctions.Add("llGiveInventory");
- DTFunctions.Add("llInstantMessage");
- DTFunctions.Add("llLoadURL");
- DTFunctions.Add("llMakeExplosion");
- DTFunctions.Add("llMakeFire");
- DTFunctions.Add("llMakeFountain");
- DTFunctions.Add("llMakeSmoke");
- DTFunctions.Add("llMapDestination");
- DTFunctions.Add("llOffsetTexture");
- DTFunctions.Add("llOpenRemoteDataChannel");
- DTFunctions.Add("llParcelMediaCommandList");
- DTFunctions.Add("llPreloadSound");
- DTFunctions.Add("llRefreshPrimURL");
- DTFunctions.Add("llRemoteDataReply");
- DTFunctions.Add("llRemoteLoadScript");
- DTFunctions.Add("llRemoteLoadScriptPin");
- DTFunctions.Add("llRemoveFromLandBanList");
- DTFunctions.Add("llRemoveFromLandPassList");
- DTFunctions.Add("llResetLandBanList");
- DTFunctions.Add("llResetLandPassList");
- DTFunctions.Add("llRezAtRoot");
- DTFunctions.Add("llRezObject");
- DTFunctions.Add("llRotateTexture");
- DTFunctions.Add("llScaleTexture");
- DTFunctions.Add("llSetLinkTexture");
- DTFunctions.Add("llSetLocalRot");
- DTFunctions.Add("llSetParcelMusicURL");
- DTFunctions.Add("llSetPos");
- DTFunctions.Add("llSetPrimURL");
- DTFunctions.Add("llSetRot");
- DTFunctions.Add("llSetTexture");
- DTFunctions.Add("llSleep");
- DTFunctions.Add("llTeleportAgentHome");
- DTFunctions.Add("llTextBox");
- DTFunctions.Add("osTeleportAgent");
- DTFunctions.Add("osTeleportOwner");
-
-
- /* suspended: some API functions are not compatible with IEnum
- // Api functions that can return a delay, a value or breakable in timeslices
- // must be IEnumerator in stub, interface and implementation files
-
- IenFunctions.Add("llRequestAgentData", "LSL_Types.LSLString");
- IenFunctions.Add("llRequestInventoryData", "LSL_Types.LSLString");
- IenFunctions.Add("llSendRemoteData", "LSL_Types.LSLString");
- IenFunctions.Add("llXorBase64Strings", "LSL_Types.LSLString");
- IenFunctions.Add("llRequestSimulatorData", "LSL_Types.LSLString");
- IenFunctions.Add("llParcelMediaQuery", "LSL_Types.list");
- IenFunctions.Add("llGetPrimMediaParams", "LSL_Types.list");
- IenFunctions.Add("llSetPrimMediaParams", "LSL_Types.LSLInteger");
- IenFunctions.Add("llClearPrimMedia", "LSL_Types.LSLInteger");
- IenFunctions.Add("llModPow", "LSL_Types.LSLInteger");
- IenFunctions.Add("llGetNumberOfNotecardLines", "LSL_Types.LSLString");
- IenFunctions.Add("llGetParcelPrimOwners", "LSL_Types.list");
- IenFunctions.Add("llGetNotecardLine", "LSL_Types.LSLString");
- */
-
-
- // the rest will be directly called
-
- #endregion
-
- ResetCounters();
- m_compiler = compiler;
-
- m_apiFunctions = compiler.ScriptEngine.GetAllFunctionNamesAPIs();
- }
-
- /// <summary>
- /// Get the mapping between LSL and C# line/column number.
- /// </summary>
- /// <returns>Dictionary\<KeyValuePair\<int, int\>, KeyValuePair\<int, int\>\>.</returns>
- public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> PositionMap
- {
- get { return m_positionMap; }
- }
-
- /// <summary>
- /// Get the mapping between LSL and C# line/column number.
- /// </summary>
- /// <returns>SYMBOL pointing to root of the abstract syntax tree.</returns>
- public SYMBOL ASTRoot
- {
- get { return m_astRoot; }
- }
-
- #region IDisposable Members
-
- public void Dispose()
- {
- ResetCounters();
- }
-
- #endregion
-
- /// <summary>
- /// Resets various counters and metadata.
- /// </summary>
- private void ResetCounters()
- {
- //NOTE: This takes a VERY long time to rebuild. Ideally, this should be reset, but interesting errors are happening when it is reset..
- p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true));
- MethodVariables.Clear();
- VariablesToRename.Clear();
- GlobalVariables.Clear();
- m_braceCount = 0;
- m_CSharpLine = 15;
- m_CSharpCol = 1;
- m_positionMap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>();
- LocalMethods.Clear();
- m_astRoot = null;
- IsParentEnumerable = false;
- OriginalScript = "";
- lock (FuncCalls)
- FuncCalls.Clear();
- FuncCntr = false;
- IsaGlobalVar = false;
- MethodsToAdd.Clear();
- LocalMethodArguements.Clear();
- m_allMethods.Clear();
- }
-
- public static int GetHeaderCount(Compiler compiler)
- {
- int i = 0;
- foreach (IScriptApi api in compiler.ScriptEngine.GetAPIs())
- foreach (string nameSpace in api.NamespaceAdditions)
- i++;
- return 13 + i;
- }
-
- public static string CreateCompilerScript(Compiler compiler,
- List<string> MethodsToAdd, string ScriptClass)
- {
- string compiledScript = "";
- foreach (IScriptApi api in compiler.ScriptEngine.GetAPIs())
- foreach (string nameSpace in api.NamespaceAdditions)
- compiledScript += "using " + nameSpace + ";\n";
- compiledScript += "using Aurora.ScriptEngine.AuroraDotNetEngine.APIs.Interfaces;\n";
- compiledScript += "using LSL_Types = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types;\n";
- compiledScript += "using System;\n";
-
- compiledScript += "namespace Script\n";
- compiledScript += "{\n";
-
- compiledScript += "[Serializable]\n";
- compiledScript +=
- "public class ScriptClass : Aurora.ScriptEngine.AuroraDotNetEngine.Runtime.ScriptBaseClass\n";
- compiledScript += "{\n";
-
- compiledScript += ScriptClass;
- foreach (string method in MethodsToAdd)
- {
- compiledScript += method;
- }
-
- compiledScript += "}\n"; // Close Class
-
- compiledScript += "}\n"; // Close Namespace
-
- return compiledScript;
- }
-
- /// <summary>
- /// Generate the code from the AST we have.
- /// </summary>
- /// <param name = "script">The LSL source as a string.</param>
- /// <returns>String containing the generated C# code.</returns>
- public string Convert(string script)
- {
- //Unless we are using the same LSL_Converter instance for all scripts, we don't need to reset this
- //ResetCounters();
-
- LSL2CSCodeTransformer codeTransformer;
- try
- {
- // lock (p)
- {
- codeTransformer = new LSL2CSCodeTransformer(p.Parse(script));
- // p.m_lexer.Reset();
- }
- }
- catch (CSToolsException e)
- {
- string message;
-
- // LL start numbering lines at 0 - geeks!
- // Also need to subtract one line we prepend!
- //
- string emessage = e.Message;
- string slinfo = e.slInfo.ToString();
-
- // Remove wrong line number info
- //
- if (emessage.StartsWith(slinfo + ": "))
- emessage = emessage.Substring(slinfo.Length + 2);
-
- if (e.slInfo.lineNumber - 1 <= 0)
- e.slInfo.lineNumber = 2;
- if (e.slInfo.charPosition - 1 <= 0)
- e.slInfo.charPosition = 2;
-
- message = String.Format("({0},{1}) {2}",
- e.slInfo.lineNumber - 1,
- e.slInfo.charPosition - 1, emessage);
-
- m_compiler.AddError(message);
- // p.m_lexer.Reset();
- ResetCounters();
- return "Error parsing the script. " + message;
- }
-
- m_astRoot = codeTransformer.Transform(LocalMethods, LocalMethodArguements);
- DuplicatedGlobalVariables = codeTransformer.DuplicatedGlobalVars;
- DuplicatedLocalVariables = codeTransformer.DuplicatedLocalVars;
- OriginalScript = script;
- string returnstring = "";
-
- // line number
- //m_CSharpLine += 3;
-
- // here's the payload
- returnstring += GenerateLine();
- foreach (SYMBOL s in m_astRoot.kids)
- returnstring += GenerateNode(s);
-
- returnstring += GenerateFireEventMethod();
-
- // Removes all carriage return characters which may be generated in Windows platform.
- //Is there a cleaner way of doing this?
- returnstring = returnstring.Replace("\r", "");
-
- try
- {
- CheckEventCasts(returnstring);
- }
- catch (InvalidOperationException ex)
- {
- m_compiler.AddError(ex.Message);
- return ex.Message;
- }
- return CreateCompilerScript(m_compiler, MethodsToAdd, returnstring);
- }
-
- private string GenerateFireEventMethod()
- {
- StringBuilder retVal = new StringBuilder();
- retVal.AppendLine("public override System.Collections.IEnumerator FireEvent (string evName, object[] parameters)");
- retVal.AppendLine("{");
- foreach (KeyValuePair<string, List<ArgumentDeclarationList>> method in m_allMethods)
- {
- retVal.AppendLine("if(evName == \"" + method.Key + "\")"); // if(evName == "state_entry")
- retVal.Append("return " + method.Key + " (");
- foreach (ArgumentDeclarationList t in method.Value)
- {
- for (int b = 0; b < t.kids.Count; b++)
- {
- retVal.Append("(" + ((Declaration)t.kids[b]).Datatype + ")");
- retVal.Append("parameters[" + b + "]");
- if (b != t.kids.Count - 1)
- retVal.Append(", ");
- }
- }
- retVal.AppendLine(");");
- }
- retVal.AppendLine("return null;");
- retVal.AppendLine("}");
- return retVal.ToString();
- }
-
- private string CheckFloatExponent(string script)
- {
- string[] SplitScript = script.Split('\n');
- List<string> ReconstructableScript = new List<string>();
-
- foreach (string line in SplitScript)
- {
- string AddLine = line;
- if (AddLine.Replace(" ", "") == "default")
- break; //We only check above default
-
- if (AddLine.Contains("float"))
- {
- if (line.Contains("e") && !line.Contains("(") && !line.Contains(")"))
- // Looking for exponents, but not for functions that have ()
- {
- //Should have this - float *** = 151e9;
- string[] SplitBeforeE = AddLine.Split('='); // Split at the e so we can look at the syntax
- if (SplitBeforeE.Length != 1)
- {
- string[] SplitBeforeESpace = SplitBeforeE[1].Split(';');
- //Should have something like this now - 151
- if (SplitBeforeESpace[0].Contains("e"))
- {
- if (!SplitBeforeESpace[0].Contains("."))
- {
- //Needs one then
- string[] Split = SplitBeforeESpace[0].Split('e');
- // Split at the e so we can look at the syntax
- Split[0] += ".";
- string TempString = "";
- foreach (string tempLine in Split)
- {
- TempString += tempLine + "e";
- }
- TempString = TempString.Remove(TempString.Length - 1, 1);
- SplitBeforeESpace[0] = TempString;
- TempString = "";
- foreach (string tempLine in SplitBeforeESpace)
- {
- TempString += tempLine + ";";
- }
- //Remove the last ;
- TempString = TempString.Remove(TempString.Length - 1, 1);
- SplitBeforeE[1] = TempString;
- foreach (string tempLine in SplitBeforeE)
- {
- AddLine += tempLine + "=";
- }
- //Remove the last e
- AddLine = AddLine.Remove(AddLine.Length - 1, 1);
- }
- }
- }
- }
- }
- ReconstructableScript.Add(AddLine);
- }
- string RetVal = "";
- foreach (string line in ReconstructableScript)
- {
- RetVal += line + "\n";
- }
- return RetVal;
- }
-
- private string CheckForInlineVectors(string script)
- {
- string[] SplitScript = script.Split('\n');
- List<string> ReconstructableScript = new List<string>();
- foreach (string line in SplitScript)
- {
- string AddLine = line;
- if (AddLine.Contains("<") && AddLine.Contains(">"))
- {
- if (AddLine.Contains("\"")) // if it contains ", we need to be more careful
- {
- string[] SplitByParLine = AddLine.Split('\"');
- int lineNumber = 0;
- List<string> ReconstructableLine = new List<string>();
- foreach (string parline in SplitByParLine)
- {
- string AddInsideLine = parline;
- //throw out all odd numbered lines as they are inside ""
- if (lineNumber % 2 != 1)
- {
- string[] SplitLineA = AddLine.Split('<');
- if (SplitLineA.Length > 1)
- {
- string SplitLineB = SplitLineA[1].Split('>')[0];
- if (SplitLineB.CompareWildcard("*,*,*", true))
- {
- AddInsideLine = AddInsideLine.Replace("<", "(<");
- AddInsideLine = AddInsideLine.Replace(">", ">)");
- }
- }
- }
- ReconstructableLine.Add(AddInsideLine);
- lineNumber++;
- }
- AddLine = "";
- foreach (string insideline in ReconstructableLine)
- {
- AddLine += insideline + "\"";
- }
- AddLine = AddLine.Remove(AddLine.Length - 1, 1);
- }
- else
- {
- string[] SplitLineA = AddLine.Split('<');
- if (SplitLineA.Length > 1)
- {
- string SplitLineB = SplitLineA[1].Split('>')[0];
- if (SplitLineB.CompareWildcard("*,*,*", true))
- {
- AddLine = AddLine.Replace("<", "(<");
- AddLine = AddLine.Replace(">", ">)");
- }
- }
- }
- }
- ReconstructableScript.Add(AddLine);
- }
- string RetVal = "";
- foreach (string line in ReconstructableScript)
- {
- RetVal += line + "\n";
- }
- return RetVal;
- }
-
- /// <summary>
- /// Checks the C# script for the correct casts in events
- /// This stops errors from misformed events ex. 'touch(vector3 position)' instead of 'touch(int touch)'
- /// </summary>
- /// <param name = "script"></param>
- private void CheckEventCasts(string script)
- {
- CheckEvent(script, "default");
- string[] States = OriginalScript.Split(new string[] { "state " }, StringSplitOptions.RemoveEmptyEntries);
- foreach (string state in States)
- {
- string stateName = state.Split(' ')[0].Split('\n')[0];
- if (!stateName.Contains("default"))
- CheckEvent(script, stateName);
- }
- }
-
- private void CheckEvent(string script, string state)
- {
- if (script.Contains(state + "_event_state_entry("))
- {
- string Valid = state + "_event_state_entry()";
- int charNum = script.IndexOf(state + "_event_state_entry(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
- if (splitScript != Valid)
- FindWrongParameterCountLineNumbers("state_entry", 0, 1);
- }
- if (script.Contains(state + "_event_touch_start("))
- {
- //Valid : default_event_touch_start(LSL_Types.LSLInteger number)
- int charNum = script.IndexOf(state + "_event_touch_start(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("touch_start", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("touch_start", 1, i);
- }
- if (script.Contains(state + "_event_at_rot_target("))
- {
- //Valid : default_event_at_rot_target(LSL_Types.LSLInteger tnum, LSL_Types.Quaternion targetrot, LSL_Types.Quaternion ourrot)
- int charNum = script.IndexOf(state + "_event_at_rot_target(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("at_rot_target", "Invalid argument");
- if (i == 1 || i == 2)
- if (!argument.Contains("LSL_Types.Quaternion"))
- FindLineNumbers("at_rot_target", "Invalid argument");
- i++;
- }
- if (i != 3)
- FindWrongParameterCountLineNumbers("at_rot_target", 3, i);
- }
- if (script.Contains(state + "_event_at_target("))
- {
- //Valid : default_event_at_rot_target(LSL_Types.LSLInteger tnum, LSL_Types.Quaternion targetrot, LSL_Types.Quaternion ourrot)
- int charNum = script.IndexOf(state + "_event_at_target(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("at_target", "Invalid argument");
- if (i == 1 || i == 2)
- if (!argument.Contains("LSL_Types.Vector3"))
- FindLineNumbers("at_target", "Invalid argument");
- i++;
- }
- if (i != 3)
- FindWrongParameterCountLineNumbers("at_target", 3, i);
- }
- if (script.Contains(state + "_event_not_at_target("))
- {
- int charNum = script.IndexOf(state + "_event_not_at_target(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string Valid = state + "_event_not_at_target()";
- if (splitScript != Valid)
- FindWrongParameterCountLineNumbers("not_at_target", 0, 1);
- }
- if (script.Contains(state + "_event_attach("))
- {
- int charNum = script.IndexOf(state + "_event_attach(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("attach", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("attach", 1, i);
- }
- if (script.Contains(state + "_event_changed("))
- {
- int charNum = script.IndexOf(state + "_event_changed(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("changed", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("changed", 1, i);
- }
- if (script.Contains(state + "_event_collision("))
- {
- int charNum = script.IndexOf(state + "_event_collision(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("collision", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("collision", 1, i);
- }
- if (script.Contains(state + "_event_collision_end("))
- {
- int charNum = script.IndexOf(state + "_event_collision_end(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("collision_end", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("collision_end", 1, i);
- }
- if (script.Contains(state + "_event_collision_start("))
- {
- int charNum = script.IndexOf(state + "_event_collision_start(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("collision_start", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("collision_start", 1, i);
- }
- if (script.Contains(state + "_event_run_time_permissions("))
- {
- int charNum = script.IndexOf(state + "_event_run_time_permissions(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- {
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("run_time_permissions", "Invalid argument");
- }
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("run_time_permissions", 1, i);
- }
- if (script.Contains(state + "_event_control("))
- {
- int charNum = script.IndexOf(state + "_event_control(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("control", "Invalid argument");
- if (i == 1 || i == 2)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("control", "Invalid argument");
- i++;
- }
- if (i != 3)
- FindWrongParameterCountLineNumbers("control", 3, i);
- }
- if (script.Contains(state + "_event_dataserver("))
- {
- int charNum = script.IndexOf(state + "_event_dataserver(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0 || i == 1)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("dataserver", "Invalid argument");
- i++;
- }
- if (i != 2)
- FindWrongParameterCountLineNumbers("dataserver", 2, i);
- }
- if (script.Contains(state + "_event_timer("))
- {
- int charNum = script.IndexOf(state + "_event_timer(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string Valid = state + "_event_timer()";
- if (splitScript != Valid)
- FindWrongParameterCountLineNumbers("timer", 0, 1);
- }
- if (script.Contains(state + "_event_email("))
- {
- int charNum = script.IndexOf(state + "_event_email(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0 || i == 1 || i == 2 || i == 3)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("email", "Invalid argument");
- if (i == 4)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("email", "Invalid argument");
- i++;
- }
- if (i != 5)
- FindWrongParameterCountLineNumbers("email", 5, i);
- }
- if (script.Contains(state + "_event_http_request("))
- {
- int charNum = script.IndexOf(state + "_event_http_request(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0 || i == 1 || i == 2)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("http_request", "Invalid argument");
- i++;
- }
- if (i != 3)
- FindWrongParameterCountLineNumbers("http_request", 3, i);
- }
- if (script.Contains(state + "_event_http_response("))
- {
- int charNum = script.IndexOf(state + "_event_http_response(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0 || i == 3)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("http_response", "Invalid argument");
- if (i == 1)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("http_response", "Invalid argument");
- if (i == 2)
- if (!argument.Contains("LSL_Types.list"))
- FindLineNumbers("http_response", "Invalid argument");
- i++;
- }
- if (i != 4)
- FindWrongParameterCountLineNumbers("http_response", 4, i);
- }
- if (script.Contains(state + "_event_land_collision_end("))
- {
- int charNum = script.IndexOf(state + "_event_land_collision_end(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.Vector3"))
- FindLineNumbers("land_collision_end", "Invalid argument");
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("land_collision_end", 1, i);
- }
- if (script.Contains(state + "_event_land_collision("))
- {
- int charNum = script.IndexOf(state + "_event_land_collision(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.Vector3"))
- FindLineNumbers("land_collision", "Invalid argument");
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("land_collision", 1, i);
- }
- if (script.Contains(state + "_event_land_collision_start("))
- {
- int charNum = script.IndexOf(state + "_event_land_collision_start(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.Vector3"))
- FindLineNumbers("land_collision_start", "Invalid argument");
- i++;
- }
- if (i != 1)
- FindWrongParameterCountLineNumbers("land_collision_start", 1, i);
- }
- if (script.Contains(state + "_event_link_message("))
- {
- int charNum = script.IndexOf(state + "_event_link_message(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0 || i == 1)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("link_message", "Invalid argument");
- if (i == 2 || i == 3)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("link_message", "Invalid argument");
- i++;
- }
- if (i != 4)
- FindWrongParameterCountLineNumbers("link_message", 4, i);
- }
- if (script.Contains(state + "_event_listen("))
- {
- int charNum = script.IndexOf(state + "_event_listen(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arguments = splitScript.Split('(')[1];
- arguments = arguments.Split(')')[0];
-
- string[] AllArguments = arguments.Split(',');
-
- int i = 0;
- foreach (string argument in AllArguments)
- {
- if (i == 0)
- if (!argument.Contains("LSL_Types.LSLInteger"))
- FindLineNumbers("listen", "Invalid argument");
- if (i == 1 || i == 2 || i == 3)
- if (!argument.Contains("LSL_Types.LSLString"))
- FindLineNumbers("listen", "Invalid argument");
- i++;
- }
- if (i != 4)
- FindWrongParameterCountLineNumbers("listen", 4, i);
- }
- if (script.Contains(state + "_event_on_rez("))
- {
- int charNum = script.IndexOf(state + "_event_on_rez(");
- string splitScript = script.Remove(0, charNum);
- charNum = splitScript.IndexOf('\n');
- splitScript = splitScript.Remove(charNum, splitScript.Length - charNum);
-
- string arg…
Large files files are truncated, but you can click here to view the full file