コード例 #1
0
ファイル: DataSection.cs プロジェクト: blinds52/cs-wasm
        /// <summary>
        /// Reads a data segment from the given WebAssembly reader.
        /// </summary>
        /// <param name="Reader">The WebAssembly reader.</param>
        /// <returns>The data segment that was read from the reader.</returns>
        public static DataSegment ReadFrom(BinaryWasmReader Reader)
        {
            var index      = Reader.ReadVarUInt32();
            var offset     = InitializerExpression.ReadFrom(Reader);
            var dataLength = Reader.ReadVarUInt32();
            var data       = Reader.ReadBytes((int)dataLength);

            return(new DataSegment(index, offset, data));
        }
コード例 #2
0
        /// <summary>
        /// Reads an element segment from the given WebAssembly reader.
        /// </summary>
        /// <param name="Reader">The WebAssembly reader.</param>
        /// <returns>The element segment that was read from the reader.</returns>
        public static ElementSegment ReadFrom(BinaryWasmReader Reader)
        {
            var index      = Reader.ReadVarUInt32();
            var offset     = InitializerExpression.ReadFrom(Reader);
            var dataLength = Reader.ReadVarUInt32();
            var elements   = new List <uint>((int)dataLength);

            for (uint i = 0; i < dataLength; i++)
            {
                elements.Add(Reader.ReadVarUInt32());
            }
            return(new ElementSegment(index, offset, elements));
        }
コード例 #3
0
ファイル: DataSection.cs プロジェクト: blinds52/cs-wasm
 /// <summary>
 /// Creates a data segment from the given memory index, offset and data.
 /// </summary>
 /// <param name="MemoryIndex">The memory index.</param>
 /// <param name="Offset">An i32 initializer expression that computes the offset at which to place the data.</param>
 /// <param name="Data">The data to which a segment of the linear memory is initialized.</param>
 public DataSegment(uint MemoryIndex, InitializerExpression Offset, byte[] Data)
 {
     this.MemoryIndex = MemoryIndex;
     this.Offset      = Offset;
     this.Data        = Data;
 }
コード例 #4
0
 /// <summary>
 /// Creates an element segment from the given table index, offset and data.
 /// </summary>
 /// <param name="TableIndex">The table index.</param>
 /// <param name="Offset">An i32 initializer expression that computes the offset at which to place the data.</param>
 /// <param name="Elements">A sequence of function indices to which a segment of the table is initialized.</param>
 public ElementSegment(uint TableIndex, InitializerExpression Offset, IEnumerable <uint> Elements)
 {
     this.TableIndex = TableIndex;
     this.Offset     = Offset;
     this.Elements   = new List <uint>(Elements);
 }
コード例 #5
0
 /// <summary>
 /// Creates a data segment from the given memory index, offset and data.
 /// </summary>
 /// <param name="memoryIndex">The memory index.</param>
 /// <param name="offset">An i32 initializer expression that computes the offset at which to place the data.</param>
 /// <param name="data">The data to which a segment of the linear memory is initialized.</param>
 public DataSegment(uint memoryIndex, InitializerExpression offset, byte[] data)
 {
     this.MemoryIndex = memoryIndex;
     this.Offset      = offset;
     this.Data        = data;
 }
コード例 #6
0
 /// <summary>
 /// Creates an element segment from the given table index, offset and data.
 /// </summary>
 /// <param name="tableIndex">The table index.</param>
 /// <param name="offset">An i32 initializer expression that computes the offset at which to place the data.</param>
 /// <param name="elements">A sequence of function indices to which a segment of the table is initialized.</param>
 public ElementSegment(uint tableIndex, InitializerExpression offset, IEnumerable <uint> elements)
 {
     this.TableIndex = tableIndex;
     this.Offset     = offset;
     this.Elements   = new List <uint>(elements);
 }
コード例 #7
0
ファイル: GlobalSection.cs プロジェクト: Buildstarted/cs-wasm
 /// <summary>
 /// Reads a global variable definition from the given WebAssembly reader.
 /// </summary>
 /// <param name="reader">The WebAssembly reader to use.</param>
 /// <returns>The global variable definition that was read.</returns>
 public static GlobalVariable ReadFrom(BinaryWasmReader reader)
 {
     return(new GlobalVariable(
                GlobalType.ReadFrom(reader),
                InitializerExpression.ReadFrom(reader)));
 }
コード例 #8
0
ファイル: GlobalSection.cs プロジェクト: Buildstarted/cs-wasm
 /// <summary>
 /// Creates a global variable definition from the given type and initial value.
 /// </summary>
 /// <param name="type">The global variable definition's type.</param>
 /// <param name="initialValue">The global variable definition's initial value.</param>
 public GlobalVariable(GlobalType type, InitializerExpression initialValue)
 {
     this.Type         = type;
     this.InitialValue = initialValue;
 }
コード例 #9
0
 /// <summary>
 /// Creates a global variable definition from the given type and initial value.
 /// </summary>
 /// <param name="Type">The global variable definition's type.</param>
 /// <param name="InitialValue">The global variable definition's initial value.</param>
 public GlobalVariable(GlobalType Type, InitializerExpression InitialValue)
 {
     this.Type         = Type;
     this.InitialValue = InitialValue;
 }