mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
There is significant confusion in names and comments with regards to variables and procedures. `Blockly.Generator.prototype.variableDB_` is a Blockly.Names database, not a variable map. This rename introduces a getter and setter so deprecated references still work. This commit also fixes some comments which are either outright wrong or misleading regarding variable and procedure names.
33 lines
864 B
JavaScript
33 lines
864 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2015 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Generating PHP for variable blocks.
|
|
* @author daarond@gmail.com (Daaron Dwyer)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.PHP.variables');
|
|
|
|
goog.require('Blockly.PHP');
|
|
|
|
|
|
Blockly.PHP['variables_get'] = function(block) {
|
|
// Variable getter.
|
|
var code = Blockly.PHP.nameDB_.getName(block.getFieldValue('VAR'),
|
|
Blockly.VARIABLE_CATEGORY_NAME);
|
|
return [code, Blockly.PHP.ORDER_ATOMIC];
|
|
};
|
|
|
|
Blockly.PHP['variables_set'] = function(block) {
|
|
// Variable setter.
|
|
var argument0 = Blockly.PHP.valueToCode(block, 'VALUE',
|
|
Blockly.PHP.ORDER_ASSIGNMENT) || '0';
|
|
var varName = Blockly.PHP.nameDB_.getName(
|
|
block.getFieldValue('VAR'), Blockly.VARIABLE_CATEGORY_NAME);
|
|
return varName + ' = ' + argument0 + ';\n';
|
|
};
|