inline functions
This commit is contained in:
parent
e797efe83d
commit
a809d3763b
2 changed files with 24 additions and 0 deletions
|
|
@ -90,6 +90,8 @@
|
|||
</category>
|
||||
<category name="Functions" colour="#5531D6">
|
||||
<block type="functions_create" />
|
||||
<block type="functions_inline" />
|
||||
<sep gap="48"></sep>
|
||||
<block type="functions_return" />
|
||||
<sep gap="48"></sep>
|
||||
<block type="functions_call" />
|
||||
|
|
|
|||
|
|
@ -34,6 +34,28 @@ function register() {
|
|||
return `${code}\n`;
|
||||
})
|
||||
|
||||
// inline function
|
||||
registerBlock(`${categoryPrefix}inline`, {
|
||||
message0: 'inline function %1 %2',
|
||||
args0: [
|
||||
{
|
||||
"type": "input_dummy"
|
||||
},
|
||||
{
|
||||
"type": "input_statement",
|
||||
"name": "FUNC"
|
||||
}
|
||||
],
|
||||
output: null,
|
||||
inputsInline: true,
|
||||
colour: categoryColor,
|
||||
}, (block) => {
|
||||
const FUNC = javascriptGenerator.statementToCode(block, 'FUNC');
|
||||
|
||||
const code = `(() => { ${FUNC} })`;
|
||||
return `${code}\n`;
|
||||
})
|
||||
|
||||
// return
|
||||
registerBlock(`${categoryPrefix}return`, {
|
||||
message0: 'return %1',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue