mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
refactor(generators): Introduce PythonGenerator class, Order enum (#7163)
* refactor(generators): Introduce PhpGenerator class, Order enum * refactor(generators): Use Order.* instead of .ORDER_* * refactor(generators): Don't rename pythonGenerator
This commit is contained in:
committed by
GitHub
parent
26901654ea
commit
2f89c0dd09
@@ -12,21 +12,23 @@ import * as goog from '../../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.Python.variables');
|
||||
|
||||
import {NameType} from '../../core/names.js';
|
||||
import {pythonGenerator as Python} from '../python.js';
|
||||
import {pythonGenerator, Order} from '../python.js';
|
||||
|
||||
|
||||
Python.forBlock['variables_get'] = function(block) {
|
||||
pythonGenerator.forBlock['variables_get'] = function(block) {
|
||||
// Variable getter.
|
||||
const code =
|
||||
Python.nameDB_.getName(block.getFieldValue('VAR'), NameType.VARIABLE);
|
||||
return [code, Python.ORDER_ATOMIC];
|
||||
pythonGenerator.nameDB_.getName(
|
||||
block.getFieldValue('VAR'), NameType.VARIABLE);
|
||||
return [code, Order.ATOMIC];
|
||||
};
|
||||
|
||||
Python.forBlock['variables_set'] = function(block) {
|
||||
pythonGenerator.forBlock['variables_set'] = function(block) {
|
||||
// Variable setter.
|
||||
const argument0 =
|
||||
Python.valueToCode(block, 'VALUE', Python.ORDER_NONE) || '0';
|
||||
pythonGenerator.valueToCode(block, 'VALUE', Order.NONE) || '0';
|
||||
const varName =
|
||||
Python.nameDB_.getName(block.getFieldValue('VAR'), NameType.VARIABLE);
|
||||
pythonGenerator.nameDB_.getName(
|
||||
block.getFieldValue('VAR'), NameType.VARIABLE);
|
||||
return varName + ' = ' + argument0 + '\n';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user