Iterate over references

This commit is contained in:
Eelco Dolstra 2019-05-28 23:05:08 +02:00
parent 9eaebbf575
commit 22f2744afd
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -83,7 +83,7 @@ static void addAttr(ExprAttrs * attrs, AttrPath & attrPath,
assert(!attrPath.empty()); assert(!attrPath.empty());
// Checking attrPath validity. // Checking attrPath validity.
// =========================== // ===========================
for (i = attrPath.begin(); i + 1 < attrPath.end(); i++) { for (i = attrPath.begin(); i + 1 < attrPath.end(); i++) {
if (i->symbol.set()) { if (i->symbol.set()) {
ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol); ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol);
if (j != attrs->attrs.end()) { if (j != attrs->attrs.end()) {
@ -106,18 +106,18 @@ static void addAttr(ExprAttrs * attrs, AttrPath & attrPath,
} }
// Expr insertion. // Expr insertion.
// ========================== // ==========================
if (i->symbol.set()) { if (i->symbol.set()) {
ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol); ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol);
if (j != attrs->attrs.end()) { if (j != attrs->attrs.end()) {
// This attr path is already defined. However, if both // This attr path is already defined. However, if both
// e and the expr pointed by the attr path are two attribute sets, // e and the expr pointed by the attr path are two attribute sets,
// we want to merge them. // we want to merge them.
// Otherwise, throw an error. // Otherwise, throw an error.
ExprAttrs* ae = dynamic_cast<ExprAttrs *>(e); auto ae = dynamic_cast<ExprAttrs *>(e);
ExprAttrs* jAttrs = dynamic_cast<ExprAttrs *>(j->second.e); auto jAttrs = dynamic_cast<ExprAttrs *>(j->second.e);
if (jAttrs && ae) { if (jAttrs && ae) {
for (auto ad: ae->attrs) { for (auto & ad : ae->attrs) {
ExprAttrs::AttrDefs::iterator j2 = jAttrs->attrs.find(ad.first); auto j2 = jAttrs->attrs.find(ad.first);
if (j2 != jAttrs->attrs.end()) // Attr already defined in iAttrs, error. if (j2 != jAttrs->attrs.end()) // Attr already defined in iAttrs, error.
dupAttr(ad.first, j2->second.pos, ad.second.pos); dupAttr(ad.first, j2->second.pos, ad.second.pos);
jAttrs->attrs[ad.first] = ad.second; jAttrs->attrs[ad.first] = ad.second;