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
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
Show 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 {
...
@@ -338,6 +338,9 @@ type decoder struct {
// size that will be checked for overflow at current overflow check point
// size that will be checked for overflow at current overflow check point
overflowCheckSize
size
overflowCheckSize
size
// whether overflow was already checked for current decodings
overflowChecked
bool
commonCoder
commonCoder
}
}
...
@@ -493,7 +496,9 @@ func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Typ
...
@@ -493,7 +496,9 @@ func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Typ
dataptr
:=
fmt
.
Sprintf
(
"data[%v:]"
,
d
.
n
)
dataptr
:=
fmt
.
Sprintf
(
"data[%v:]"
,
d
.
n
)
decoded
:=
fmt
.
Sprintf
(
basic
.
decode
,
dataptr
)
decoded
:=
fmt
.
Sprintf
(
basic
.
decode
,
dataptr
)
d
.
n
+=
basic
.
wireSize
d
.
n
+=
basic
.
wireSize
if
!
d
.
overflowChecked
{
d
.
overflowCheckSize
.
Add
(
basic
.
wireSize
)
d
.
overflowCheckSize
.
Add
(
basic
.
wireSize
)
}
if
userType
!=
nil
&&
userType
!=
typ
{
if
userType
!=
nil
&&
userType
!=
typ
{
// userType is a named type over some basic, like
// userType is a named type over some basic, like
// type ClusterState int32
// type ClusterState int32
...
@@ -601,50 +606,34 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
...
@@ -601,50 +606,34 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
d
.
emit
(
"{"
)
d
.
emit
(
"{"
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
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
.
resetPos
()
//d.overflowCheckpoint()
//d.pos.AddExpr("l") // FIXME l*sizeof(elem)
/*
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
// if size(item)==const - check l in one go
// if size(item)==const - check l in one go
overflowChecked
:=
d
.
overflowChecked
if
elemFixed
{
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
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
d
.
emit
(
"for i := 0; uint32(i) < l; i++ {"
)
d
.
emit
(
"for i := 0; uint32(i) < l; i++ {"
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
/*
if
!
elemFixed
{
d.flushOverflow()
d.pos = size{} // zero
*/
d
.
overflowCheckpoint
()
d
.
overflowCheckpoint
()
}
d
.
resetPos
()
d
.
resetPos
()
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
d
)
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
.
resetPos
()
d
.
emit
(
"}"
)
d
.
emit
(
"}"
)
//d.overflowCheckpoint()
d
.
overflowChecked
=
overflowChecked
//d.resetPos()
//d.emit("%v= string(data[:l])", assignto)
//d.emit("%v= string(data[:l])", assignto)
d
.
emit
(
"}"
)
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