inline functions

This commit is contained in:
sussy layers dev 2023-11-18 11:11:55 +00:00 committed by GitHub
commit a809d3763b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -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" />

View file

@ -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',