Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup object fields #157

Merged
merged 2 commits into from
Apr 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,21 +600,17 @@ class Interpreter {

/** Auxiliary function.
*/
IdHideMap objectFields(const HeapObject *obj_,
unsigned &counter, unsigned skip,
bool manifesting)
IdHideMap objectFieldsAux(const HeapObject *obj_)
{
IdHideMap r;
if (auto *obj = dynamic_cast<const HeapSimpleObject*>(obj_)) {
counter++;
if (counter <= skip) return r;
for (const auto &f : obj->fields) {
r[f.first] = !manifesting ? ObjectField::VISIBLE : f.second.hide;
r[f.first] = f.second.hide;
}

} else if (auto *obj = dynamic_cast<const HeapExtendedObject*>(obj_)) {
r = objectFields(obj->right, counter, skip, manifesting);
for (const auto &pair : objectFields(obj->left, counter, skip, manifesting)) {
r = objectFieldsAux(obj->right);
for (const auto &pair : objectFieldsAux(obj->left)) {
auto it = r.find(pair.first);
if (it == r.end()) {
// First time it is seen
Expand All @@ -626,8 +622,6 @@ class Interpreter {
}

} else if (auto *obj = dynamic_cast<const HeapComprehensionObject*>(obj_)) {
counter++;
if (counter <= skip) return r;
for (const auto &f : obj->compValues)
r[f.first] = ObjectField::VISIBLE;
}
Expand All @@ -638,10 +632,9 @@ class Interpreter {
*/
std::set<const Identifier*> objectFields(const HeapObject *obj_, bool manifesting)
{
unsigned counter = 0;
std::set<const Identifier*> r;
for (const auto &pair : objectFields(obj_, counter, 0, manifesting)) {
if (pair.second != ObjectField::HIDDEN) r.insert(pair.first);
for (const auto &pair : objectFieldsAux(obj_)) {
if (!manifesting || pair.second != ObjectField::HIDDEN) r.insert(pair.first);
}
return r;
}
Expand Down