Add procedures to name DB in init

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.
This commit is contained in:
Neil Fraser
2021-05-22 00:01:32 -07:00
committed by Neil Fraser
parent 17f9209f2f
commit 9869269ce2
7 changed files with 47 additions and 2 deletions

View File

@@ -156,6 +156,14 @@ Blockly.PHP.init = function(workspace) {
Blockly.VARIABLE_CATEGORY_NAME) + ';');
}
// Add user procedures.
var procedures = Blockly.Procedures.allProcedures(workspace);
// Flatten the return vs no-return procedure lists.
procedures = procedures[0].concat(procedures[1]);
for (var i = 0; i < procedures.length; i++) {
this.nameDB_.getName(procedures[i][0], Blockly.PROCEDURE_CATEGORY_NAME);
}
// Declare all of the variables.
this.definitions_['variables'] = defvars.join('\n');
this.isInitialized = true;