Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
31a07ee2
Commit
31a07ee2
authored
Jun 02, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sets were horribly broken since they didn't have GC handlers
parent
d460425b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
src/runtime/set.cpp
src/runtime/set.cpp
+29
-4
test/tests/set.py
test/tests/set.py
+2
-0
No files found.
src/runtime/set.cpp
View file @
31a07ee2
...
...
@@ -23,17 +23,19 @@ namespace pyston {
BoxedClass
*
set_cls
,
*
set_iterator_cls
;
const
ObjectFlavor
set_flavor
(
&
boxGCHandler
,
NULL
);
const
ObjectFlavor
set_iterator_flavor
(
&
boxGCHandler
,
NULL
);
extern
"C"
void
setGCHandler
(
GCVisitor
*
v
,
void
*
p
);
extern
"C"
void
setIteratorGCHandler
(
GCVisitor
*
v
,
void
*
p
);
const
ObjectFlavor
set_flavor
(
&
setGCHandler
,
NULL
);
const
ObjectFlavor
set_iterator_flavor
(
&
setIteratorGCHandler
,
NULL
);
namespace
set
{
class
BoxedSetIterator
:
public
Box
{
p
rivate
:
p
ublic
:
BoxedSet
*
s
;
decltype
(
BoxedSet
::
s
)
::
iterator
it
;
public:
BoxedSetIterator
(
BoxedSet
*
s
)
:
Box
(
&
set_iterator_flavor
,
set_iterator_cls
),
s
(
s
),
it
(
s
->
s
.
begin
())
{}
bool
hasNext
()
{
return
it
!=
s
->
s
.
end
();
}
...
...
@@ -45,6 +47,29 @@ public:
}
};
extern
"C"
void
setGCHandler
(
GCVisitor
*
v
,
void
*
p
)
{
boxGCHandler
(
v
,
p
);
BoxedSet
*
s
=
(
BoxedSet
*
)
p
;
// This feels like a cludge, but we need to find anything that
// the unordered_map might have allocated.
// Another way to handle this would be to rt_alloc the unordered_map
// as well, though that incurs extra memory dereferences which would
// be nice to avoid.
void
**
start
=
(
void
**
)
&
s
->
s
;
void
**
end
=
start
+
(
sizeof
(
s
->
s
)
/
8
);
v
->
visitPotentialRange
(
start
,
end
);
}
extern
"C"
void
setIteratorGCHandler
(
GCVisitor
*
v
,
void
*
p
)
{
boxGCHandler
(
v
,
p
);
BoxedSetIterator
*
it
=
(
BoxedSetIterator
*
)
p
;
v
->
visit
(
it
->
s
);
}
Box
*
setiteratorHasnext
(
BoxedSetIterator
*
self
)
{
assert
(
self
->
cls
==
set_iterator_cls
);
return
boxBool
(
self
->
hasNext
());
...
...
test/tests/set.py
View file @
31a07ee2
...
...
@@ -26,3 +26,5 @@ s.add("")
print
len
(
s
)
s
.
add
(
None
)
print
len
(
s
)
print
set
([
1
])
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