Collapse the five 0/1-based index flags into one option.

This commit is contained in:
Neil Fraser
2016-10-06 17:54:43 -07:00
parent e6ec2d6fd9
commit 7928fac3ce
24 changed files with 60 additions and 74 deletions

View File

@@ -84,12 +84,6 @@ Blockly.Dart.ORDER_CASCADE = 15; // ..
Blockly.Dart.ORDER_ASSIGNMENT = 16; // = *= /= ~/= %= += -= <<= >>= &= ^= |=
Blockly.Dart.ORDER_NONE = 99; // (...)
/**
* Allow for switching between one and zero based indexing for lists and text,
* one based by default.
*/
Blockly.Dart.ONE_BASED_INDEXING = true;
/**
* Initialise the database of variable names.
* @param {!Blockly.Workspace} workspace Workspace to generate code from.
@@ -232,10 +226,10 @@ Blockly.Dart.getAdjusted = function(block, atId, opt_delta, opt_negate,
opt_order) {
var delta = opt_delta || 0;
var order = opt_order || Blockly.Dart.ORDER_NONE;
if (Blockly.Dart.ONE_BASED_INDEXING) {
if (block.workspace.options.oneBasedIndex) {
delta--;
}
var defaultAtIndex = Blockly.Dart.ONE_BASED_INDEXING ? '1' : '0';
var defaultAtIndex = block.workspace.options.oneBasedIndex ? '1' : '0';
if (delta) {
var at = Blockly.Dart.valueToCode(block, atId,
Blockly.Dart.ORDER_ADDITIVE) || defaultAtIndex;