Inference/src/Semantic/SSAAlgorithm/SSAHelper.cs
/// <summary>
/// To clone the equivalence classes of a previously cloned type variables
/// </summary>
/// <param name="references">The references used in the block.</param>
/// <param name="methodAnalyzed">The method that is being analyzed when the operation is performed.</param>
To clone the equivalence classes of a previously cloned type variables
To clone the equivalence classes of a previously cloned type variables
private static void CloneEquivalenceClasses(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed) {
            foreach (EquivalenceClass oldEquivalenceClass in equivalenceClasses) {
                EquivalenceClass newEquivalenceClass = new EquivalenceClass();
                TypeExpression newSubstitution = null;
                if (oldEquivalenceClass.Substitution != null)
                    newSubstitution = oldEquivalenceClass.Substitution.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
                newEquivalenceClass.add(newSubstitution, SortOfUnification.Equivalent, new List<Pair<TypeExpression, TypeExpression>>());
                foreach (int typeVariableNumber in oldEquivalenceClass.TypeVariables.Keys) {
                    TypeVariable newTypeVariable = clonedTypeVariables[typeVariableNumber];
                    newEquivalenceClass.TypeVariables[newTypeVariable.Variable] = newTypeVariable;
                    newTypeVariable.EquivalenceClass = newEquivalenceClass;
                    clonedTypeVariables[typeVariableNumber].ValidTypeExpression = false;
                }
            }
        }
private static void CloneEquivalenceClasses ( IDictionary < int , TypeVariable > clonedTypeVariables , IList < EquivalenceClass > equivalenceClasses , MethodType methodAnalyzed ) { foreach ( EquivalenceClass oldEquivalenceClass in equivalenceClasses ) { EquivalenceClass newEquivalenceClass = new EquivalenceClass ( ) ; TypeExpression newSubstitution = null ; if ( oldEquivalenceClass . Substitution != null ) newSubstitution = oldEquivalenceClass . Substitution . Clone ( clonedTypeVariables , equivalenceClasses , methodAnalyzed ) ; newEquivalenceClass . add ( newSubstitution , SortOfUnification . Equivalent , new List < Pair < TypeExpression , TypeExpression > > ( ) ) ; foreach ( int typeVariableNumber in oldEquivalenceClass . TypeVariables . Keys ) { TypeVariable newTypeVariable = clonedTypeVariables [ typeVariableNumber ] ; newEquivalenceClass . TypeVariables [ newTypeVariable . Variable ] = newTypeVariable ; newTypeVariable . EquivalenceClass = newEquivalenceClass ; clonedTypeVariables [ typeVariableNumber ] . ValidTypeExpression = false ; } } }
To clone the equivalence classes of a previously cloned type variables
To clone the equivalence classes of a previously cloned type variables
// * Clones and updates the equivalence classes // * Clones the substitution // * Updates the substitution to the cloned one // * Adds the cloned type variable to the new equivalence class // * Sets the class equivalence of the cloned type variable
clonedTypeVariables
IDictionary<int, TypeVariable>
equivalenceClasses
IList<EquivalenceClass>
methodAnalyzed
MethodType
The method that is being analyzed when the operation is performed.
The method that is being analyzed when the operation is performed .
references
The references used in the block.
The references used in the block .