/// <summary> /// Insert a variable reference /// </summary> /// <param name="variable">the variable</param> /// <param name="expression">the reference</param> public void InsertVariable(Variable variable, ExpressionNodeCouple expression) { if (!VariablesReferences.ContainsKey(variable)) { VariablesReferences.Add(variable, new HashSet <ExpressionNodeCouple>()); } VariablesReferences[variable].Add(expression); }
/// <summary> /// Insert a variable reference /// </summary> /// <param name="variable">the variable</param> /// <param name="expression">the reference</param> public void InsertVariable(Variable variable, ExpressionNodeCouple expression) { if (!VariablesReferences.ContainsKey(variable)) { VariablesReferences.Add(variable, new HashSet <ExpressionNodeCouple>()); } // Also add all the variables in that buffer so that they are not removed var cbuffer = (ConstantBuffer)variable.GetTag(StrideTags.ConstantBuffer); if (cbuffer != null) { foreach (var otherVariable in cbuffer.Members.OfType <Variable>()) { if (!VariablesReferences.ContainsKey(otherVariable)) { VariablesReferences.Add(otherVariable, new HashSet <ExpressionNodeCouple>()); } } } VariablesReferences[variable].Add(expression); }
/// <summary> /// Merge the argument references into this one /// </summary> /// <param name="pool">the ReferencePool</param> public void Merge(ReferencesPool pool) { // merge the VariablesReferences foreach (var variableReference in pool.VariablesReferences) { if (!VariablesReferences.ContainsKey(variableReference.Key)) { VariablesReferences.Add(variableReference.Key, new HashSet <ExpressionNodeCouple>()); } VariablesReferences[variableReference.Key].UnionWith(variableReference.Value); } // merge the MethodsReferences foreach (var methodReference in pool.MethodsReferences) { if (!MethodsReferences.ContainsKey(methodReference.Key)) { MethodsReferences.Add(methodReference.Key, new HashSet <MethodInvocationExpression>()); } MethodsReferences[methodReference.Key].UnionWith(methodReference.Value); } }