Ejemplo n.º 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;
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
 public bool IsEquivalentTo(RootEnvironment rootEnv, StackEntryState other)
 {
     return(Type.IsEquivalentTo(rootEnv, other.Type) && PointsTo.Lte(other.PointsTo) &&
            other.PointsTo.Lte(PointsTo));
 }
Ejemplo n.º 5
0
 public MachineState Push(StackEntryState entry)
 {
     return(PopPush(0, entry));
 }
Ejemplo n.º 6
0
 public MachineState Push(StackEntryState entry)
 {
     return PopPush(0, entry);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 8
0
 public bool IsEquivalentTo(RootEnvironment rootEnv, StackEntryState other)
 {
     return Type.IsEquivalentTo(rootEnv, other.Type) && PointsTo.Lte(other.PointsTo) &&
            other.PointsTo.Lte(PointsTo);
 }