Ejemplo n.º 1
0
 int SerializeEnvFrame(VmEnvFrame frame, object obj)
 {
     var composite = new Composite {
         Kind = ObjectTypes.EnvFrame,
         Elements = new int[3]
     };
     var result = SerializeOneHashed (composite, obj);
     composite.Elements [0] = Serialize (frame.VarNames);
     composite.Elements [1] = Serialize (frame.Values);
     composite.Elements [2] = SerializeOne (frame.IntroducedAtProgramCounter);
     return result;
 }
Ejemplo n.º 2
0
        VmEnvFrame RebuildEnvFrame(
            object[] objects, int index, Composite composite, Func<int, object> reader)
        {
            var result = new VmEnvFrame ();
            objects [index] = result;

            result.VarNames = (string[])reader (composite.Elements [0]);
            result.Values = (Value[])reader (composite.Elements [1]);
            result.IntroducedAtProgramCounter = (int)(long)reader (composite.Elements [2]);

            return result;
        }
Ejemplo n.º 3
0
Archivo: Vm.cs Proyecto: mbrezu/Shovel
        int CountCellsEnvFrame(VmEnvFrame envFrame, HashSet<object> visited)
        {
            var sum = 3;
            visited.Add (envFrame);

            sum += CountCellsImpl (envFrame.VarNames, visited);
            sum += CountCellsImpl (envFrame.Values, visited);

            return sum;
        }
Ejemplo n.º 4
0
Archivo: Vm.cs Proyecto: mbrezu/Shovel
 static void HandleNewFrame(Vm vm)
 {
     var instruction = vm.CurrentInstruction ();
     var args = (string[])instruction.Arguments;
     var frame = new VmEnvFrame () {
         VarNames = args,
         Values = new Value[args.Length],
         IntroducedAtProgramCounter = vm.programCounter
     };
     var newEnv = new VmEnvironment () {
         Frame = frame,
         Next = vm.currentEnvironment
     };
     vm.currentEnvironment = newEnv;
     vm.IncrementCells (args.Length * 3 + 5);
     vm.programCounter++;
 }
Ejemplo n.º 5
0
Archivo: Vm.cs Proyecto: ichaos/Shovel
 static VmEnvironment FreshFrame(Vm vm, Instruction instruction)
 {
     var args = (string[])instruction.Arguments;
     var frame = new VmEnvFrame () {
         VarNames = args,
         Values = new Value[args.Length],
         IntroducedAtProgramCounter = vm.programCounter
     };
     var result = new VmEnvironment () {
         Frame = frame,
     };
     vm.IncrementCells (args.Length * 3 + 5);
     instruction.Cache = result;
     return result;
 }