Drop single-stepping and pause modes (#294)

This commit is contained in:
Tim Mickel 2016-10-20 11:42:16 -04:00 committed by GitHub
parent 9af9a87cb6
commit 3d57c2e74c
5 changed files with 1 additions and 156 deletions

View file

@ -18,16 +18,9 @@
<div>
Turbo: <input id='turbomode' type='checkbox' />
</div>
<div>
Pause: <input id='pausemode' type='checkbox' />
</div>
<div>
Compatibility (30 TPS): <input id='compatmode' type='checkbox' />
</div>
<div>
Single stepping: <input id='singlestepmode' type='checkbox' />
<input id='singlestepspeed' type='range' min='1' max='20' value='10' />
</div>
<br />
<ul id="playgroundLinks">
<li><a id="renderexplorer-link" href="#">Renderer</a></li>

View file

@ -249,26 +249,11 @@ window.onload = function() {
var turboOn = document.getElementById('turbomode').checked;
vm.setTurboMode(turboOn);
});
document.getElementById('pausemode').addEventListener('change', function() {
var pauseOn = document.getElementById('pausemode').checked;
vm.setPauseMode(pauseOn);
});
document.getElementById('compatmode').addEventListener('change',
function() {
var compatibilityMode = document.getElementById('compatmode').checked;
vm.setCompatibilityMode(compatibilityMode);
});
document.getElementById('singlestepmode').addEventListener('change',
function() {
var singleStep = document.getElementById('singlestepmode').checked;
vm.setSingleSteppingMode(singleStep);
});
document.getElementById('singlestepspeed').addEventListener('input',
function() {
var speed = document.getElementById('singlestepspeed').value;
vm.setSingleSteppingSpeed(speed);
});
var tabBlockExplorer = document.getElementById('tab-blockexplorer');
var tabThreadExplorer = document.getElementById('tab-threadexplorer');
var tabRenderExplorer = document.getElementById('tab-renderexplorer');

View file

@ -83,12 +83,6 @@ function Runtime () {
*/
this._scriptGlowsPreviousFrame = [];
/**
* A list of block IDs that were glowing during the previous frame.
* @type {!Array.<!string>}
*/
this._blockGlowsPreviousFrame = [];
/**
* Currently known number of clones, used to enforce clone limit.
* @type {number}
@ -101,24 +95,12 @@ function Runtime () {
*/
this.turboMode = false;
/**
* Whether the project is in "pause mode."
* @type {Boolean}
*/
this.pauseMode = false;
/**
* Whether the project is in "compatibility mode" (30 TPS).
* @type {Boolean}
*/
this.compatibilityMode = false;
/**
* Whether the project is in "single stepping mode."
* @type {Boolean}
*/
this.singleStepping = false;
/**
* How fast in ms "single stepping mode" should run, in ms.
* Can be updated dynamically.
@ -542,10 +524,6 @@ Runtime.prototype.stopAll = function () {
* inactive threads after each iteration.
*/
Runtime.prototype._step = function () {
if (this.pauseMode) {
// Don't do any execution while in pause mode.
return;
}
// Find all edge-activated hats, and add them to threads to be evaluated.
for (var hatType in this._hats) {
var hat = this._hats[hatType];
@ -569,23 +547,6 @@ Runtime.prototype.setEditingTarget = function (editingTarget) {
this._updateGlows();
};
/**
* Set whether we are in pause mode.
* @param {boolean} pauseModeOn True iff in pause mode.
*/
Runtime.prototype.setPauseMode = function (pauseModeOn) {
// Inform the project clock/timer to pause/resume its time.
if (this.ioDevices.clock) {
if (pauseModeOn && !this.pauseMode) {
this.ioDevices.clock.pause();
}
if (!pauseModeOn && this.pauseMode) {
this.ioDevices.clock.resume();
}
}
this.pauseMode = pauseModeOn;
};
/**
* Set whether we are in 30 TPS compatibility mode.
* @param {boolean} compatibilityModeOn True iff in compatibility mode.
@ -599,31 +560,7 @@ Runtime.prototype.setCompatibilityMode = function (compatibilityModeOn) {
};
/**
* Set whether we are in single-stepping mode.
* @param {boolean} singleSteppingOn True iff in single-stepping mode.
*/
Runtime.prototype.setSingleSteppingMode = function (singleSteppingOn) {
this.singleStepping = singleSteppingOn;
if (this._steppingInterval) {
self.clearInterval(this._steppingInterval);
this.start();
}
};
/**
* Set the speed during single-stepping mode.
* @param {number} speed Interval length to step threads, in ms.
*/
Runtime.prototype.setSingleSteppingSpeed = function (speed) {
this.singleStepInterval = 1000 / speed;
if (this._steppingInterval) {
self.clearInterval(this._steppingInterval);
this.start();
}
};
/**
* Emit glows/glow clears for blocks and scripts after a single tick.
* Emit glows/glow clears for scripts after a single tick.
* Looks at `this.threads` and notices which have turned on/off new glows.
* @param {Array.<Thread>=} opt_extraThreads Optional list of inactive threads.
*/
@ -635,10 +572,8 @@ Runtime.prototype._updateGlows = function (opt_extraThreads) {
}
// Set of scripts that request a glow this frame.
var requestedGlowsThisFrame = [];
var requestedBlockGlowsThisFrame = [];
// Final set of scripts glowing during this frame.
var finalScriptGlows = [];
var finalBlockGlows = [];
// Find all scripts that should be glowing.
for (var i = 0; i < searchThreads.length; i++) {
var thread = searchThreads[i];
@ -657,10 +592,6 @@ Runtime.prototype._updateGlows = function (opt_extraThreads) {
requestedGlowsThisFrame.push(script);
}
}
// Only show block glows in single-stepping mode.
if (this.singleStepping && blockForThread) {
requestedBlockGlowsThisFrame.push(blockForThread);
}
}
}
// Compare to previous frame.
@ -682,30 +613,7 @@ Runtime.prototype._updateGlows = function (opt_extraThreads) {
finalScriptGlows.push(currentFrameGlow);
}
}
for (var m = 0; m < this._blockGlowsPreviousFrame.length; m++) {
var previousBlockGlow = this._blockGlowsPreviousFrame[m];
if (requestedBlockGlowsThisFrame.indexOf(previousBlockGlow) < 0) {
// Glow turned off.
try {
this.glowBlock(previousBlockGlow, false);
} catch (e) {
// Block has been removed.
}
} else {
// Still glowing.
finalBlockGlows.push(previousBlockGlow);
}
}
for (var p = 0; p < requestedBlockGlowsThisFrame.length; p++) {
var currentBlockFrameGlow = requestedBlockGlowsThisFrame[p];
if (this._blockGlowsPreviousFrame.indexOf(currentBlockFrameGlow) < 0) {
// Glow turned on.
this.glowBlock(currentBlockFrameGlow, true);
finalBlockGlows.push(currentBlockFrameGlow);
}
}
this._scriptGlowsPreviousFrame = finalScriptGlows;
this._blockGlowsPreviousFrame = finalBlockGlows;
};
/**

View file

@ -70,13 +70,6 @@ Sequencer.prototype.stepThreads = function () {
activeThread.warpTimer = null;
}
if (activeThread.status === Thread.STATUS_RUNNING) {
// After stepping, status is still running.
// If we're in single-stepping mode, mark the thread as
// a single-tick yield so it doesn't re-execute
// until the next frame.
if (this.runtime.singleStepping) {
activeThread.status = Thread.STATUS_YIELD_TICK;
}
numActiveThreads++;
}
}
@ -169,11 +162,6 @@ Sequencer.prototype.stepThread = function (thread) {
// Get next block of existing block on the stack.
thread.goToNextBlock();
}
// In single-stepping mode, force `stepThread` to only run one block
// at a time.
if (this.runtime.singleStepping) {
return;
}
}
};

View file

@ -75,15 +75,6 @@ VirtualMachine.prototype.setTurboMode = function (turboModeOn) {
this.runtime.turboMode = !!turboModeOn;
};
/**
* Set whether the VM is in "pause mode."
* When true, nothing is stepped.
* @param {Boolean} pauseModeOn Whether pause mode should be set.
*/
VirtualMachine.prototype.setPauseMode = function (pauseModeOn) {
this.runtime.setPauseMode(!!pauseModeOn);
};
/**
* Set whether the VM is in 2.0 "compatibility mode."
* When true, ticks go at 2.0 speed (30 TPS).
@ -93,26 +84,6 @@ VirtualMachine.prototype.setCompatibilityMode = function (compatibilityModeOn) {
this.runtime.setCompatibilityMode(!!compatibilityModeOn);
};
/**
* Set whether the VM is in "single stepping mode."
* When true, blocks execute slowly and are highlighted visually.
* @param {Boolean} singleSteppingOn Whether single-stepping mode is set.
*/
VirtualMachine.prototype.setSingleSteppingMode = function (singleSteppingOn) {
this.runtime.setSingleSteppingMode(!!singleSteppingOn);
};
/**
* Set single-stepping mode speed.
* When in single-stepping mode, adjusts the speed of execution.
* @param {Number} speed Interval length in ms.
*/
VirtualMachine.prototype.setSingleSteppingSpeed = function (speed) {
this.runtime.setSingleSteppingSpeed(speed);
};
/**
* Stop all threads and running activities.
*/