void ProcessCallIf()
        {
            CodeIf code = (CodeIf)m_scriptInstruction.Operand0;

            if (ProcessCondition(code.If, Executable_Block.If))
            {
                return;
            }
            int length = code.ElseIf.Count;

            for (int i = 0; i < length; ++i)
            {
                if (ProcessCondition(code.ElseIf[i], Executable_Block.If))
                {
                    return;
                }
            }
            ProcessCondition(code.Else, Executable_Block.If);
        }
        //解析if(判断语句)
        private void ParseIf()
        {
            CodeIf ret = new CodeIf();

            ret.If = ParseCondition(true, Executable_Block.If);
            List <TempCondition> ElseIf = new List <TempCondition>();

            for (; ;)
            {
                Token token = ReadToken();
                if (token.Type == TokenType.ElseIf)
                {
                    ElseIf.Add(ParseCondition(true, Executable_Block.If));
                }
                else if (token.Type == TokenType.Else)
                {
                    if (PeekToken().Type == TokenType.If)
                    {
                        ReadToken();
                        ElseIf.Add(ParseCondition(true, Executable_Block.If));
                    }
                    else
                    {
                        UndoToken();
                        break;
                    }
                }
                else
                {
                    UndoToken();
                    break;
                }
            }
            if (PeekToken().Type == TokenType.Else)
            {
                ReadToken();
                ret.Else = ParseCondition(false, Executable_Block.If);
            }
            ret.Init(ElseIf);
            m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_IF, ret));
        }
        void ProcessCallIf()
        {
            CodeIf code = (CodeIf)m_scriptInstruction.Operand0;

            if (ProcessAllow(code.If))
            {
                ProcessCondition(code.If);
                return;
            }
            foreach (TempCondition ElseIf in code.ElseIf)
            {
                if (ProcessAllow(ElseIf))
                {
                    ProcessCondition(ElseIf);
                    return;
                }
            }
            if (code.Else != null && ProcessAllow(code.Else))
            {
                ProcessCondition(code.Else);
            }
        }
Beispiel #4
0
        private void ParseIf()
        {
            Token  token;
            CodeIf @if = new CodeIf {
                If = this.ParseCondition(true, Executable_Block.If)
            };
            List <TempCondition> elseIf = new List <TempCondition>();

Label_001A:
            token = this.ReadToken();
            if (token.Type == Scorpio.Compiler.TokenType.ElseIf)
            {
                elseIf.Add(this.ParseCondition(true, Executable_Block.If));
                goto Label_001A;
            }
            if (token.Type == Scorpio.Compiler.TokenType.Else)
            {
                if (this.PeekToken().Type == Scorpio.Compiler.TokenType.If)
                {
                    this.ReadToken();
                    elseIf.Add(this.ParseCondition(true, Executable_Block.If));
                    goto Label_001A;
                }
                this.UndoToken();
            }
            else
            {
                this.UndoToken();
            }
            if (this.PeekToken().Type == Scorpio.Compiler.TokenType.Else)
            {
                this.ReadToken();
                @if.Else = this.ParseCondition(false, Executable_Block.If);
            }
            @if.Init(elseIf);
            this.m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_IF, @if));
        }
        private void ProcessCallIf()
        {
            CodeIf @if = (CodeIf)this.m_scriptInstruction.operand0;

            if (this.ProcessAllow(@if.If))
            {
                this.ProcessCondition(@if.If);
            }
            else
            {
                foreach (TempCondition condition in @if.ElseIf)
                {
                    if (this.ProcessAllow(condition))
                    {
                        this.ProcessCondition(condition);
                        return;
                    }
                }
                if ((@if.Else != null) && this.ProcessAllow(@if.Else))
                {
                    this.ProcessCondition(@if.Else);
                }
            }
        }