public static Dictionary <string, DHJassFunction> CollectNameFunctionPairs() { Module m = Assembly.GetExecutingAssembly().GetModules(false)[0]; Type[] types = m.FindTypes(new TypeFilter(SearchCriteria), "DotaHIT.Jass.Native.Functions"); Dictionary <string, DHJassFunction> nameFunctionPairs = new Dictionary <string, DHJassFunction>(); for (int i = 0; i < types.Length; i++) { try { DHJassFunction value = (DHJassFunction)types[i].InvokeMember(null, BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); nameFunctionPairs.Add(types[i].Name, value); value.Name = types[i].Name; } catch { } } return(nameFunctionPairs); }
public override DHJassOperation GetNew(List <string> lines, ref int line, List <string> args) { DHJassFunction function = DHJassCompiler.Functions.Peek(); if (function != null) { function.LocalDeclarations.Add(new DHJassLocalDeclaration(args)); } return(null); }
protected static void GetWar3Functions(List <string> lines, bool removeRead) { int i = 0; int length; List <string> args; do { length = lines.Count; args = new List <string>(3); for (; i < length; i++) { if (DHJassFunction.IsSyntaxMatchFast(lines[i], ref args)) { break; } } if (args.Count > 1) // if function declaration was found { List <string> function_lines = new List <string>(); int j = i + 1; for (; j < length; j++) { string curren_line = lines[j]; if (curren_line == "endfunction") { break; } else { function_lines.Add(curren_line); } } if (removeRead) { lines.RemoveRange(i, (j - i) + 1); i = 0; } else { i = ++j; } DHJassFunction function = new DHJassFunction(args, function_lines); DHJassExecutor.War3Functions.Add(function.Name, function); } }while (args.Count > 1); }
public DHJassLoopOperation(List <string> lines, ref int line, List <string> args) { DHJassCompiler.Loops.Push(this); DHJassOperation LoopEndPoint; line++; if (DHJassFunction.TryCreateBody(lines, ref line, this, out EntryPoint, out LoopEndPoint)) { LoopEndPoint.SetNext(EntryPoint); } DHJassCompiler.Loops.Pop(); }
public DHJassCallFunctionCommand(string code) { //Match match; string name; List <string> args; if (DHJassSyntax.checkFunctionUsageSyntaxFast(code, out name, out args)) //out match)) { parse(name, args); //match); } else { function = null; } }
public DHJassIfElseOperation(List <string> lines, ref int line, List <string> args, DHJassEmptyOperation endPoint) { DHJassOperation StatementEndPoint; Condition = new DHJassGetValueOnDemandCommand(args[0]); line++; if (DHJassFunction.TryCreateBody(lines, ref line, this, out Then, out StatementEndPoint)) { this.EndPoint = endPoint; StatementEndPoint.SetNext(EndPoint); string currentLine = lines[line].Trim(); switch (currentLine) { case "else": line++; if (DHJassFunction.TryCreateBody(lines, ref line, this, out Else, out StatementEndPoint)) { StatementEndPoint.SetNext(EndPoint); } break; case "endif": Else = EndPoint; break; default: if (this.IsSyntaxMatch(currentLine, out args)) { Else = new DHJassIfElseOperation(lines, ref line, args, endPoint); //Else.GetLast().SetNext(EndPoint); } break; } } }
public DHJassCallFunctionCommand(string name, List <string> argList) { function = null; parse(name, argList); }
protected static void GetWar3Functions(List<string> lines, bool removeRead) { int i = 0; int length; List<string> args; do { length = lines.Count; args = new List<string>(3); for (; i < length; i++) if (DHJassFunction.IsSyntaxMatchFast(lines[i], ref args)) break; if (args.Count > 1) // if function declaration was found { List<string> function_lines = new List<string>(); int j = i + 1; for (; j < length; j++) { string curren_line = lines[j]; if (curren_line == "endfunction") break; else function_lines.Add(curren_line); } if (removeRead) { lines.RemoveRange(i, (j - i) + 1); i = 0; } else i = ++j; DHJassFunction function = new DHJassFunction(args, function_lines); DHJassExecutor.War3Functions.Add(function.Name, function); } } while (args.Count > 1); }