aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js8
-rw-r--r--src/parseTools.js24
-rw-r--r--src/settings.js11
3 files changed, 27 insertions, 16 deletions
diff --git a/src/compiler.js b/src/compiler.js
index 46d6b5cf..bdfdbba8 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -27,16 +27,16 @@ for (setting in settings) {
}
var CONSTANTS = { 'QUANTUM_SIZE': QUANTUM_SIZE };
-if (CORRECT_SIGNS === 2) {
+if (CORRECT_SIGNS >= 2) {
CORRECT_SIGNS_LINES = set(CORRECT_SIGNS_LINES); // for fast checking
}
-if (CORRECT_OVERFLOWS === 2) {
+if (CORRECT_OVERFLOWS >= 2) {
CORRECT_OVERFLOWS_LINES = set(CORRECT_OVERFLOWS_LINES); // for fast checking
}
-if (CORRECT_ROUNDINGS === 2) {
+if (CORRECT_ROUNDINGS >= 2) {
CORRECT_ROUNDINGS_LINES = set(CORRECT_ROUNDINGS_LINES); // for fast checking
}
-if (SAFE_HEAP === 2) {
+if (SAFE_HEAP >= 2) {
SAFE_HEAP_LINES = set(SAFE_HEAP_LINES); // for fast checking
}
diff --git a/src/parseTools.js b/src/parseTools.js
index a2f946bc..9e0fc24c 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -592,32 +592,40 @@ function indentify(text, indent) {
// Correction tools
function correctSpecificSign() {
- assert(!(CORRECT_SIGNS === 2 && !Debugging.on), 'Need debugging for line-specific corrections');
- return CORRECT_SIGNS === 2 && Framework.currItem && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_SIGNS_LINES;
+ assert(!(CORRECT_SIGNS >= 2 && !Debugging.on), 'Need debugging for line-specific corrections');
+ if (!Framework.currItem) return false;
+ return (CORRECT_SIGNS === 2 && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_SIGNS_LINES) ||
+ (CORRECT_SIGNS === 3 && !(Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_SIGNS_LINES));
}
function correctSigns() {
return CORRECT_SIGNS === 1 || correctSpecificSign();
}
function correctSpecificOverflow() {
- assert(!(CORRECT_OVERFLOWS === 2 && !Debugging.on), 'Need debugging for line-specific corrections');
- return CORRECT_OVERFLOWS === 2 && Framework.currItem && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_OVERFLOWS_LINES;
+ assert(!(CORRECT_OVERFLOWS >= 2 && !Debugging.on), 'Need debugging for line-specific corrections');
+ if (!Framework.currItem) return false;
+ return (CORRECT_OVERFLOWS === 2 && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_OVERFLOWS_LINES) ||
+ (CORRECT_OVERFLOWS === 3 && !(Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_OVERFLOWS_LINES));
}
function correctOverflows() {
return CORRECT_OVERFLOWS === 1 || correctSpecificOverflow();
}
function correctSpecificRounding() {
- assert(!(CORRECT_ROUNDINGS === 2 && !Debugging.on), 'Need debugging for line-specific corrections');
- return CORRECT_ROUNDINGS === 2 && Framework.currItem && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_ROUNDINGS_LINES;
+ assert(!(CORRECT_ROUNDINGS >= 2 && !Debugging.on), 'Need debugging for line-specific corrections');
+ if (!Framework.currItem) return false;
+ return (CORRECT_ROUNDINGS === 2 && Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_ROUNDINGS_LINES) ||
+ (CORRECT_ROUNDINGS === 3 && !(Debugging.getIdentifier(Framework.currItem.lineNum) in CORRECT_ROUNDINGS_LINES));
}
function correctRoundings() {
return CORRECT_ROUNDINGS === 1 || correctSpecificRounding();
}
function checkSpecificSafeHeap() {
- assert(!(SAFE_HEAP === 2 && !Debugging.on), 'Need debugging for line-specific checks');
- return SAFE_HEAP === 2 && Framework.currItem && !(Debugging.getIdentifier(Framework.currItem.lineNum) in SAFE_HEAP_LINES);
+ assert(!(SAFE_HEAP >= 2 && !Debugging.on), 'Need debugging for line-specific checks');
+ if (!Framework.currItem) return false;
+ return (SAFE_HEAP === 2 && Debugging.getIdentifier(Framework.currItem.lineNum) in SAFE_HEAP_LINES) ||
+ (SAFE_HEAP === 3 && !(Debugging.getIdentifier(Framework.currItem.lineNum) in SAFE_HEAP_LINES));
}
function checkSafeHeap() {
return SAFE_HEAP === 1 || checkSpecificSafeHeap();
diff --git a/src/settings.js b/src/settings.js
index 249c8224..b50ac04d 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -17,7 +17,8 @@ CORRECT_SIGNS = 1; // Whether we make sure to convert unsigned values to signed
// Decreases performance with additional runtime checks. Might not be
// needed in some kinds of code.
// If equal to 2, done on a line-by-line basis according to
- // CORRECT_SIGNS_LINES
+ // CORRECT_SIGNS_LINES, correcting only the specified lines.
+ // If equal to 3, correcting all *but* the specified lines
CHECK_SIGNS = 0; // Runtime errors for signing issues that need correcting.
// It is recommended to use this in
// order to find if your code needs CORRECT_SIGNS. If you can get your
@@ -47,8 +48,9 @@ SKIP_STACK_IN_SMALL = 1; // When enabled, does not push/pop the stack at all in
// Generated code debugging options
SAFE_HEAP = 0; // Check each write to the heap against a list of blocked addresses
// If equal to 2, done on a line-by-line basis according to
- // SAFE_HEAP_LINES (note that these are the lines to *exclude*
- // from checking - the opposite of what CORRECT_*_LINES mean)
+ // SAFE_HEAP_LINES, checking only the specified lines.
+ // If equal to 3, checking all *but* the specified lines. Note
+ // that 3 is the option you usually want here.
SAFE_HEAP_LOG = 0; // Print out every single heap read and write (LOTS of output)
LABEL_DEBUG = 0; // Print out labels and functions as we enter them
EXCEPTION_DEBUG = 1; // Print out exceptions in emscriptened code
@@ -71,7 +73,8 @@ CORRECT_OVERFLOWS = 1; // Experimental code that tries to prevent unexpected JS
// it slows things down.
//
// If equal to 2, done on a line-by-line basis according to
- // CORRECT_OVERFLOWS_LINES
+ // CORRECT_OVERFLOWS_LINES, correcting only the specified lines.
+ // If equal to 3, correcting all *but* the specified lines
//
// NOTE: You can introduce signing issues by using this option. If you
// take a large enough 32-bit value, and correct it for overflows,