...
1
16
17 package encoder
18
19 import (
20 `encoding/json`
21 `fmt`
22 `reflect`
23 `strconv`
24 `unsafe`
25
26 `github.com/bytedance/sonic/internal/rt`
27 )
28
29 var _ERR_too_deep = &json.UnsupportedValueError {
30 Str : "Value nesting too deep",
31 Value : reflect.ValueOf("..."),
32 }
33
34 var _ERR_nan_or_infinite = &json.UnsupportedValueError {
35 Str : "NaN or ±Infinite",
36 Value : reflect.ValueOf("NaN or ±Infinite"),
37 }
38
39 func error_type(vtype reflect.Type) error {
40 return &json.UnsupportedTypeError{Type: vtype}
41 }
42
43 func error_number(number json.Number) error {
44 return &json.UnsupportedValueError {
45 Str : "invalid number literal: " + strconv.Quote(string(number)),
46 Value : reflect.ValueOf(number),
47 }
48 }
49
50 func error_marshaler(ret []byte, pos int) error {
51 return fmt.Errorf("invalid Marshaler output json syntax at %d: %q", pos, ret)
52 }
53
54 const (
55 panicNilPointerOfNonEmptyString int = 1 + iota
56 )
57
58 func goPanic(code int, val unsafe.Pointer) {
59 switch(code){
60 case panicNilPointerOfNonEmptyString:
61 panic(fmt.Sprintf("val: %#v has nil pointer while its length is not zero!", (*rt.GoString)(val)))
62 default:
63 panic("encoder error!")
64 }
65 }
66
View as plain text