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

@@ -131,12 +131,6 @@ Blockly.PHP.ORDER_OVERRIDES = [
[Blockly.PHP.ORDER_LOGICAL_OR, Blockly.PHP.ORDER_LOGICAL_OR]
];
/**
* Allow for switching between one and zero based indexing for lists and text,
* one based by default.
*/
Blockly.PHP.ONE_BASED_INDEXING = true;
/**
* Initialise the database of variable names.
* @param {!Blockly.Workspace} workspace Workspace to generate code from.
@@ -257,10 +251,10 @@ Blockly.PHP.getAdjusted = function(block, atId, opt_delta, opt_negate,
opt_order) {
var delta = opt_delta || 0;
var order = opt_order || Blockly.PHP.ORDER_NONE;
if (Blockly.PHP.ONE_BASED_INDEXING) {
if (block.workspace.options.oneBasedIndex) {
delta--;
}
var defaultAtIndex = Blockly.PHP.ONE_BASED_INDEXING ? '1' : '0';
var defaultAtIndex = block.workspace.options.oneBasedIndex ? '1' : '0';
if (delta > 0) {
var at = Blockly.PHP.valueToCode(block, atId,
Blockly.PHP.ORDER_ADDITION) || defaultAtIndex;