コード例 #1
0
        public void Unify(RootEnvironment rootEnv, StackEntryState other, BoolRef changed)
        {
            var type = Type.Lub(rootEnv, other.Type, changed);

            var upperBound = default(TypeRef);

            if (UpperBound != null && other.UpperBound != null)
            {
                upperBound = UpperBound.Glb(rootEnv, other.UpperBound, changed);
            }
            else if (other.UpperBound != null)
            {
                upperBound = other.UpperBound;
                changed.Set();
            }
            else
            {
                upperBound = UpperBound;
            }

            if (upperBound != null && !type.IsAssignableTo(rootEnv, upperBound))
            {
                throw new InvalidOperationException("stack entries are not unifiable");
            }

            var pointsTo = PointsTo.Lub(other.PointsTo, changed);

            UpperBound = upperBound;
            Type       = type;
            PointsTo   = pointsTo;
        }