/// <summary> /// Creates a new <see cref="OpCodeCompilationException"/> with the provided parameters. /// </summary> /// <param name="miscellaneousOpCode">The miscellaneous operation attempted.</param> /// <param name="message">An explanation of the problem, concatenated with <paramref name="miscellaneousOpCode"/> and passed to the base as the message.</param> public OpCodeCompilationException(MiscellaneousOpCode miscellaneousOpCode, string message) : base($"{miscellaneousOpCode} {message}") { this.OpCode = OpCode.MiscellaneousOperationPrefix; this.MiscellaneousOpCode = miscellaneousOpCode; }
/// <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 void Instruction_NameMatchesMiscellaneousOpcode() { var mismatch = string.Join(", ", InstructionTypes .Where(x => x.IsSubclassOf(typeof(MiscellaneousInstruction))) .Select(type => ( MiscellaneousOpCode: ((MiscellaneousInstruction)type.GetConstructor(System.Type.EmptyTypes) !.Invoke(null)).MiscellaneousOpCode.ToString(), TypeName: type.Name )) .Where(result => result.MiscellaneousOpCode != result.TypeName) .Select(result => result.TypeName) ); Assert.AreEqual("", mismatch, "Instructions whose name do not match their miscellaneous opcode found."); }
/// <summary> /// Creates a new <see cref="StackTooSmallException"/> with the provided parameters. /// </summary> /// <param name="miscellaneousOpCode">The miscellaneous operation attempted.</param> /// <param name="minimum">The minimum acceptable stack height.</param> /// <param name="actual">The actual stack height at the time the operation was attempted.</param> public StackTooSmallException(MiscellaneousOpCode miscellaneousOpCode, int minimum, int actual) : base(miscellaneousOpCode, $"requires at least {minimum} values on the stack, found {actual}.") { this.Minimum = minimum; this.Actual = actual; }