示例#1
0
        void ProcessCallFor()
        {
            CodeFor       code         = (CodeFor)m_scriptInstruction.Operand0;
            ScriptContext context      = code.Context;
            ScriptContext blockContext = code.BlockContext;

            context.Initialize(this);
            context.Execute(code.BeginExecutable);
            ScriptBoolean Condition;

            for ( ; ;)
            {
                if (code.Condition != null)
                {
                    Condition = context.ResolveOperand(code.Condition) as ScriptBoolean;
                    if (Condition == null)
                    {
                        throw new ExecutionException("for 跳出条件必须是一个bool型");
                    }
                    if (!Condition.Value)
                    {
                        break;
                    }
                }
                blockContext.Initialize(context);
                blockContext.Execute();
                if (blockContext.IsBreak)
                {
                    break;
                }
                context.Execute(code.LoopExecutable);
            }
        }
示例#2
0
        //解析正规for循环
        private void ParseFor_impl()
        {
            CodeFor ret   = new CodeFor();
            Token   token = ReadToken();

            if (token.Type != TokenType.SemiColon)
            {
                UndoToken();
                ret.BeginExecutable = ParseStatementBlock(Executable_Block.ForBegin, false, TokenType.SemiColon);
            }
            token = ReadToken();
            if (token.Type != TokenType.SemiColon)
            {
                UndoToken();
                ret.Condition = GetObject();
                ReadSemiColon();
            }
            token = ReadToken();
            if (token.Type != TokenType.RightPar)
            {
                UndoToken();
                ret.LoopExecutable = ParseStatementBlock(Executable_Block.ForLoop, false, TokenType.RightPar);
            }
            ret.BlockExecutable = ParseStatementBlock(Executable_Block.For);
            m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_FOR, ret));
        }
示例#3
0
    public void SetUpCodeForEnd(Transform code)
    {
        int     index = code.GetSiblingIndex() + 1;
        CodeFor cF    = code.GetComponent <CodeFor>();

        cF.codeEnd = Instantiate(codeForEnd, code.parent);
        cF.codeEnd.SetSiblingIndex(index);

        CodeForEnd cFE = cF.codeEnd.GetComponent <CodeForEnd>();

        cFE.arrow       = cFE.transform.Find("Arrow").GetComponent <RectTransform>();
        cFE.codeFor     = code;
        cFE.canvasGroup = cFE.GetComponent <CanvasGroup>();
        cFE.SetUpArrow();
    }
示例#4
0
        private void ProcessCallFor()
        {
            CodeFor       @for   = (CodeFor)this.m_scriptInstruction.operand0;
            ScriptContext parent = new ScriptContext(this.m_script, null, this, Executable_Block.For);

            parent.Execute(@for.BeginExecutable);
            while ((@for.Condition == null) || parent.ResolveOperand(@for.Condition).LogicOperation())
            {
                ScriptContext context2 = new ScriptContext(this.m_script, @for.BlockExecutable, parent, Executable_Block.For);
                context2.Execute();
                if (context2.IsOver)
                {
                    return;
                }
                parent.Execute(@for.LoopExecutable);
            }
            return;
        }
示例#5
0
        void ProcessCallFor()
        {
            CodeFor       code    = (CodeFor)m_scriptInstruction.operand0;
            ScriptContext context = new ScriptContext(m_script, null, this, Executable_Block.For);

            context.Execute(code.BeginExecutable);
            ScriptContext blockContext;

            while (code.Condition == null || context.ResolveOperand(code.Condition).LogicOperation())
            {
                blockContext = new ScriptContext(m_script, code.BlockExecutable, context, Executable_Block.For);
                blockContext.Execute();
                if (blockContext.IsOver)
                {
                    break;
                }
                context.Execute(code.LoopExecutable);
            }
        }
示例#6
0
        private void ParseFor_impl()
        {
            CodeFor @for = new CodeFor();

            if (this.ReadToken().Type != Scorpio.Compiler.TokenType.SemiColon)
            {
                this.UndoToken();
                @for.BeginExecutable = this.ParseStatementBlock(Executable_Block.ForBegin, false, Scorpio.Compiler.TokenType.SemiColon);
            }
            if (this.ReadToken().Type != Scorpio.Compiler.TokenType.SemiColon)
            {
                this.UndoToken();
                @for.Condition = this.GetObject();
                this.ReadSemiColon();
            }
            if (this.ReadToken().Type != Scorpio.Compiler.TokenType.RightPar)
            {
                this.UndoToken();
                @for.LoopExecutable = this.ParseStatementBlock(Executable_Block.ForLoop, false, Scorpio.Compiler.TokenType.RightPar);
            }
            @for.BlockExecutable = this.ParseStatementBlock(Executable_Block.For);
            this.m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_FOR, @for));
        }