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

Method ConvertMemberExpression

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

Source from the content-addressed store, hash-verified

554 }
555
556 static ConvertMemberExpression (n, ctx) {
557 if (n.computed === true) {
558 return {
559 type: 'lists_getIndex',
560 fields: {
561 MODE: 'GET',
562 WHERE: 'FROM_START',
563 },
564 inputs: {
565 AT: { block: convert(n.property, ctx) },
566 VALUE: { block: convert(n.object, ctx) },
567 },
568 }
569 }
570
571 if (n.property.type === 'Identifier' && n.property.name === 'length') {
572 return {
573 type: 'lists_length',
574 inputs: {
575 VALUE: { block: convert(n.object, ctx) },
576 },
577 }
578 }
579
580 const found = findOne(ctx.plan, x => fuzzyMatch(n, x[1]), `Couldn't find match for ${JSON.stringify(n)}`)
581 // console.log(found)
582 return {
583 type: found[0].type,
584 }
585 }
586}
587
588function convert (node, ctx) {

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