This is part of #5153 but is being prioritised because we want remove
the declareLegacyNamespace calls from the core/utils/*.js modules and
then reexport them explicitly via utils.js, and it turns out that
doing so results in the exports object of this module being passed to
Object.freeze - which fails on the global object, which can't be made
non-extensible!
The new name chosen for the former default export is globalThis, since
it is intended to have the same value as the global variable of that
name; see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
A {} has a bunch of names already defined on it (like ‘toString’). When using an object as a map with arbitrary keys, it should not inherit from Object.prototype.
This enables the generator for any block to see all variable names and procedure names in the whole program, including those that haven’t generated yet.
Only for JS, Lua, and PHP. Dart and Python need extra logic to split out import statements.
Also use ‘this’ instead of fully qualified names in generators.
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.
* Fix dart text generator logic
* Fix Javascript text generator logic.
* Fix Lua text generator logic
* Fix php text generator logic
* Fix python text generator logic
* Fix error in substring logic
* Fix unit test block generators
* Update from ORDER_COMMA to ORDER_NONE
* Update golden files
This change means the list is complete for every environment. This makes evaling code more safe. However it also means that code generated on one environment isn't guaranteed to be free of global collisions when executed on another environment (with the exception of the JS Interpreter).
So if you are generating code in Node, and then executing it with eval() in a user's browser a user's program could declare a variable named `location`, assign to it, and the browser will redirect to that URL. Honestly, that's what you get for evaling untrusted code between users. Use the JS Interpreter if you are doing anything other than just generating and executing in the same environment.
* Google changed from an Inc to an LLC.
This happened back in 2017 but we didn’t notice. Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade.
* Remove project description/titles from licenses
This is no longer part of Google’s header requirements. Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”).
* License no longer requires URL.
* Fix license regexps.
* Moved comment icons to use a model-based system. The block holds the model of the comment, and the comment icon holds a reference to it.
* Reorganized the setVisible function.
* Changed how xml.js serializes and deserializes comments.
Number() is a bit less forgiving than parseFloat() and is more likely to generate NaN rather than some random number. An audit of each case shows nowhere that parseFloat()’s features are needed.
Previously a function call with no return value generated:
prefix();
suffix();
function();
The intent was so the prefix and suffix calls in the function body wouldn’t overlap with the prefix and suffix calls of the function call. However, this is doomed to be inconsistent with a function call with a return value:
prefix();
print(function());
suffix();
Thus since overlaping must exist, both types of function calls should have consistent suffix locations.
Visit (with prefix and suffix) function block when executed. This commit adds a revisit at the end of the function body when evaluating the return value.
This allows generators to have more control over the placement of suffix. Needed for ‘if’ blocks and function calls which require their suffix code to be somewhere other than the end.
Also, add loop’s prefix to ‘break’ blocks, since the loop’s suffix will be the next statement hit.
Also, reuse procedures_callreturn generator for procedures_callnoreturn.
Also remove need to manually indent INFINITE_LOOP_TRAP. This is a breaking change for Python users of this property. However, very few users of this property exist, given that the existing code breaks if the block ID has a $ in it (also fixed in this PR).