mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
fixing some items
This commit is contained in:
@@ -105,17 +105,22 @@ Blockly.PHP.init = function(workspace) {
|
||||
} else {
|
||||
Blockly.PHP.variableDB_.reset();
|
||||
}
|
||||
|
||||
var defvars = [];
|
||||
var variables = Blockly.Variables.allVariables(workspace);
|
||||
for (var x = 0; x < variables.length; x++) {
|
||||
defvars[x] = 'var ' +
|
||||
Blockly.PHP.variableDB_.getName(variables[x],
|
||||
Blockly.Variables.NAME_TYPE) + ';';
|
||||
}
|
||||
Blockly.PHP.definitions_['variables'] = defvars.join('\n');
|
||||
};
|
||||
|
||||
Blockly.PHP.getDistinctName = function(name, type) {
|
||||
var safeName = this.variableDB_.safeName_(name);
|
||||
var i = '';
|
||||
while (this.variableDB_.dbReverse_[safeName + i] ||
|
||||
(safeName + i) in this.variableDB_.reservedDict_) {
|
||||
// Collision with existing name. Create a unique name.
|
||||
i = i ? i + 1 : 2;
|
||||
}
|
||||
safeName += i;
|
||||
this.variableDB_.dbReverse_[safeName] = true;
|
||||
return '$' + safeName;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Prepend the generated code with the variable definitions.
|
||||
* @param {string} code Generated code.
|
||||
|
||||
Reference in New Issue
Block a user