Skip to content

Commit 6cf90ad

Browse files
dannypsnlmewmew
authored andcommitted
(#111) handle u0x/s0x prefix (#114)
ref #111 (comment)
1 parent 2a823f8 commit 6cf90ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: asm/helper.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,20 @@ func boolLit(old ast.BoolLit) bool {
166166
// unsigned integer literal.
167167
func uintLit(old ast.UintLit) uint64 {
168168
text := old.Text()
169-
x, err := strconv.ParseUint(text, 10, 64)
169+
var x uint64
170+
var err error
171+
switch {
172+
case strings.HasPrefix(text, "u0x"):
173+
text = text[len("u0x"):]
174+
x, err = strconv.ParseUint(text, 16, 64)
175+
case strings.HasPrefix(text, "s0x"):
176+
text = text[len("s0x"):]
177+
// TODO: figure out how to handle negative values.
178+
// The problem at here was we should return an int64 but since signature parse as uint64
179+
x, err = strconv.ParseUint(text, 16, 64)
180+
default:
181+
x, err = strconv.ParseUint(text, 10, 64)
182+
}
170183
if err != nil {
171184
panic(fmt.Errorf("unable to parse unsigned integer literal %q; %v", text, err))
172185
}

0 commit comments

Comments
 (0)