/// <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); }