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

Method ConvertBinaryExpression

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

Source from the content-addressed store, hash-verified

320 }
321
322 static ConvertBinaryExpression (n, ctx) {
323 const [type, op] = ({
324 '+': ['math_or_string_arithmetic', 'ADD'],
325 '-': ['math_or_string_arithmetic', 'MINUS'],
326 '*': ['math_or_string_arithmetic', 'MULTIPLY'],
327 '/': ['math_or_string_arithmetic', 'DIVIDE'],
328 '**': ['math_or_string_arithmetic', 'POWER'],
329
330 '&&': ['logic_operation', 'AND'],
331 '||': ['logic_operation', 'OR'],
332
333 '>': ['logic_compare', 'GT'],
334 '<': ['logic_compare', 'LT'],
335 '>=': ['logic_compare', 'GTE'],
336 '<=': ['logic_compare', 'LTE'],
337 '==': ['logic_compare', 'EQ'],
338 '!=': ['logic_compare', 'NEQ'],
339
340 '===': ['logic_compare', 'EQ'],
341 '!==': ['logic_compare', 'NEQ'],
342
343 })[n.operator]
344 return {
345 type,
346 fields: {
347 OP: op,
348 },
349 inputs: {
350 A: { block: convert(n.left, ctx) },
351 B: { block: convert(n.right, ctx) },
352 },
353 }
354 }
355
356 static ConvertLogicalExpression (n, ctx) {
357 return Converters.ConvertBinaryExpression(n, ctx)

Callers 1

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected