Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
            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);
            }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
 public DHJassCallFunctionCommand(string name, List <string> argList)
 {
     function = null;
     parse(name, argList);
 }
Exemplo n.º 8
0
            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);
            }