mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
* chore: replace var with const and let in python block generators * chore: update test deps * chore: update bracket usage in switch statements
33 lines
831 B
JavaScript
33 lines
831 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2012 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Generating Python for variable blocks.
|
|
*/
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.Python.variables');
|
|
|
|
goog.require('Blockly.Python');
|
|
|
|
|
|
Blockly.Python['variables_get'] = function(block) {
|
|
// Variable getter.
|
|
const code = Blockly.Python.nameDB_.getName(block.getFieldValue('VAR'),
|
|
Blockly.VARIABLE_CATEGORY_NAME);
|
|
return [code, Blockly.Python.ORDER_ATOMIC];
|
|
};
|
|
|
|
Blockly.Python['variables_set'] = function(block) {
|
|
// Variable setter.
|
|
const argument0 =
|
|
Blockly.Python.valueToCode(block, 'VALUE', Blockly.Python.ORDER_NONE) ||
|
|
'0';
|
|
const varName = Blockly.Python.nameDB_.getName(
|
|
block.getFieldValue('VAR'), Blockly.VARIABLE_CATEGORY_NAME);
|
|
return varName + ' = ' + argument0 + '\n';
|
|
};
|