Files
blockly/generators/dart/variables.js
Neil Fraser 90b3f75d82 Remove @author tags (#5601)
Our files are up to a decade old, and have churned so much, that the initial author of the file no longer has much meaning.

Furthermore, this will encourage developers to post to the developer group, rather than emailing Googlers (usually me) directly.
2021-10-15 09:50:46 -07:00

32 lines
805 B
JavaScript

/**
* @license
* Copyright 2014 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Generating Dart for variable blocks.
*/
'use strict';
goog.provide('Blockly.Dart.variables');
goog.require('Blockly.Dart');
Blockly.Dart['variables_get'] = function(block) {
// Variable getter.
var code = Blockly.Dart.nameDB_.getName(block.getFieldValue('VAR'),
Blockly.VARIABLE_CATEGORY_NAME);
return [code, Blockly.Dart.ORDER_ATOMIC];
};
Blockly.Dart['variables_set'] = function(block) {
// Variable setter.
var argument0 = Blockly.Dart.valueToCode(block, 'VALUE',
Blockly.Dart.ORDER_ASSIGNMENT) || '0';
var varName = Blockly.Dart.nameDB_.getName(block.getFieldValue('VAR'),
Blockly.VARIABLE_CATEGORY_NAME);
return varName + ' = ' + argument0 + ';\n';
};