private bool _AreEqual(VariableExpression a, VariableExpression b) { if (_aliases == null) { return(a.Name.Equals(b.Name)); } // TODO currently only allowing one single alias. There are cases // multiple are correct, but also where not. If loop dependence analysis // supports branches, this has to be improved. var aAliases = _aliases.GetAliasesOfVariableBefore(a.Name, _aNode).ToList(); if (aAliases.Count != 1) { return(false); } var bAliases = _aliases.GetAliasesOfVariableBefore(b.Name, _bNode).ToList(); if (bAliases.Count != 1) { return(false); } // TODO support nested expressions through aliasing? return(aAliases.Single().Equals(bAliases.Single())); }
private Expression _GetAliasTarget(string variableName, FlowNode node) { // TODO at this point this check is unnecessary and could be removed. // because of the loop dependence analysis check beforehand which does not support // multiple values of a variable, there should actually be exactly one alias. var aliases = _aliasAnalysis.GetAliasesOfVariableBefore(variableName, node).ToList(); if (aliases.Count != 1) { // TODO it might be possible to support multiple distinct aliases in some cases throw new UnsupportedSyntaxException($"detected multiple possible values for variable {variableName}: {aliases}"); } return(aliases[0].Target); }