# All files / src/core bool.js

100% Statements 15/15
100% Branches 6/6
100% Functions 7/7
100% Lines 14/14

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    87x

    174x
    245x
    1x

    244x

    87x
    87x
    179x
    3x

    176x

    87x
    648x
    18x

    630x

     export default function booleanPlugin() {
      return {
        semantics() {
          const declaration = next => ([decl, context]) => {
            if (decl.type === 'bool') {
              return next([{ ...decl, type: 'i32' }, context]);
            }

            return next([decl, context]);
          };
          return {
            FunctionResult: next => ([result, context]) => {
              if (result.type === 'bool') {
                return next([{ ...result, type: 'i32' }, context]);
              }

              return next([result, context]);
            },
            Constant: next => ([constant, ...rest]) => {
              if (constant.type === 'bool') {
                return next([{ ...constant, type: 'i32' }]);
              }

              return next([constant, ...rest]);
            },
            Declaration: declaration,
            ImmutableDeclaration: declaration,
          };
        },
      };
    }