public Opcode Step(BinaryReader reader) { EffectOperand operand = (EffectOperand)reader.ReadByte(); if (this.mOpcodes.TryGetValue(operand, out Type opcodeType) == false) { throw new DogmaMachineException($"Unknown opcode {operand}"); } // create a new instance for this opcode Opcode handler = (Opcode)Activator.CreateInstance(opcodeType, this); // load it with the required data return(handler.LoadOpcode(reader)); }
/// <summary> /// Writes a marshal opcode to the stream /// </summary> /// <param name="w">The binary writer in use</param> /// <param name="op">The opcode to write</param> public static void WriteOperand(this BinaryWriter w, EffectOperand op) { w.Write((byte)op); }