71
71
72
72
73
73
74
- decode (io:: IO , :: Val{TYPE_0} ) = decode_unsigned (io)
74
+ decode_internal (io:: IO , :: Val{TYPE_0} ) = decode_unsigned (io)
75
75
76
- function decode (io:: IO , :: Val{TYPE_1} )
76
+ function decode_internal (io:: IO , :: Val{TYPE_1} )
77
77
data = signed (decode_unsigned (io))
78
78
if (i = Int128 (data) + one (data)) > typemax (Int64)
79
79
return - i
85
85
"""
86
86
Decode Byte Array
87
87
"""
88
- function decode (io:: IO , :: Val{TYPE_2} )
88
+ function decode_internal (io:: IO , :: Val{TYPE_2} )
89
89
if (peekbyte (io) & ADDNTL_INFO_MASK) == ADDNTL_INFO_INDEF
90
90
skip (io, 1 )
91
91
result = IOBuffer ()
92
92
while peekbyte (io) != = BREAK_INDEF
93
- write (result, decode (io))
93
+ write (result, decode_internal (io))
94
94
end
95
95
return take! (result)
96
96
else
@@ -101,12 +101,12 @@ end
101
101
"""
102
102
Decode String
103
103
"""
104
- function decode (io:: IO , :: Val{TYPE_3} )
104
+ function decode_internal (io:: IO , :: Val{TYPE_3} )
105
105
if (peekbyte (io) & ADDNTL_INFO_MASK) == ADDNTL_INFO_INDEF
106
106
skip (io, 1 )
107
107
result = IOBuffer ()
108
108
while peekbyte (io) != = BREAK_INDEF
109
- write (result, decode (io))
109
+ write (result, decode_internal (io))
110
110
end
111
111
return String (take! (result))
112
112
else
@@ -117,25 +117,25 @@ end
117
117
"""
118
118
Decode Vector of arbitrary elements
119
119
"""
120
- function decode (io:: IO , :: Val{TYPE_4} )
121
- return map (identity, decode_ntimes (decode , io))
120
+ function decode_internal (io:: IO , :: Val{TYPE_4} )
121
+ return map (identity, decode_ntimes (decode_internal , io))
122
122
end
123
123
124
124
"""
125
125
Decode Dict
126
126
"""
127
- function decode (io:: IO , :: Val{TYPE_5} )
127
+ function decode_internal (io:: IO , :: Val{TYPE_5} )
128
128
return Dict (decode_ntimes (io) do io
129
- decode (io) => decode (io)
129
+ decode_internal (io) => decode_internal (io)
130
130
end )
131
131
end
132
132
133
133
"""
134
134
Decode Tagged type
135
135
"""
136
- function decode (io:: IO , :: Val{TYPE_6} )
136
+ function decode_internal (io:: IO , :: Val{TYPE_6} )
137
137
tag = decode_unsigned (io)
138
- data = decode (io)
138
+ data = decode_internal (io)
139
139
if tag in (POS_BIG_INT_TAG, NEG_BIG_INT_TAG)
140
140
big_int = parse (
141
141
BigInt, bytes2hex (data), base = HEX_BASE
@@ -157,7 +157,7 @@ function decode(io::IO, ::Val{TYPE_6})
157
157
return Tag (tag, data)
158
158
end
159
159
160
- function decode (io:: IO , :: Val{TYPE_7} )
160
+ function decode_internal (io:: IO , :: Val{TYPE_7} )
161
161
first_byte = read (io, UInt8)
162
162
addntl_info = first_byte & ADDNTL_INFO_MASK
163
163
if addntl_info < SINGLE_BYTE_SIMPLE_PLUS_ONE + 1
@@ -190,16 +190,16 @@ function decode(io::IO, ::Val{TYPE_7})
190
190
end
191
191
end
192
192
193
- function decode (io:: IO )
193
+ function decode_internal (io:: IO )
194
194
# leave startbyte in io
195
195
first_byte = peekbyte (io)
196
196
typ = first_byte & TYPE_BITS_MASK
197
- typ == TYPE_0 && return decode (io, Val (TYPE_0))
198
- typ == TYPE_1 && return decode (io, Val (TYPE_1))
199
- typ == TYPE_2 && return decode (io, Val (TYPE_2))
200
- typ == TYPE_3 && return decode (io, Val (TYPE_3))
201
- typ == TYPE_4 && return decode (io, Val (TYPE_4))
202
- typ == TYPE_5 && return decode (io, Val (TYPE_5))
203
- typ == TYPE_6 && return decode (io, Val (TYPE_6))
204
- typ == TYPE_7 && return decode (io, Val (TYPE_7))
197
+ typ == TYPE_0 && return decode_internal (io, Val (TYPE_0))
198
+ typ == TYPE_1 && return decode_internal (io, Val (TYPE_1))
199
+ typ == TYPE_2 && return decode_internal (io, Val (TYPE_2))
200
+ typ == TYPE_3 && return decode_internal (io, Val (TYPE_3))
201
+ typ == TYPE_4 && return decode_internal (io, Val (TYPE_4))
202
+ typ == TYPE_5 && return decode_internal (io, Val (TYPE_5))
203
+ typ == TYPE_6 && return decode_internal (io, Val (TYPE_6))
204
+ typ == TYPE_7 && return decode_internal (io, Val (TYPE_7))
205
205
end
0 commit comments