diff --git a/gnovm/pkg/gnolang/values_string.go b/gnovm/pkg/gnolang/values_string.go index 52497cc3ca7..ed997734c89 100644 --- a/gnovm/pkg/gnolang/values_string.go +++ b/gnovm/pkg/gnolang/values_string.go @@ -13,31 +13,31 @@ 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, @@ -45,77 +45,77 @@ func (av *ArrayValue) ProtectedString(seen map[Value]struct{}) string { // 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 @@ -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()+":"+ @@ -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(),