xo-expression: bugfix: ensure in-layer uniqueness of vars
This commit is contained in:
parent
a76c835477
commit
f18c33b249
2 changed files with 9 additions and 2 deletions
|
|
@ -25,6 +25,11 @@ namespace xo {
|
|||
return new Variable(name, var_type);
|
||||
}
|
||||
|
||||
/** return copy of x: same var, different object identity **/
|
||||
static ref::rp<Variable> copy(ref::brw<Variable> x) {
|
||||
return new Variable(x->name(), x->valuetype());
|
||||
}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static ref::brw<Variable> from(ref::brw<Expression> x) {
|
||||
return ref::brw<Variable>::from(x);
|
||||
|
|
|
|||
|
|
@ -103,9 +103,11 @@ namespace xo {
|
|||
|
||||
auto ix = var_map.find(var->name());
|
||||
if (ix == var_map.end()) {
|
||||
/* add to var_map */
|
||||
/* add to var_map, copy to ensure Variable
|
||||
* is unique to layer
|
||||
*/
|
||||
|
||||
var_map[var->name()] = var.get();
|
||||
var_map[var->name()] = Variable::copy(var);
|
||||
|
||||
return var.get();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue