Move operand type lists into the vm
This commit is contained in:
@@ -44,7 +44,7 @@ func disassembleInstruction(in *vm.Instruction) (string, error) {
|
||||
nameByOpCode[in.OpCode],
|
||||
}
|
||||
|
||||
for i, t := range operandsByOpCode[in.OpCode] {
|
||||
for i, t := range vm.OperandsByOpCode[in.OpCode] {
|
||||
op, err := disassembleOperand(in.Operands[i], t)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -58,7 +58,7 @@ func disassembleInstruction(in *vm.Instruction) (string, error) {
|
||||
return encoded, nil
|
||||
}
|
||||
|
||||
func disassembleOperand(op *vm.Operand, t operandType) (string, error) {
|
||||
func disassembleOperand(op *vm.Operand, t vm.OperandNumericType) (string, error) {
|
||||
switch op.Type {
|
||||
case vm.GlobalMemoryIndex:
|
||||
return fmt.Sprintf("g%d", op.Value), nil
|
||||
@@ -68,13 +68,13 @@ func disassembleOperand(op *vm.Operand, t operandType) (string, error) {
|
||||
|
||||
case vm.Literal:
|
||||
switch t {
|
||||
case u:
|
||||
case vm.OperandUnsigned:
|
||||
return fmt.Sprintf("%d", op.Value), nil
|
||||
|
||||
case s:
|
||||
case vm.OperandSigned:
|
||||
return fmt.Sprintf("%+d", int64(op.Value)), nil
|
||||
|
||||
case us:
|
||||
case vm.OperandSignedOrUnsigned:
|
||||
// Take our best guess
|
||||
if op.Value > math.MaxInt64 {
|
||||
return fmt.Sprintf("%+d", int64(op.Value)), nil
|
||||
|
||||
Reference in New Issue
Block a user