Beispiel #1
0
 public MachineState PopAddArgLocalPointsTo(int n, ArgLocal argLocal, int index, PointsTo pointsTo)
 {
     if (n > Depth)
         throw new InvalidOperationException("stack is too shallow");
     var stack = new Seq<StackEntryState>(Depth - n);
     for (var i = n; i < Depth; i++)
         stack.Add(innerState.Value.Stack[i]);
     return CloneWithArgLocalPointsTo(stack, argLocal, index, pointsTo);
 }
Beispiel #2
0
 public void ReadPointer(MachineState nextState, PointsTo pointsTo, BoolRef changed)
 {
     innerState.Value.ArgsLocalsState.ReadPointer(nextState.innerState.Value.ArgsLocalsState, pointsTo, changed);
 }
Beispiel #3
0
 public MachineState PopPushType(int n, TypeRef type, PointsTo pointsTo)
 {
     return PopPush(n, new StackEntryState(type.ToRunTimeType(RootEnv,true), pointsTo));
 }
Beispiel #4
0
 public MachineState PushType(TypeRef type, PointsTo pointsTo)
 {
     return PopPushType(0, type, pointsTo);
 }
Beispiel #5
0
 public StackEntryState(TypeRef type, PointsTo pointsTo)
     : this(type, null, pointsTo)
 {
 }
Beispiel #6
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;
        }
Beispiel #7
0
 public StackEntryState(TypeRef type, TypeRef upperBound, PointsTo pointsTo)
 {
     Type = type;
     UpperBound = upperBound;
     PointsTo = pointsTo;
 }
Beispiel #8
0
 public MachineState CloneWithArgLocalPointsTo(IImSeq<StackEntryState> stack, ArgLocal argLocal, int index, PointsTo pointsTo)
 {
     return new MachineState(RootEnv, nArgs, nLocals, innerState.Value.CloneWithArgLocalPointsTo(stack, argLocal, index, pointsTo));
 }
Beispiel #9
0
 public InnerMachineState CloneWithArgLocalPointsTo(IImSeq<StackEntryState> stack, ArgLocal argLocal, int index, PointsTo pointsTo)
 {
     return new InnerMachineState(stack, ArgsLocalsState.CloneWithArgLocalPointsTo(argLocal, index, pointsTo));
 }
Beispiel #10
0
 public void ReadPointer(ArgsLocalsState other, PointsTo pointsTo, BoolRef changed)
 {
     var newArgsAlive = other.argsAlive.Clone();
     foreach (var argIndex in pointsTo.Args.Members)
         newArgsAlive[argIndex] = true;
     argsAlive.UnionInPlace(newArgsAlive, changed);
     var newLocalsAlive = other.localsAlive.Clone();
     foreach (var localIndex in pointsTo.Locals.Members)
         newLocalsAlive[localIndex] = true;
     localsAlive.UnionInPlace(newLocalsAlive, changed);
 }
Beispiel #11
0
 public ArgsLocalsState CloneWithArgLocalPointsTo(ArgLocal argLocal, int index, PointsTo pointsTo)
 {
     var key = ArgLocalInstruction.Key(argLocal, index);
     var res = new ArgsLocalsState(argsAlive.Capacity, localsAlive.Capacity);
     foreach (var kv in argLocalToPointsTo)
     {
         if (kv.Key != key)
             res.argLocalToPointsTo.Add(kv.Key, kv.Value);
     }
     if (!pointsTo.IsBottom)
         res.argLocalToPointsTo.Add(key, pointsTo);
     return res;
 }