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

Method ConvertCallExpression

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

Source from the content-addressed store, hash-verified

370 }
371
372 static ConvertCallExpression (n, ctx) {
373 if (n.callee.type === 'Identifier') {
374 // console.log('CALL', n, ctx.scope)
375
376 if (n.callee.name === '__comment__') {
377 return {
378 type: 'comment',
379 fields: {
380 COMMENT: n.arguments[0].value.trim(),
381 },
382 }
383 }
384
385 if (n.callee.name === '__arrow__') {
386 return {
387 type: 'entry_point',
388 fields: {
389 },
390 }
391 }
392
393 if (n.callee.name === '__donothing__') {
394 return null
395 }
396
397 if (ctx.scope[n.callee.name] && ctx.scope[n.callee.name].type === 'fx') {
398 const inputs = {}
399 const extraState = { params: [] }
400 for (let i = 0; i < n.arguments.length; ++i) {
401 inputs[`ARG${i}`] = { block: convert(n.arguments[i], { ...ctx, context: 'value' }) }
402 }
403 for (const p of ctx.scope[n.callee.name].n.params) {
404 extraState.params.push(p.name)
405 }
406
407 if (ctx.context === 'value') {
408 return {
409 type: 'procedures_callreturn',
410 fields: {
411 NAME: n.callee.name,
412 },
413 inputs,
414 extraState,
415 }
416 } else {
417 return {
418 type: 'procedures_callnoreturn',
419 fields: {
420 NAME: n.callee.name,
421 },
422 inputs,
423 extraState,
424 }
425 }
426 }
427 }
428
429 if (n.callee.type === 'MemberExpression') {

Callers

nothing calls this directly

Calls 4

convertFunction · 0.85
findOneFunction · 0.85
fuzzyMatchFunction · 0.85
stringifyMethod · 0.45

Tested by

no test coverage detected