All files / src/generator else.js

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  22x 22x 22x     22x     42x              
// @flow
import opcode from '../emitter/opcode';
import mapSyntax from './map-syntax';
import mergeBlock from './merge-block';
import type { GeneratorType } from './flow/types';
 
const generateElse: GeneratorType = (node, parent) => {
  // TODO: blocks should encode a return type and an end opcode,
  // but currently they are only used as part of a larger control flow instructions
  return [
    { kind: opcode.Else, params: [] },
    ...node.params.map(mapSyntax(parent)).reduce(mergeBlock, []),
  ];
};
 
export default generateElse;