All files / src/generator function-call.js

100% Statements 9/9
100% Branches 2/2
100% Functions 1/1
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  22x 22x 22x 22x     22x 183x 183x   183x           183x        
// @flow
import mapSyntax from './map-syntax';
import opcode from '../emitter/opcode';
import mergeBlock from './merge-block';
import { FUNCTION_INDEX } from '../semantics/metadata';
import type { GeneratorType } from './flow/types';
 
const generateFunctionCall: GeneratorType = (node, parent) => {
  const block = node.params.map(mapSyntax(parent)).reduce(mergeBlock, []);
  const metaFunctionIndex = node.meta[FUNCTION_INDEX];
 
  block.push({
    kind: opcode.Call,
    params: [metaFunctionIndex],
    debug: `${node.value}<${node.type ? node.type : 'void'}>`,
  });
 
  return block;
};
 
export default generateFunctionCall;