示例#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;
        }
示例#2
0
        public MachineState PopPush(int n, StackEntryState entry)
        {
            if (n > Depth)
            {
                throw new InvalidOperationException("stack is too shallow");
            }
            var stack = new Seq <StackEntryState>(Depth - n + 1);

            stack.Add(entry);
            for (var i = n; i < Depth; i++)
            {
                stack.Add(innerState.Value.Stack[i]);
            }
            return(CloneForward(stack));
        }
示例#3
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;
        }
示例#4
0
 public bool IsEquivalentTo(RootEnvironment rootEnv, StackEntryState other)
 {
     return(Type.IsEquivalentTo(rootEnv, other.Type) && PointsTo.Lte(other.PointsTo) &&
            other.PointsTo.Lte(PointsTo));
 }
示例#5
0
 public MachineState Push(StackEntryState entry)
 {
     return(PopPush(0, entry));
 }
示例#6
0
 public MachineState Push(StackEntryState entry)
 {
     return PopPush(0, entry);
 }
示例#7
0
 public MachineState PopPush(int n, StackEntryState entry)
 {
     if (n > Depth)
         throw new InvalidOperationException("stack is too shallow");
     var stack = new Seq<StackEntryState>(Depth - n + 1);
     stack.Add(entry);
     for (var i = n; i < Depth; i++)
         stack.Add(innerState.Value.Stack[i]);
     return CloneForward(stack);
 }
示例#8
0
 public bool IsEquivalentTo(RootEnvironment rootEnv, StackEntryState other)
 {
     return Type.IsEquivalentTo(rootEnv, other.Type) && PointsTo.Lte(other.PointsTo) &&
            other.PointsTo.Lte(PointsTo);
 }