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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
ce26522f
Commit
ce26522f
authored
Jan 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
23d09bcd
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
88 deletions
+77
-88
t/neo/marshal.go
t/neo/marshal.go
+63
-63
t/neo/protogen.go
t/neo/protogen.go
+14
-25
No files found.
t/neo/marshal.go
View file @
ce26522f
This diff is collapsed.
Click to expand it.
t/neo/protogen.go
View file @
ce26522f
...
...
@@ -338,6 +338,9 @@ type decoder struct {
// size that will be checked for overflow at current overflow check point
overflowCheckSize
size
// whether overflow was already checked for current decodings
overflowChecked
bool
commonCoder
}
...
...
@@ -493,7 +496,9 @@ func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Typ
dataptr
:=
fmt
.
Sprintf
(
"data[%v:]"
,
d
.
n
)
decoded
:=
fmt
.
Sprintf
(
basic
.
decode
,
dataptr
)
d
.
n
+=
basic
.
wireSize
d
.
overflowCheckSize
.
Add
(
basic
.
wireSize
)
if
!
d
.
overflowChecked
{
d
.
overflowCheckSize
.
Add
(
basic
.
wireSize
)
}
if
userType
!=
nil
&&
userType
!=
typ
{
// userType is a named type over some basic, like
// type ClusterState int32
...
...
@@ -601,50 +606,34 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
d
.
emit
(
"{"
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
/*
d.emit("data = data[%v:]", d.pos.num)
d.emit("%v += %v", d.var_("nread"), d.pos.num)
d.flushOverflow()
d.pos = size{} // zero
*/
d
.
resetPos
()
//d.overflowCheckpoint()
//d.pos.AddExpr("l") // FIXME l*sizeof(elem)
/*
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
// if size(item)==const - check l in one go
overflowChecked
:=
d
.
overflowChecked
if
elemFixed
{
d.emit("if len(data) < l*%v { goto overflow }", elemSize)
d
.
overflowCheckpoint
()
d
.
overflowCheckSize
.
AddExpr
(
"l * %v"
,
elemSize
)
d
.
overflowChecked
=
true
}
// TODO ^^^ then skip inner overflow checks
*/
d
.
emit
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
d
.
emit
(
"for i := 0; uint32(i) < l; i++ {"
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
/*
d.flushOverflow()
d.pos = size{} // zero
*/
d
.
overflowCheckpoint
()
if
!
elemFixed
{
d
.
overflowCheckpoint
()
}
d
.
resetPos
()
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
d
)
/*
d.emit("data = data[%v:]", d.pos.num) // FIXME wrt slice of slice ?
d.emit("%v += %v", d.var_("nread"), d.pos.num)
*/
d
.
resetPos
()
d
.
emit
(
"}"
)
//d.overflowCheckpoint()
//d.resetPos()
d
.
overflowChecked
=
overflowChecked
//d.emit("%v= string(data[:l])", assignto)
d
.
emit
(
"}"
)
...
...
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