Beispiel #1
0
        public static Dictionary <Type, DHJassOperation> CollectTypeOperationPairs()
        {
            Module m = Assembly.GetExecutingAssembly().GetModules(false)[0];

            Type[] types = m.FindTypes(new TypeFilter(SearchCriteria), "DotaHIT.Jass.Operations");

            Dictionary <Type, DHJassOperation> typeOperationPairs = new Dictionary <Type, DHJassOperation>();

            for (int i = 0; i < types.Length; i++)
            {
                try
                {
                    DHJassOperation value = (DHJassOperation)types[i].InvokeMember(null,
                                                                                   BindingFlags.Public | BindingFlags.DeclaredOnly |
                                                                                   BindingFlags.Instance | BindingFlags.CreateInstance,
                                                                                   null, null, null);

                    typeOperationPairs.Add(types[i], value);
                }
                catch
                {
                }
            }

            return(typeOperationPairs);
        }
Beispiel #2
0
        public static bool TryCreate(List <string> lines, ref int line, out DHJassOperation EntryPoint, out DHJassOperation ExitPoint)
        {
            DHJassOperation Operation = DbJassTypeOperationKnowledge.CreateKnownOperation(lines, ref line);

            if (Operation == null)
            {
                for (line++; line < lines.Count; line++)
                {
                    Operation = DbJassTypeOperationKnowledge.CreateKnownOperation(lines, ref line);
                    if (Operation != null)
                    {
                        EntryPoint = Operation;
                        ExitPoint  = Operation.GetLast();
                        return(true);
                    }
                }
            }
            else
            {
                EntryPoint = Operation;
                ExitPoint  = Operation.GetLast();
                return(true);
            }

            EntryPoint = null;
            ExitPoint  = null;
            return(false);
        }
Beispiel #3
0
 public DHJassExitLoopWhenOperation(List <string> lines, ref int line, List <string> args)
 {
     Condition = new DHJassGetValueOnDemandCommand(args[0]);
     if (DHJassCompiler.Loops.Count != 0)
     {
         DHJassLoopOperation Loop = DHJassCompiler.Loops.Peek();
         LoopEndPoint = Loop.EndPoint;
     }
 }
Beispiel #4
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;
                }
            }
        }
Beispiel #5
0
        public static bool TryCreateBody(List<string> lines, ref int i, IBodyEndSyntaxHolder besh, out DHJassOperation EntryPoint, out DHJassOperation ExitPoint)
        {
            DHJassOperation LastExitPoint;
            DHJassOperation NextEntryPoint;

            // check if this line is already the end of the body
            if (besh.CheckBodyEndSyntax(lines[i]))
            {
                EntryPoint = new DHJassEmptyOperation();
                ExitPoint = EntryPoint;
                return true;
            }

            // create operation based on the specified line
            if (DHJassOperation.TryCreate(lines, ref i, out EntryPoint, out ExitPoint))
            {
                // update the pointer to the body's last operation
                LastExitPoint = ExitPoint;

                // now start creating the rest of the operations until the body end syntax is met
                for (i++; i < lines.Count; i++)
                {
                    // check if this line is the end of the body
                    if (besh.CheckBodyEndSyntax(lines[i]))
                        return true;

                    // create operation based on the specified line
                    DHJassOperation.TryCreate(lines, ref i, out NextEntryPoint, out ExitPoint);

                    // link previous operation's body exit point with this operation's body entry point
                    LastExitPoint.SetNext(NextEntryPoint);

                    // the pointer to the body's last operation will now point to
                    // the exit point of this operation
                    LastExitPoint = ExitPoint;
                }
            }
            else
                return false;

            return true;
        }
Beispiel #6
0
 public override void SetNext(DHJassOperation next)
 {
     Next = next;
 }
Beispiel #7
0
 public virtual void SetNext(DHJassOperation next)
 {
 }
Beispiel #8
0
        public static bool TryCreate(List<string> lines, ref int line, out DHJassOperation EntryPoint, out DHJassOperation ExitPoint)
        {
            DHJassOperation Operation = DbJassTypeOperationKnowledge.CreateKnownOperation(lines, ref line);
            if (Operation == null)
                for (line++; line < lines.Count; line++)
                {
                    Operation = DbJassTypeOperationKnowledge.CreateKnownOperation(lines, ref line);
                    if (Operation != null)
                    {
                        EntryPoint = Operation;
                        ExitPoint = Operation.GetLast();
                        return true;
                    }
                }
            else
            {
                EntryPoint = Operation;
                ExitPoint = Operation.GetLast();
                return true;
            }

            EntryPoint = null;
            ExitPoint = null;
            return false;
        }
Beispiel #9
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;
                }
            }
        }
Beispiel #10
0
 public DHJassExitLoopWhenOperation(List<string> lines, ref int line, List<string> args)
 {
     Condition = new DHJassGetValueOnDemandCommand(args[0]);
     if (DHJassCompiler.Loops.Count != 0)
     {
         DHJassLoopOperation Loop = DHJassCompiler.Loops.Peek();
         LoopEndPoint = Loop.EndPoint;
     }
 }
Beispiel #11
0
 public override void SetNext(DHJassOperation next)
 {
 }
Beispiel #12
0
 public virtual void SetNext(DHJassOperation next)
 {
 }