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); }
public void ReadPointer(MachineState nextState, PointsTo pointsTo, BoolRef changed) { innerState.Value.ArgsLocalsState.ReadPointer(nextState.innerState.Value.ArgsLocalsState, pointsTo, changed); }
public MachineState PopPushType(int n, TypeRef type, PointsTo pointsTo) { return PopPush(n, new StackEntryState(type.ToRunTimeType(RootEnv,true), pointsTo)); }
public MachineState PushType(TypeRef type, PointsTo pointsTo) { return PopPushType(0, type, pointsTo); }
public StackEntryState(TypeRef type, PointsTo pointsTo) : this(type, null, pointsTo) { }
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; }
public StackEntryState(TypeRef type, TypeRef upperBound, PointsTo pointsTo) { Type = type; UpperBound = upperBound; PointsTo = pointsTo; }
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)); }
public InnerMachineState CloneWithArgLocalPointsTo(IImSeq<StackEntryState> stack, ArgLocal argLocal, int index, PointsTo pointsTo) { return new InnerMachineState(stack, ArgsLocalsState.CloneWithArgLocalPointsTo(argLocal, index, pointsTo)); }
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); }
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; }