Пример #1
0
        unsafe public CtrlFrame PopCtrl(List <byte> expanded)
        {
            if (this.ctrls.Count == 0)
            {
                throw new System.Exception("Error popping control frame, control frame stack mismatch.");
            }

            CtrlFrame frame = this.ctrls.Peek();

            this.PopOpds(frame.endTypes);

            if (frame.returnedInside == true)
            {
                while (this.opds.Count > frame.height)
                {
                    this.PopOpd();
                }
            }

            // We don't do return value checking here - just stack matching for
            // all other logic nesting.
            if (this.ctrls.Count != 1 && this.opds.Count != frame.height)
            {
                throw new System.Exception("Error popping control frame, variable stack mismatch.");
            }

            this.ctrls.Pop();

            if (frame.opcode == Instruction.loop)
            {
                //Function.TransferInstruction(expanded, Instruction._goto);
                //Function.TransferInt32u(expanded, frame.loopStart);
                frame.FlushEndWrites(expanded, frame.loopStart);
            }
            else
            {
                frame.FlushEndWrites(expanded);
            }

            return(frame);
        }
Пример #2
0
        public CtrlFrame PushCtrl(
            Instruction opcode,
            List <StackOpd> instk,
            List <StackOpd> outstk,
            DataStoreIdx memStore,
            DataStoreIdx globStore,
            DataStoreIdx tabStore)
        {
            CtrlFrame frame = new CtrlFrame();

            frame.opcode      = opcode;
            frame.startTypes  = instk;
            frame.endTypes    = outstk;
            frame.unreachable = false;
            frame.height      = this.opds.Count;
            frame.memoryStore = memStore;
            frame.globalStore = globStore;
            frame.tableStore  = tabStore;
            this.ctrls.Push(frame);
            this.PushOpds(instk);

            return(frame);
        }
Пример #3
0
        public bool MatchesLabelTypes(CtrlFrame other)
        {
            List <StackOpd> otherTys = other.LabelTypes();

            return(this.MatchesLabelTypes(otherTys));
        }