Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
og-rek
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
og-rek
Commits
b59989db
Commit
b59989db
authored
Dec 30, 2015
by
Sean DuBois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Implement opMemoize/opShortBinUnicode/opFrame from 'Protocol 4'
parent
3185aa3b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
ogorek.go
ogorek.go
+40
-0
No files found.
ogorek.go
View file @
b59989db
...
@@ -76,6 +76,11 @@ const (
...
@@ -76,6 +76,11 @@ const (
opNewfalse
=
'\x89'
// push False
opNewfalse
=
'\x89'
// push False
opLong1
=
'\x8a'
// push long from < 256 bytes
opLong1
=
'\x8a'
// push long from < 256 bytes
opLong4
=
'\x8b'
// push really big long
opLong4
=
'\x8b'
// push really big long
// Protocol 4
opShortBinUnicode
=
'\x8c'
// push short string; UTF-8 length < 256 bytes
opMemoize
=
'\x94'
// store top of the stack in memo
opFrame
=
'\x95'
// indicate the beginning of a new frame
)
)
var
errNotImplemented
=
errors
.
New
(
"unimplemented opcode"
)
var
errNotImplemented
=
errors
.
New
(
"unimplemented opcode"
)
...
@@ -218,6 +223,12 @@ func (d Decoder) Decode() (interface{}, error) {
...
@@ -218,6 +223,12 @@ func (d Decoder) Decode() (interface{}, error) {
err
=
d
.
loadSetItems
()
err
=
d
.
loadSetItems
()
case
opBinfloat
:
case
opBinfloat
:
err
=
d
.
binFloat
()
err
=
d
.
binFloat
()
case
opFrame
:
err
=
d
.
loadFrame
()
case
opShortBinUnicode
:
err
=
d
.
loadShortBinUnicode
()
case
opMemoize
:
err
=
d
.
loadMemoize
()
case
opProto
:
case
opProto
:
v
,
err
:=
d
.
r
.
ReadByte
()
v
,
err
:=
d
.
r
.
ReadByte
()
if
err
==
nil
&&
v
!=
2
{
if
err
==
nil
&&
v
!=
2
{
...
@@ -786,6 +797,35 @@ func (d *Decoder) binFloat() error {
...
@@ -786,6 +797,35 @@ func (d *Decoder) binFloat() error {
return
nil
return
nil
}
}
func
(
d
*
Decoder
)
loadFrame
()
error
{
var
b
[
8
]
byte
_
,
err
:=
io
.
ReadFull
(
d
.
r
,
b
[
:
])
if
err
!=
nil
{
return
err
}
return
nil
}
func
(
d
*
Decoder
)
loadShortBinUnicode
()
error
{
b
,
err
:=
d
.
r
.
ReadByte
()
if
err
!=
nil
{
return
err
}
s
:=
make
([]
byte
,
b
)
_
,
err
=
io
.
ReadFull
(
d
.
r
,
s
)
if
err
!=
nil
{
return
err
}
d
.
push
(
string
(
s
))
return
nil
}
func
(
d
*
Decoder
)
loadMemoize
()
error
{
d
.
memo
[
strconv
.
Itoa
(
len
(
d
.
memo
))]
=
d
.
stack
[
len
(
d
.
stack
)
-
1
]
return
nil
}
// decodeLong takes a byte array of 2's compliment little-endian binary words and converts them
// decodeLong takes a byte array of 2's compliment little-endian binary words and converts them
// to a big integer
// to a big integer
func
decodeLong
(
data
string
)
(
*
big
.
Int
,
error
)
{
func
decodeLong
(
data
string
)
(
*
big
.
Int
,
error
)
{
...
...
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