public static bool TryToValueType(this BlockType blockType, out WebAssemblyValueType valueType) { switch (blockType) { default: case BlockType.Empty: valueType = default; return(false); case BlockType.Int32: valueType = WebAssemblyValueType.Int32; break; case BlockType.Int64: valueType = WebAssemblyValueType.Int64; break; case BlockType.Float32: valueType = WebAssemblyValueType.Float32; break; case BlockType.Float64: valueType = WebAssemblyValueType.Float64; break; } return(true); }
public GlobalInfo(WebAssemblyValueType type, bool requiresInstance, MethodInfo getter, MethodInfo?setter) { this.Type = type; this.RequiresInstance = requiresInstance; this.Getter = getter; this.Setter = setter; }
internal Local(Reader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } this.Count = reader.ReadVarUInt32(); this.Type = (WebAssemblyValueType)reader.ReadVarInt7(); }
private GlobalImport(Delegate getter, Delegate?setter, WebAssemblyValueType type) { if (getter == null) { throw new ArgumentNullException(nameof(getter)); } this.Getter = getter; this.Setter = setter; this.GetterType = type; }
public static System.Type ToSystemType(this WebAssemblyValueType valueType) { switch (valueType) { case WebAssemblyValueType.Int32: return(typeof(int)); case WebAssemblyValueType.Int64: return(typeof(long)); case WebAssemblyValueType.Float32: return(typeof(float)); case WebAssemblyValueType.Float64: return(typeof(double)); default: throw new System.ArgumentOutOfRangeException(nameof(valueType), $"{nameof(WebAssemblyValueType)} {valueType} not recognized."); } }
static Instance <SelectTester <T> > CreateTester <T>(WebAssemblyValueType type) where T : struct { var module = new Module(); module.Types.Add(new WebAssemblyType { Parameters = new WebAssemblyValueType[] { type, type, WebAssemblyValueType.Int32, }, Returns = new[] { type, }, }); module.Functions.Add(new Function { }); module.Exports.Add(new Export { Name = nameof(SelectTester <T> .Test), }); module.Codes.Add(new FunctionBody { Code = new Instruction[] { new LocalGet(0), new LocalGet(1), new LocalGet(2), new Select(), new End(), }, }); return(module.ToInstance <SelectTester <T> >()); }
public Signature(WebAssemblyValueType returnType) : this() { this.ReturnTypes = new[] { returnType.ToSystemType() }; this.RawReturnTypes = new[] { returnType }; }
/// <summary> /// Creates a new <see cref="StackTypeInvalidException"/> with the provided parameters. /// </summary> /// <param name="miscellaneousOpCode">The miscellaneous operation attempted.</param> /// <param name="expected">The expected value type.</param> /// <param name="actual">The actual value type.</param> public StackTypeInvalidException(MiscellaneousOpCode miscellaneousOpCode, WebAssemblyValueType expected, WebAssemblyValueType actual) : base(miscellaneousOpCode, $"requires the top stack item to be {expected}, found {actual}.") { this.Expected = expected; this.Actual = actual; }
public static System.Type ToSystemType(this WebAssemblyValueType valueType) => valueType switch {
public static bool TryConvertToValueType(this System.Type type, out WebAssemblyValueType value) => systemTypeToValueType.Reference.TryGetValue(type, out value);
/// <summary> /// Creates a new <see cref="StackParameterMismatchException"/> with the provided parameters. /// </summary> /// <param name="opCode">The operation attempted.</param> /// <param name="first">The first parameter type.</param> /// <param name="second">The second parameter type.</param> public StackParameterMismatchException(OpCode opCode, WebAssemblyValueType first, WebAssemblyValueType second) : base(opCode, $"requires the type parameters to match, found {first} and {second}.") { this.First = first; this.Second = second; }
private GlobalImport(Delegate getter, Delegate?setter, WebAssemblyValueType type) { this.Getter = getter; this.Setter = setter; this.GetterType = type; }
/// <summary> /// Creates a new <see cref="Global"/> instance with the provided parameters. /// </summary> /// <param name="module">The module portion of the name.</param> /// <param name="field">The field portion of the name.</param> /// <param name="contentType">Type of the value.</param> public Global(string module, string field, WebAssemblyValueType contentType = WebAssemblyValueType.Int32) : base(module, field) { this.ContentType = contentType; }