mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 06:23:39 +00:00
interp: move some often-repeated code into a function
This commit is contained in:
committed by
Ron Evans
parent
2fb866ca86
commit
54c07b7de8
@@ -373,6 +373,22 @@ type literalValue struct {
|
||||
value interface{}
|
||||
}
|
||||
|
||||
// Make a literalValue given the number of bits.
|
||||
func makeLiteralInt(value uint64, bits int) literalValue {
|
||||
switch bits {
|
||||
case 64:
|
||||
return literalValue{value}
|
||||
case 32:
|
||||
return literalValue{uint32(value)}
|
||||
case 16:
|
||||
return literalValue{uint16(value)}
|
||||
case 8:
|
||||
return literalValue{uint8(value)}
|
||||
default:
|
||||
panic("unknown integer size")
|
||||
}
|
||||
}
|
||||
|
||||
func (v literalValue) len(r *runner) uint32 {
|
||||
switch v.value.(type) {
|
||||
case uint64:
|
||||
|
||||
Reference in New Issue
Block a user