Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
6745433a
Commit
6745433a
authored
Jan 27, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fc0cf8de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
t/neo/protogen.go
t/neo/protogen.go
+5
-7
No files found.
t/neo/protogen.go
View file @
6745433a
...
...
@@ -403,8 +403,6 @@ func (o *OverflowCheck) PopChecked() bool {
return
popret
}
// Add and AddExpr update .checkSize accordingly, but only if overflow was not
// already marked as checked
func
(
o
*
OverflowCheck
)
Add
(
n
int
)
{
...
...
@@ -518,7 +516,6 @@ func (e *encoder) generatedCode() string {
return
code
.
String
()
}
// XXX place? naming?
// data = data[n:]
// n = 0
func
(
d
*
decoder
)
resetPos
()
{
...
...
@@ -556,7 +553,7 @@ func (d *decoder) overflowCheck() {
d
.
bufDone
.
emit
(
"if uint32(len(data)) < %v { goto overflow }"
,
&
d
.
overflow
.
checkSize
)
// if size for overflow check was only numeric - just
// accumulate it at
compile
time
// accumulate it at
generation
time
//
// otherwise accumulate into var(nread) at runtime.
// we do not break runtime accumulation into numeric & symbolic
...
...
@@ -782,7 +779,7 @@ func (e *encoder) genSlice(path string, typ *types.Slice, obj types.Object) {
e
.
emit
(
"for i := 0; uint32(i) <l; i++ {"
)
e
.
emit
(
"a := &%s[i]"
,
path
)
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
e
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt slice of slice ?
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
e
.
emit
(
"}"
)
e
.
emit
(
"}"
)
e
.
n
=
0
...
...
@@ -854,6 +851,7 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e
.
genBasic
(
"l"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
e
.
n
=
0
// output keys in sorted order on the wire
// (easier for debugging & deterministic for testing)
e
.
emit
(
"keyv := make([]%s, 0, l)"
,
typeName
(
typ
.
Key
()))
...
...
@@ -861,6 +859,7 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e
.
emit
(
" keyv = append(keyv, key)"
)
e
.
emit
(
"}"
)
e
.
emit
(
"sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })"
)
e
.
emit
(
"for _, key := range keyv {"
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
e
)
...
...
@@ -879,8 +878,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
// if size(key,item)==const - check overflow in one go
keySize
,
keyFixed
:=
typeSizeFixed
(
typ
.
Key
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
itemFixed
:=
keyFixed
&&
elemFixed
if
itemFixed
{
if
keyFixed
&&
elemFixed
{
d
.
overflowCheck
()
d
.
overflow
.
AddExpr
(
"l * %v"
,
keySize
+
elemSize
)
d
.
overflow
.
PushChecked
(
true
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment