Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 /// <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)));
 }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 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;
 }