Пример #1
0
        public static bool DoDataStoreValidation(
            IReadOnlyList <IndexEntry> idxEntries,
            int operandSrc,
            List <byte> expanded,
            ref DataStoreIdx dstore)
        {
            // Check if we need to change the global store source
            IndexEntry ie = idxEntries[(int)operandSrc];

            if (dstore.Match(ie.type, ie.index) == false)
            {
                if (ie.type == IndexEntry.FnIdxType.Import)
                {
                    Function.TransferInstruction(expanded, Instruction._global_chStoreImp);
                    Function.TransferInt32u(expanded, (uint)ie.index);

                    dstore.Set(DataStoreIdx.Location.Import, ie.index);
                    return(true);
                }
                else
                {
                    Function.TransferInstruction(expanded, Instruction._global_chStoreLoc);
                    Function.TransferInt32u(expanded, (uint)ie.index);

                    dstore.Set(DataStoreIdx.Location.Local, ie.index);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #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 static bool EnsureDefaulTable(IReadOnlyList <IndexEntry> tableIndices, List <byte> expanded, ref DataStoreIdx dsIdx)
        {
            if (dsIdx.loc != DataStoreIdx.Location.Unknown)
            {
                return(false);
            }

            if (tableIndices.Count == 0)
            {
                throw new System.Exception("No tables provided for a function that requires memory storage.");
            }

            IndexEntry ie = tableIndices[0];

            if (ie.type == IndexEntry.FnIdxType.Local)
            {
                dsIdx.loc   = DataStoreIdx.Location.Local;
                dsIdx.index = ie.index;

                Function.TransferInstruction(expanded, Instruction._SetTableStoreLoc);
                Function.TransferInt32s(expanded, ie.index);

                return(true);
            }
            else if (ie.type == IndexEntry.FnIdxType.Import)
            {
                dsIdx.loc   = DataStoreIdx.Location.Import;
                dsIdx.index = ie.index;

                Function.TransferInstruction(expanded, Instruction._SetTableStoreImp);
                Function.TransferInt32s(expanded, ie.index);

                return(true);
            }

            throw new System.Exception("Encountered table from unknown source.");
        }