You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
538 B

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. package vm
  2. import (
  3. "encoding/binary"
  4. )
  5. func Uint64ToWord(i uint64) Word {
  6. word := Word{}
  7. PutUint64(word[:], i)
  8. return word
  9. }
  10. func BytesToWord(bz []byte) Word {
  11. word := Word{}
  12. copy(word[:], bz)
  13. return word
  14. }
  15. func LeftPadWord(bz []byte) (word Word) {
  16. copy(word[:], bz)
  17. return
  18. }
  19. func RightPadWord(bz []byte) (word Word) {
  20. copy(word[32-len(bz):], bz)
  21. return
  22. }
  23. func GetUint64(word Word) uint64 {
  24. return binary.LittleEndian.Uint64(word[:])
  25. }
  26. func PutUint64(dest []byte, i uint64) {
  27. binary.LittleEndian.PutUint64(dest, i)
  28. }