}
}
// note: increments reference count on attributes
public static Attributes resultAttributes(@SuppressWarnings("unused") ASTNode ast, RArray a, RArray b) {
Attributes aa = a.attributes();
Attributes ba = b.attributes();
if (ba == null && aa == null) {
return null;
}
int asize = a.size();
int bsize = b.size();
if (asize > bsize) {
return Attributes.markShared(aa);
}
if (bsize > asize) {
return Attributes.markShared(ba);
}
// asize == bsize
if (ba == null) {
return Attributes.markShared(aa);
}
if (aa == null) {
return Attributes.markShared(ba);
}
// both aa != null and ba != null
Attributes res = ba.copy();
Map<RSymbol, RAny> amap = aa.map();
for (Map.Entry<RSymbol, RAny> ae : amap.entrySet()) {
RAny value = ae.getValue();
value.ref();
res.put(ae.getKey(), value);
}
return res;
}