Commit Graph

210 Commits

Author SHA1 Message Date
Monica Kozbial 81d355f5fa Fix order errors in text generators (#4329)
* 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
2020-09-30 14:08:45 -07:00
Rachel Fenichel 0b423abd4d Merge pull request #4294 from rachel-fenichel/bugfix/dart_multiline
Fix dart multiline strings
2020-09-18 13:51:38 -07:00
Rachel Fenichel 1350604e93 Fix dart multiline strings 2020-09-18 13:37:54 -07:00
Rachel Fenichel 7da8d4abfe Fix PHP multiline string 2020-09-18 13:27:04 -07:00
Rachel Fenichel afcbb7036e Fix python multiline string 2020-09-18 12:11:48 -07:00
Rachel Fenichel 773a4430e7 Fix lua multiline quote 2020-09-18 11:02:17 -07:00
Monica Kozbial fcc3a09661 Fix python loop (#4007)
* Fix code generation for python controls_for

* Update python golden file.
2020-06-30 11:35:48 -07:00
Rachel Fenichel 99dc14c323 Avoid .includes 2020-06-24 17:43:47 -07:00
Monica Kozbial df1508b547 Use getter for variables in procedure generator. (#3971) 2020-06-15 09:47:51 -07:00
Monica Kozbial d6abf4798e Fixing operator precedence in Lua and and adding test. (#3765)
* Fixing operator precedence in Lua and and adding test.

* Updating golden files.
2020-03-25 14:34:07 -07:00
Neil Fraser 4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00
Sam El-Husseini 72c6aa8699 Block generator warnings (#3353) 2019-10-28 16:20:25 -07:00
Sam El-Husseini 64c52efb5b Resolve warnings in generator code (#3350) 2019-10-28 09:35:40 -07:00
alschmiedt b19e6a5fbf Remove deprectaed use of Blockly.Procedures.NAME_TYPE (#3301) 2019-10-22 04:33:13 -05:00
Neil Fraser ce02665044 Replace static reserved word list with dynamic scan (#3269)
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.
2019-10-17 11:17:37 -07:00
Sam El-Husseini 986e965be8 Private/protected visibility cleanup (#3263)
* Fix a number of private visibility issues
2019-10-16 11:48:09 -05:00
RoboErikG e62c2a3f6b Remove multi-line comments to avoid escaping (#3231)
Fixes #3230 by removing multi-line comments for procedures.
2019-10-14 10:40:22 -07:00
Neil Fraser b46a4fe286 Bring our license format up to date (#3127)
* 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.
2019-10-02 14:46:56 -07:00
Beka Westberg 9e5df6216a Fixed comment ownership. (#2923)
* 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.
2019-09-20 13:16:07 -07:00
Rachel Fenichel 6f4476c962 Textarea Field, Multiline Block (from acbart) (#2663)
* Field Textarea, text_multiline block, generators
2019-09-11 17:57:46 -07:00
Neil Fraser 939bbd072b Lint 2019-08-02 11:00:40 -07:00
Neil Fraser e77a9b7e81 Change parseFloat() to Number()
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.
2019-08-01 11:36:58 -07:00
Neil Fraser 92c4d6d3a3 Fix colour injection vulnerability.
The new validators already solve this problem, but as a second layer of defence, the generators should also be secured.  Issue #2637
2019-07-15 16:03:55 -07:00
Neil Fraser d1a29739d8 Move utilities into own directory.
TODO: There are more functions which may be migrated into dom and string.
2019-06-07 10:32:57 -07:00
Neil Fraser 05253d0766 Add prefix/suffix to orphaned value blocks.
Also respect suppressPrefixSuffix on loops when generating prefix/suffix with continue/break blocks.
2019-05-17 15:04:39 -07:00
Neil Fraser ed0b5adcd1 Wrong language. 2019-05-17 15:04:39 -07:00
Neil Fraser e642a77f5d Use conventional prefix/suffix for function calls.
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.
2019-05-17 15:04:39 -07:00
Neil Fraser 04e39c20f8 Fix indentation bug if no xfix exists in function 2019-05-14 17:19:31 -07:00
Neil Fraser 585866a1b6 Revisit function block for return.
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.
2019-05-14 17:19:31 -07:00
Neil Fraser c0e14c3a7c Add method to suppress prefix/suffix from blocks.
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.
2019-05-14 17:19:31 -07:00
Neil Fraser 25adb40e66 Prefix and suffix edge cases for flow statements.
Call suffix code on break/continue before executing the break/continue.
Call prefix code for enclosing loop before executing continue.
2019-05-14 17:19:31 -07:00
Neil Fraser 0259f8bb48 Add extra suffix when generating if/return block.
Also fix loops in Lua.
2019-05-14 17:19:31 -07:00
Neil Fraser ba18ae2159 Add STATEMENT_SUFFIX
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).
2019-05-14 17:19:31 -07:00
tojimjiang 25b883d920 Remove Python references in Dart math generator
Resolves #2329
Commit in develop branch
2019-03-27 15:48:03 -07:00
Rachel Fenichel e4690902de Merge pull request #2179 from DubeySandeep/PHP-text-outerOrder
Fix #2161: Changes outerOrder for PHP/text component.
2018-12-17 13:28:20 -08:00
Sandeep Dubey 8d09419afc Changes outerOrder for PHP/text component. 2018-12-16 22:32:19 +05:30
alschmiedt f06bee4eca Fixes pull request comments 2018-11-27 09:55:15 -08:00
Abby Schmiedt 26a4774b35 Adds option to generate code for a single block 2018-11-21 09:00:29 -08:00
Andrew n marshall 9252c947bc Add new atan2 block (PR #2079)
Merge pull request from nadyafebi/add-atan2-support-1835
2018-10-16 11:27:00 -07:00
Andrew n marshall 58bfab7c6c Math.PI => Math.pi
The Dart test was failing prior to this.
2018-10-16 11:25:10 -07:00
Neil Fraser 4f714716a5 Upgrade to dart 2.0 2018-10-15 16:17:50 -07:00
Nadya Febiana Djojosantoso d3deeedc02 Add math_atan2 Python generator 2018-10-11 14:34:26 -07:00
Nadya Febiana Djojosantoso c61822befa Add math_atan2 PHP generator 2018-10-11 14:20:27 -07:00
Nadya Febiana Djojosantoso 683a738166 Add math_atan2 Lua generator 2018-10-11 14:19:40 -07:00
Nadya Febiana Djojosantoso fd0bcabacd Add math_atan2 Dart generator 2018-10-11 14:19:01 -07:00
Nadya Febiana Djojosantoso 23bb0e00d9 Add math_atan2 JavaScript generator 2018-10-11 14:18:25 -07:00
Neil Fraser f3a76cc288 Remove unneeded String() and str() calls.
String literals in JS and Python don’t need to be coerced to strings.
2018-09-25 14:00:00 -07:00
Andrew n marshall f42291ea64 Do not escape % in python strings. (#1982)
Rebase of PR-1890, commit 793055… from Ellipsis753:patch-1
2018-07-20 15:54:11 -07:00
Neil Fraser c8bfc888c8 Throw errors instead of strings. (#1974)
Blocks and generators
2018-07-16 16:33:44 -07:00
Neil Fraser 6203cadcae Move away from math.log10 and math.pow in Lua generators.
Fixes #1695
2018-03-12 11:35:29 -07:00