// <summary> // Get the "cloned" var for a given Var. // If no cloned var exists, return the input Var itself // </summary> // <param name="v"> The Var for which the cloned Var should be retrieved </param> // <returns> The cloned Var that corresponds to the specified Var if this OpCopier is cloning across two different Commands; otherwise it is safe to return the specified Var itself </returns> private Var GetMappedVar(Var v) { Var mappedVar; // // Return a mapping if there is one // if (m_varMap.TryGetValue(v, out mappedVar)) { return(mappedVar); } // // No mapping found. // If we're cloning to a different command, this is an error // if (m_destCmd != m_srcCmd) { throw EntityUtil.InternalError(EntityUtil.InternalErrorCode.UnknownVar, 6, null); } // // otherwise return the current Var itself // return(v); }
internal VarMap GetReverseMap() { VarMap varMap = new VarMap(); foreach (KeyValuePair <Var, Var> keyValuePair in (Dictionary <Var, Var>) this) { Var var; if (!varMap.TryGetValue(keyValuePair.Value, out var)) { varMap[keyValuePair.Value] = keyValuePair.Key; } } return(varMap); }
internal VarMap GetReverseMap() { var reverseMap = new VarMap(); foreach (var kv in this) { Var x; // On the odd chance that a var is in the varMap more than once, the first one // is going to be the one we want to use, because it might be the discriminator // var; if (!reverseMap.TryGetValue(kv.Value, out x)) { reverseMap[kv.Value] = kv.Key; } } return(reverseMap); }