summaryrefslogtreecommitdiffstats
path: root/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
diff options
context:
space:
mode:
authorAndrew Wilkins <axwalk@gmail.com>2016-03-15 05:36:43 +0000
committerAndrew Wilkins <axwalk@gmail.com>2016-03-15 05:36:43 +0000
commit6436a4abd7a2f3a60b230453295dba199d8a59c3 (patch)
tree125aef80fc2cf46c5d1758a8ece1fde14e7b13fd /llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
parent36761bf92427846ce40fdd849615732c852e44dd (diff)
downloadbcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.tar.gz
bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.zip
[llgo] Roll gofrontend forward
Switch gofrontend to using go.googlesource.com, and update to 81eb6a3f425b2158c67ee32c0cc973a72ce9d6be. There are various changes required to update to the go 1.5 runtime: typemap.go is changed to accommodate the change in representation for equal/hash algorithms, and the removal of the zero value/type. CMakeLists.txt is updated to add the build tree to the package search path, so internal packages, which are not installed, are found. various files changes due to removal of __go_new_nopointers; the same change as in D11863, but with NoUnwindAttribute added to the added runtime functions which are called with "callOnly". minor cleanups in ssa.go while investigating issues with unwinding/panic handling. Differential Revisision: http://reviews.llvm.org/D15188 llvm-svn: 263536
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go')
-rw-r--r--llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go b/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
index fca2a0980b2..e829a930768 100644
--- a/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
+++ b/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
@@ -7,7 +7,7 @@
// in the documentation for the Marshal and Unmarshal functions.
//
// See "JSON and Go" for an introduction to this package:
-// http://golang.org/doc/articles/json_and_go.html
+// https://golang.org/doc/articles/json_and_go.html
package json
import (
@@ -79,8 +79,8 @@ import (
//
// The "string" option signals that a field is stored as JSON inside a
// JSON-encoded string. It applies only to fields of string, floating point,
-// or integer types. This extra level of encoding is sometimes used when
-// communicating with JavaScript programs:
+// integer, or boolean types. This extra level of encoding is sometimes used
+// when communicating with JavaScript programs:
//
// Int64String int64 `json:",string"`
//
@@ -113,8 +113,8 @@ import (
// a JSON tag of "-".
//
// Map values encode as JSON objects.
-// The map's key type must be string; the object keys are used directly
-// as map keys.
+// The map's key type must be string; the map keys are used as JSON object
+// keys, subject to the UTF-8 coercion described for string values above.
//
// Pointer values encode as the value pointed to.
// A nil pointer encodes as the null JSON object.
@@ -275,8 +275,6 @@ func (e *encodeState) error(err error) {
panic(err)
}
-var byteSliceType = reflect.TypeOf([]byte(nil))
-
func isEmptyValue(v reflect.Value) bool {
switch v.Kind() {
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
@@ -1024,7 +1022,7 @@ func typeFields(t reflect.Type) []field {
// Scan f.typ for fields to include.
for i := 0; i < f.typ.NumField(); i++ {
sf := f.typ.Field(i)
- if sf.PkgPath != "" { // unexported
+ if sf.PkgPath != "" && !sf.Anonymous { // unexported
continue
}
tag := sf.Tag.Get("json")
@@ -1045,6 +1043,19 @@ func typeFields(t reflect.Type) []field {
ft = ft.Elem()
}
+ // Only strings, floats, integers, and booleans can be quoted.
+ quoted := false
+ if opts.Contains("string") {
+ switch ft.Kind() {
+ case reflect.Bool,
+ reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
+ reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
+ reflect.Float32, reflect.Float64,
+ reflect.String:
+ quoted = true
+ }
+ }
+
// Record found field and index sequence.
if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct {
tagged := name != ""
@@ -1057,7 +1068,7 @@ func typeFields(t reflect.Type) []field {
index: index,
typ: ft,
omitEmpty: opts.Contains("omitempty"),
- quoted: opts.Contains("string"),
+ quoted: quoted,
}))
if count[f.typ] > 1 {
// If there were multiple instances, add a second,
OpenPOWER on IntegriCloud