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
63202f0f
Commit
63202f0f
authored
Jun 09, 2014
by
Kamil Kisiel
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from Sean-Der/implement-tuple2-decode
Implement the TUPLE2 Opcode
parents
eb26998f
1b113b59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
ogórek.go
ogórek.go
+9
-0
ogórek_test.go
ogórek_test.go
+1
-0
No files found.
ogórek.go
View file @
63202f0f
...
...
@@ -205,6 +205,8 @@ func (d Decoder) Decode() (interface{}, error) {
err
=
d
.
loadSetItem
()
case
opTuple
:
err
=
d
.
loadTuple
()
case
opTuple2
:
err
=
d
.
loadTuple2
()
case
opEmptyTuple
:
d
.
push
([]
interface
{}{})
case
opSetitems
:
...
...
@@ -607,6 +609,13 @@ func (d *Decoder) loadTuple() error {
return
nil
}
func
(
d
*
Decoder
)
loadTuple2
()
error
{
k
:=
len
(
d
.
stack
)
-
2
v
:=
append
([]
interface
{}{},
d
.
stack
[
k
:
]
...
)
d
.
stack
=
append
(
d
.
stack
[
:
k
],
v
)
return
nil
}
func
(
d
*
Decoder
)
obj
()
error
{
return
errNotImplemented
}
...
...
ogórek_test.go
View file @
63202f0f
...
...
@@ -41,6 +41,7 @@ func TestDecode(t *testing.T) {
{
"tuple of two ints"
,
"(I1
\n
I2
\n
tp0
\n
."
,
[]
interface
{}{
int64
(
1
),
int64
(
2
)}},
{
"nested tuples"
,
"((I1
\n
I2
\n
tp0
\n
(I3
\n
I4
\n
tp1
\n
tp2
\n
."
,
[]
interface
{}{[]
interface
{}{
int64
(
1
),
int64
(
2
)},
[]
interface
{}{
int64
(
3
),
int64
(
4
)}}},
{
"tuple with top 2 items from stack"
,
"I0
\n
I1
\n\x86
."
,
[]
interface
{}{
int64
(
0
),
int64
(
1
)}},
{
"empty list"
,
"(lp0
\n
."
,
[]
interface
{}{}},
{
"list of numbers"
,
"(lp0
\n
I1
\n
aI2
\n
aI3
\n
aI4
\n
a."
,
[]
interface
{}{
int64
(
1
),
int64
(
2
),
int64
(
3
),
int64
(
4
)}},
{
"string"
,
"S'abc'
\n
p0
\n
."
,
string
(
"abc"
)},
...
...
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