-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specialize NameMap::visit_children for ordered_map so that order is p…
…reserved when nodes change names or split or whatever.
- Loading branch information
Chris Dodd
committed
Apr 19, 2016
1 parent
fdfb406
commit 39dcae3
Showing
5 changed files
with
92 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "ir/ir.h" | ||
#include "ir/visitor.h" | ||
#include <assert.h> | ||
|
||
class TestTrans : public Transform { | ||
IR::Node *preorder(IR::TableProperty *a) override { | ||
if (!a->isConstant) | ||
a->name = "$new$"; | ||
return a; | ||
} | ||
IR::Node *postorder(IR::TableProperties *p) override { | ||
int count = 0; | ||
for (auto &prop : p->properties) { | ||
if (prop.first == "$new$") | ||
assert(count == 0); | ||
else | ||
assert(count == 1); | ||
++count; } | ||
return p; | ||
} | ||
}; | ||
|
||
int main() { | ||
auto tp = new IR::TableProperties(); | ||
tp->properties.add("a", new IR::TableProperty(Util::SourceInfo(), "a", | ||
new IR::Annotations(new IR::Vector<IR::Annotation>()), | ||
new IR::Key(Util::SourceInfo(), new IR::Vector<IR::KeyElement>()), | ||
false)); | ||
tp->properties.add("b", new IR::TableProperty(Util::SourceInfo(), "b", | ||
new IR::Annotations(new IR::Vector<IR::Annotation>()), | ||
new IR::Key(Util::SourceInfo(), new IR::Vector<IR::KeyElement>()), | ||
true)); | ||
tp->apply(TestTrans()); | ||
} |