You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added generator_context.ts with class GeneratorContext.
GeneratorContext holds information needed during and after python code generation:
- The module (so the ExtendedPythonGenerator can get the class and parent class names)
- Exported blocks (these are produced by the ExtendedPythonGenerator and are added to the file after code generation is finished).
- The class method names (maps from the block's NAME field to the actual python method name)
- Method getClassName returns the class name as PascalCase.
Modified ExtendedPythonGenerator so it can safely be a singleton.
- Removed fields currentModule and mapWorkspaceIdToExportedBlocks and added context (type GeneratorContext).
- Renamed methods_ field to classMethods. This field can stay in ExtendedPythonGenerator because it is only needed during workspaceToCode execution. It is not needed after workspaceToCode has finished.
- Added a field name workspace for the Blockly Workspace because it is needed in the finish method, but it is not a parameter.
- Removed init method override.
- Renamed method addMethod to addClassMethodDefinition and added NAME field value as a parameter.
- Added finish method override.
-- Here we still produce the code, which is the class definition line and the class method definitions.
-- By setting the code parameter to the code we want (the class definition) and passing it to super.finish, we can just call super.finish normally.
-- Produce the exported blocks.
- Moved setCurrentModule (renamed to setModule), getExportedBlocks, and classParentFromModuleType (renamed to getClassParent) to GeneratorContext.
Updated the App to create a GeneratorContext and pass it to workspaceToCode.
Updated common_storage to create a GeneratorContext and pass it to workspaceToCode.
Updated Editor to create a GeneratorContext and pass it to workspaceToCode.
Modified code generator for mrc_class_method_def blocks to return empty string.
0 commit comments