Skip to content

Commit

Permalink
consistently renamed receivers of value type string methods
Browse files Browse the repository at this point in the history
  • Loading branch information
deelawn committed Oct 28, 2023
1 parent 02c7bae commit 25455af
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions gnovm/pkg/gnolang/values_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,109 +13,109 @@ func (v StringValue) String() string {
return strconv.Quote(string(v))
}

func (bv BigintValue) String() string {
return bv.V.String()
func (v BigintValue) String() string {
return v.V.String()
}

func (bv BigdecValue) String() string {
return bv.V.String()
func (v BigdecValue) String() string {
return v.V.String()
}

func (dbv DataByteValue) String() string {
return fmt.Sprintf("(%0X)", (dbv.GetByte()))
func (v DataByteValue) String() string {
return fmt.Sprintf("(%0X)", (v.GetByte()))
}

func (av *ArrayValue) String() string {
return av.ProtectedString(map[Value]struct{}{})
func (v *ArrayValue) String() string {
return v.ProtectedString(map[Value]struct{}{})
}

func (av *ArrayValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[av]; ok {
func (v *ArrayValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[v]; ok {
return recursed
}

seen[av] = struct{}{}
ss := make([]string, len(av.List))
if av.Data == nil {
for i, e := range av.List {
seen[v] = struct{}{}
ss := make([]string, len(v.List))
if v.Data == nil {
for i, e := range v.List {
ss[i] = e.ProtectedString(seen)
}
// NOTE: we may want to unify the representation,
// but for now tests expect this to be different.
// This may be helpful for testing implementation behavior.
return "array[" + strings.Join(ss, ",") + "]"
}
if len(av.Data) > 256 {
return fmt.Sprintf("array[0x%X...]", av.Data[:256])
if len(v.Data) > 256 {
return fmt.Sprintf("array[0x%X...]", v.Data[:256])
}
return fmt.Sprintf("array[0x%X]", av.Data)
return fmt.Sprintf("array[0x%X]", v.Data)
}

func (sv *SliceValue) String() string {
return sv.ProtectedString(map[Value]struct{}{})
func (v *SliceValue) String() string {
return v.ProtectedString(map[Value]struct{}{})
}

func (sv *SliceValue) ProtectedString(seen map[Value]struct{}) string {
if sv.Base == nil {
func (v *SliceValue) ProtectedString(seen map[Value]struct{}) string {
if v.Base == nil {
return "nil-slice"
}

if _, ok := seen[sv]; ok {
if _, ok := seen[v]; ok {
return recursed
}

if ref, ok := sv.Base.(RefValue); ok {
if ref, ok := v.Base.(RefValue); ok {
return fmt.Sprintf("slice[%v]", ref)
}

seen[sv] = struct{}{}
vbase := sv.Base.(*ArrayValue)
seen[v] = struct{}{}
vbase := v.Base.(*ArrayValue)
if vbase.Data == nil {
ss := make([]string, sv.Length)
for i, e := range vbase.List[sv.Offset : sv.Offset+sv.Length] {
ss := make([]string, v.Length)
for i, e := range vbase.List[v.Offset : v.Offset+v.Length] {
ss[i] = e.ProtectedString(seen)
}
return "slice[" + strings.Join(ss, ",") + "]"
}
if sv.Length > 256 {
return fmt.Sprintf("slice[0x%X...(%d)]", vbase.Data[sv.Offset:sv.Offset+256], sv.Length)
if v.Length > 256 {
return fmt.Sprintf("slice[0x%X...(%d)]", vbase.Data[v.Offset:v.Offset+256], v.Length)
}
return fmt.Sprintf("slice[0x%X]", vbase.Data[sv.Offset:sv.Offset+sv.Length])
return fmt.Sprintf("slice[0x%X]", vbase.Data[v.Offset:v.Offset+v.Length])
}

func (pv PointerValue) String() string {
return pv.ProtectedString(map[Value]struct{}{})
func (v PointerValue) String() string {
return v.ProtectedString(map[Value]struct{}{})
}

func (pv PointerValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[pv]; ok {
func (v PointerValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[v]; ok {
return recursed
}

seen[pv] = struct{}{}
return fmt.Sprintf("&%s", pv.TV.ProtectedString(seen))
seen[v] = struct{}{}
return fmt.Sprintf("&%s", v.TV.ProtectedString(seen))
}

func (sv *StructValue) String() string {
return sv.ProtectedString(map[Value]struct{}{})
func (v *StructValue) String() string {
return v.ProtectedString(map[Value]struct{}{})
}

func (sv *StructValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[sv]; ok {
func (v *StructValue) ProtectedString(seen map[Value]struct{}) string {
if _, ok := seen[v]; ok {
return recursed
}

seen[sv] = struct{}{}
ss := make([]string, len(sv.Fields))
for i, f := range sv.Fields {
seen[v] = struct{}{}
ss := make([]string, len(v.Fields))
for i, f := range v.Fields {
ss[i] = f.ProtectedString(seen)
}
return "struct{" + strings.Join(ss, ",") + "}"
}

func (fv *FuncValue) String() string {
name := string(fv.Name)
if fv.Type == nil {
func (v *FuncValue) String() string {
name := string(v.Name)
if v.Type == nil {
return fmt.Sprintf("incomplete-func ?%s(?)?", name)
}
return name
Expand All @@ -140,22 +140,22 @@ func (v *BoundMethodValue) String() string {
recvT, name, params, results)
}

func (mv *MapValue) String() string {
return mv.ProtectedString(map[Value]struct{}{})
func (v *MapValue) String() string {
return v.ProtectedString(map[Value]struct{}{})
}

func (mv *MapValue) ProtectedString(seen map[Value]struct{}) string {
if mv.List == nil {
func (v *MapValue) ProtectedString(seen map[Value]struct{}) string {
if v.List == nil {
return "zero-map"
}

if _, ok := seen[mv]; ok {
if _, ok := seen[v]; ok {
return recursed
}

seen[mv] = struct{}{}
ss := make([]string, 0, mv.GetLength())
next := mv.List.Head
seen[v] = struct{}{}
ss := make([]string, 0, v.GetLength())
next := v.List.Head
for next != nil {
ss = append(ss,
next.Key.String()+":"+
Expand All @@ -180,13 +180,13 @@ func (v TypeValue) String() string {
v.Type.String(), ptr)
}

func (pv *PackageValue) String() string {
return fmt.Sprintf("package(%s %s)", pv.PkgName, pv.PkgPath)
func (v *PackageValue) String() string {
return fmt.Sprintf("package(%s %s)", v.PkgName, v.PkgPath)
}

func (nv *NativeValue) String() string {
func (v *NativeValue) String() string {
return fmt.Sprintf("gonative{%v}",
nv.Value.Interface())
v.Value.Interface())
/*
return fmt.Sprintf("gonative{%v (%s)}",
v.Value.Interface(),
Expand Down

0 comments on commit 25455af

Please sign in to comment.