Correct MSIZE args
This commit is contained in:
parent
1c11e5881a
commit
83fe049b15
@ -84,12 +84,12 @@ func ToString(b []byte) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
case MSIZE:
|
case MSIZE:
|
||||||
r, bb, err := ParseMSize(b)
|
r, v, bb, err := ParseMSize(b)
|
||||||
b = bb
|
b = bb
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
s = fmt.Sprintf("%s %v", s, r)
|
s = fmt.Sprintf("%s %v %v", s, r, v)
|
||||||
case MOUT:
|
case MOUT:
|
||||||
r, v, bb, err := ParseMOut(b)
|
r, v, bb, err := ParseMOut(b)
|
||||||
b = bb
|
b = bb
|
||||||
|
@ -121,12 +121,12 @@ func TestToString(t *testing.T) {
|
|||||||
t.Fatalf("expected:\n\t%v\ngot:\n\t%v", expect, r)
|
t.Fatalf("expected:\n\t%v\ngot:\n\t%v", expect, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
b = NewLine(nil, MSIZE, nil, nil, []uint8{0x42})
|
b = NewLine(nil, MSIZE, nil, nil, []uint8{0x42, 0x2a})
|
||||||
r, err = ToString(b)
|
r, err = ToString(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
expect = "MSIZE 66\n"
|
expect = "MSIZE 66 42\n"
|
||||||
if r != expect {
|
if r != expect {
|
||||||
t.Fatalf("expected:\n\t%v\ngot:\n\t%v", expect, r)
|
t.Fatalf("expected:\n\t%v\ngot:\n\t%v", expect, r)
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,8 @@ func RunHalt(b []byte, st *state.State, rs resource.Resource, ctx context.Contex
|
|||||||
// RunMSize
|
// RunMSize
|
||||||
func RunMSize(b []byte, st *state.State, rs resource.Resource, ctx context.Context) ([]byte, error) {
|
func RunMSize(b []byte, st *state.State, rs resource.Resource, ctx context.Context) ([]byte, error) {
|
||||||
log.Printf("WARNING MSIZE not yet implemented")
|
log.Printf("WARNING MSIZE not yet implemented")
|
||||||
return b, nil
|
_, _, b, err := ParseMSize(b)
|
||||||
|
return b, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunMSize
|
// RunMSize
|
||||||
|
11
go/vm/vm.go
11
go/vm/vm.go
@ -55,13 +55,14 @@ func ParseMNext(b []byte) (string, string, []byte, error) {
|
|||||||
return parseTwoSym(b)
|
return parseTwoSym(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseMSize(b []byte) (uint32, []byte, error) {
|
func ParseMSize(b []byte) (uint32, uint32, []byte, error) {
|
||||||
if len(b) < 1 {
|
if len(b) < 2 {
|
||||||
return 0, b, fmt.Errorf("zero-length argument")
|
return 0, 0, b, fmt.Errorf("argument too short")
|
||||||
}
|
}
|
||||||
r := uint32(b[0])
|
r := uint32(b[0])
|
||||||
b = b[1:]
|
rr := uint32(b[1])
|
||||||
return r, b, nil
|
b = b[2:]
|
||||||
|
return r, rr, b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseMOut(b []byte) (string, string, []byte, error) {
|
func ParseMOut(b []byte) (string, string, []byte, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user