public object call(Context c, Scriptable scope, Scriptable thisObj, object[] objarr)
        {
            if(objarr.Length < 1)
            {
                throw new Exception("Snapshot function requires machine argument");
            }

            IMachine machine = new MachineResolver(provider).Resolve(objarr[0]);

            initFunc(machine);

            var snapshotId = machine.MakeSnapshot();

            // We need to clean up the snapshots at some point.
            Action oldAction = CleanupSnapshots;
            CleanupSnapshots = () =>
            {
                machine.DeleteSnapshot(snapshotId);
                oldAction();
            };

            return new SnapshotObject(machine, snapshotId);
        }
        public object call(Context c, Scriptable scope, Scriptable thisObj, object[] objarr)
        {
            if (objarr.Length < 1)
            {
                throw new Exception("Snapshot function requires machine argument");
            }

            IMachine machine = new MachineResolver(provider).Resolve(objarr[0]);

            initFunc(machine);

            var snapshotId = machine.MakeSnapshot();

            // We need to clean up the snapshots at some point.
            Action oldAction = CleanupSnapshots;

            CleanupSnapshots = () =>
            {
                machine.DeleteSnapshot(snapshotId);
                oldAction();
            };

            return(new SnapshotObject(machine, snapshotId));
        }