Ejemplo n.º 1
0
        /// <summary>
        /// Reads a single function type from the given reader.
        /// </summary>
        /// <returns>The function type.</returns>
        public static FunctionType ReadFrom(BinaryWasmReader reader)
        {
            WasmType form = (WasmType)reader.ReadWasmType();

            if (form != WasmType.Func)
            {
                throw new WasmException("Invalid 'form' value ('" + form + "') for function type.");
            }

            uint paramCount = reader.ReadVarUInt32();
            var  paramTypes = new List <WasmValueType>((int)paramCount);

            for (uint i = 0; i < paramCount; i++)
            {
                paramTypes.Add(reader.ReadWasmValueType());
            }

            uint retCount = reader.ReadVarUInt32();
            var  retTypes = new List <WasmValueType>((int)retCount);

            for (uint i = 0; i < retCount; i++)
            {
                retTypes.Add(reader.ReadWasmValueType());
            }

            return(new FunctionType(paramTypes, retTypes));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads a single table description from the given reader.
        /// </summary>
        /// <returns>The table description.</returns>
        public static TableType ReadFrom(BinaryWasmReader reader)
        {
            var elemType = (WasmType)reader.ReadWasmType();
            var limits   = reader.ReadResizableLimits();

            return(new TableType(elemType, limits));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the immediates (not the opcode) of a WebAssembly instruction
        /// for this operator from the given reader and returns the result as an
        /// instruction.
        /// </summary>
        /// <param name="Reader">The WebAssembly file reader to read immediates from.</param>
        /// <returns>A WebAssembly instruction.</returns>
        public override Instruction ReadImmediates(BinaryWasmReader Reader)
        {
            var type = Reader.ReadWasmType();

            return(ReadBlockContents(type, Reader));
        }