MCPcopy Index your code
hub / github.com/tinygo-org/tinygo / String

Method String

interp/memory.go:692–718  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

690}
691
692func (v rawValue) String() string {
693 if len(v.buf) == 2 || len(v.buf) == 4 || len(v.buf) == 8 {
694 // Format as a pointer if the entire buf is this pointer.
695 if v.buf[0] > 255 {
696 isPointer := true
697 for _, p := range v.buf {
698 if p != v.buf[0] {
699 isPointer = false
700 break
701 }
702 }
703 if isPointer {
704 return pointerValue{v.buf[0]}.String()
705 }
706 }
707 // Format as number if none of the buf is a pointer.
708 if !v.hasPointer() {
709 // Construct a fake runner, which is little endian.
710 // We only use String() for debugging, so this is is good enough
711 // (the printed value will just be slightly wrong when debugging the
712 // interp package with GOOS=mips for example).
713 r := &runner{byteOrder: binary.LittleEndian}
714 return strconv.FormatInt(v.Int(r), 10)
715 }
716 }
717 return "<[…" + strconv.Itoa(len(v.buf)) + "]>"
718}
719
720func (v rawValue) clone() value {
721 newValue := v

Callers

nothing calls this directly

Calls 3

hasPointerMethod · 0.95
IntMethod · 0.95
StringMethod · 0.65

Tested by

no test coverage detected