/// <summary> /// Get all compiler events in code. /// </summary> internal IList <MochaScriptFunction> GetCompilerEvents() { List <MochaScriptFunction> _compilerEvents = new List <MochaScriptFunction>(); string line, name; string[] parts; int dex; MochaScriptFunction _event; for (int index = beginIndex + 1; index < finalIndex; index++) { line = MochaScriptArray[index].Trim(); if (line.StartsWith("compilerevent ")) { parts = line.Split(' '); name = parts[1].Substring(0, parts[1].Length - 2); if (parts.Length != 2 || MochaScriptArray[index + 1].Trim() != "{") { throw Throw(index + 1, "|| Any function is not processed!"); } else if (!parts[1].EndsWith("()")) { throw Throw(index + 1, "|| Any function is not processed!"); } if (!compilerEventsRegex.IsMatch(name)) { throw Throw(index + 1, "|| Not added compiler event. Not exists compiler event this name."); } if (compilerEvents.Contains(name)) { throw Throw(index + 1, "|| Not added compiler event. Debugger already in defined this name."); } dex = codeProcessor.GetCloseBracketIndex(index + 2, '{', '}'); if (dex == -1) { throw Throw(index + 1, "|| Any function is not processed!"); } _event = new MochaScriptFunction(name); Array.Copy(MochaScriptArray, index + 2, _event.Source, 0, dex); _event.Source = MochaScriptArray.Skip(index + 2).Take(dex - (index + 2)).ToArray(); _event.Index = index; _compilerEvents.Add(_event); index = dex; continue; } } return(_compilerEvents); }
/// <summary> /// Get all functions in code. /// </summary> internal IList <MochaScriptFunction> GetFunctions() { List <MochaScriptFunction> _functions = new List <MochaScriptFunction>(); string line, name; string[] parts; int dex; MochaScriptFunction func; for (int index = beginIndex + 1; index < finalIndex; index++) { line = MochaScriptArray[index].Trim(); if (line.StartsWith("func ")) { parts = line.Split(' '); name = parts[1].Substring(0, parts[1].Length - 2); if (parts.Length != 2 || MochaScriptArray[index + 1].Trim() != "{") { throw Throw(index + 1, "|| Any function is not processed!"); } else if (!parts[1].EndsWith("()")) { throw Throw(index + 1, "|| Any function is not processed!"); } if (functions.Contains(name)) { throw Throw(index + 1, "|| Not added function. Debugger already in defined this name."); } dex = codeProcessor.GetCloseBracketIndex(index + 2, '{', '}'); if (dex == -1) { throw Throw(index + 1, "|| Any function is not processed!"); } func = new MochaScriptFunction(name); func.Source = MochaScriptArray.Skip(index + 2).Take(dex - (index + 2)).ToArray(); func.Index = index; _functions.Add(func); index = dex; continue; } } return(_functions); }