Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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
Show 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 {
...
@@ -403,8 +403,6 @@ func (o *OverflowCheck) PopChecked() bool {
return
popret
return
popret
}
}
// Add and AddExpr update .checkSize accordingly, but only if overflow was not
// Add and AddExpr update .checkSize accordingly, but only if overflow was not
// already marked as checked
// already marked as checked
func
(
o
*
OverflowCheck
)
Add
(
n
int
)
{
func
(
o
*
OverflowCheck
)
Add
(
n
int
)
{
...
@@ -518,7 +516,6 @@ func (e *encoder) generatedCode() string {
...
@@ -518,7 +516,6 @@ func (e *encoder) generatedCode() string {
return
code
.
String
()
return
code
.
String
()
}
}
// XXX place? naming?
// data = data[n:]
// data = data[n:]
// n = 0
// n = 0
func
(
d
*
decoder
)
resetPos
()
{
func
(
d
*
decoder
)
resetPos
()
{
...
@@ -556,7 +553,7 @@ func (d *decoder) overflowCheck() {
...
@@ -556,7 +553,7 @@ func (d *decoder) overflowCheck() {
d
.
bufDone
.
emit
(
"if uint32(len(data)) < %v { goto overflow }"
,
&
d
.
overflow
.
checkSize
)
d
.
bufDone
.
emit
(
"if uint32(len(data)) < %v { goto overflow }"
,
&
d
.
overflow
.
checkSize
)
// if size for overflow check was only numeric - just
// 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.
// otherwise accumulate into var(nread) at runtime.
// we do not break runtime accumulation into numeric & symbolic
// 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) {
...
@@ -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
(
"for i := 0; uint32(i) <l; i++ {"
)
e
.
emit
(
"a := &%s[i]"
,
path
)
e
.
emit
(
"a := &%s[i]"
,
path
)
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
e
)
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
.
emit
(
"}"
)
e
.
emit
(
"}"
)
e
.
n
=
0
e
.
n
=
0
...
@@ -854,6 +851,7 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
...
@@ -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
.
genBasic
(
"l"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
e
.
n
=
0
e
.
n
=
0
// output keys in sorted order on the wire
// output keys in sorted order on the wire
// (easier for debugging & deterministic for testing)
// (easier for debugging & deterministic for testing)
e
.
emit
(
"keyv := make([]%s, 0, l)"
,
typeName
(
typ
.
Key
()))
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) {
...
@@ -861,6 +859,7 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e
.
emit
(
" keyv = append(keyv, key)"
)
e
.
emit
(
" keyv = append(keyv, key)"
)
e
.
emit
(
"}"
)
e
.
emit
(
"}"
)
e
.
emit
(
"sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })"
)
e
.
emit
(
"sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })"
)
e
.
emit
(
"for _, key := range keyv {"
)
e
.
emit
(
"for _, key := range keyv {"
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
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) {
...
@@ -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
// if size(key,item)==const - check overflow in one go
keySize
,
keyFixed
:=
typeSizeFixed
(
typ
.
Key
())
keySize
,
keyFixed
:=
typeSizeFixed
(
typ
.
Key
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
itemFixed
:=
keyFixed
&&
elemFixed
if
keyFixed
&&
elemFixed
{
if
itemFixed
{
d
.
overflowCheck
()
d
.
overflowCheck
()
d
.
overflow
.
AddExpr
(
"l * %v"
,
keySize
+
elemSize
)
d
.
overflow
.
AddExpr
(
"l * %v"
,
keySize
+
elemSize
)
d
.
overflow
.
PushChecked
(
true
)
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