MCPcopy Create free account
hub / github.com/codecombat/codecombat / ConvertFunctionDeclaration

Method ConvertFunctionDeclaration

app/lib/code-to-blocks.js:506–526  ·  view source on GitHub ↗
(n, ctx)

Source from the content-addressed store, hash-verified

504 }
505
506 static ConvertFunctionDeclaration (n, ctx) {
507 ctx.scope[n.id.name] = { type: 'fx', n }
508 // console.log('FX', n)
509 const o = {
510 type: 'procedures_defnoreturn',
511 extraState: { params: [] },
512 fields: {
513 NAME: n.id.name,
514 },
515 inputs: {},
516 }
517
518 for (const p of n.params) {
519 ctx.scope[p.name] = { type: 'var' }
520 o.extraState.params.push({ name: p.name, id: p.name })
521 }
522
523 if (n.body && n.body.body.length > 0) { o.inputs.STACK = { block: convert(n.body, { ...ctx, nospace: true })[0] } }
524
525 return o
526 }
527
528 static ConvertIdentifier (n, ctx) {
529 let out

Callers

nothing calls this directly

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected