Automatic commit Sat Jan 11 03:00:02 PST 2014

This commit is contained in:
ellen.spertus
2014-01-11 03:00:02 -08:00
parent f29e70834f
commit 08f4022b38
43 changed files with 2067 additions and 1937 deletions

View File

@@ -82,16 +82,6 @@ Blockly.Python.ORDER_NONE = 99; // (...)
*/
Blockly.Python.INFINITE_LOOP_TRAP = null;
/**
* This is used as a placeholder in functions defined using
* Blockly.Python.provideFunction_. It must not be legal code that could
* legitimately appear in a function definition (or comment), and it must
* not confuse the regular expression parser.
*/
Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ = '{{{}}}';
Blockly.Python.FUNCTION_NAME_PLACEHOLDER_REGEXP_ =
new RegExp(Blockly.Python.FUNCTION_NAME_PLACEHOLDER_, 'g');
/**
* Initialise the database of variable names.
*/
@@ -207,31 +197,3 @@ Blockly.Python.scrub_ = function(block, code) {
var nextCode = this.blockToCode(nextBlock);
return commentCode + code + nextCode;
};
/**
* Define a function to be included in the generated code.
* The first time this is called with a given desiredName, the code is
* saved and an actual name is generated. Subsequent calls with the
* same desiredName have no effect but have the same return value.
*
* It is up to the caller to make sure the same desiredName is not
* used for different code values.
*
* The code gets output when Blockly.Python.finish() is called.
*
* @param {string} desiredName The desired name of the function (e.g., isPrime).
* @param {code} A list of Python statements.
* @return {string} The actual name of the new function. This may differ
* from desiredName if the former has already been taken by the user.
* @private
*/
Blockly.Python.provideFunction_ = function(desiredName, code) {
if (!Blockly.Python.definitions_[desiredName]) {
var functionName = Blockly.Python.variableDB_.getDistinctName(
desiredName, Blockly.Generator.NAME_TYPE);
Blockly.Python.functionNames_[desiredName] = functionName;
Blockly.Python.definitions_[desiredName] = code.join('\n').replace(
Blockly.Python.FUNCTION_NAME_PLACEHOLDER_REGEXP_, functionName);
}
return Blockly.Python.functionNames_[desiredName];
};