Skip to content

Commit

Permalink
Merge pull request #157 from sparkprime/cleanup_object_fields
Browse files Browse the repository at this point in the history
Cleanup object fields
  • Loading branch information
sparkprime committed Apr 4, 2016
2 parents 16524a0 + c4113fa commit 72c67a1
Showing 1 changed file with 6 additions and 13 deletions.
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

0 comments on commit 72c67a1

Please sign in to comment.