Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
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;
                }
            }
        }