# All files / src/generator memory.js

100% Statements 8/8
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21x
    21x

    21x
    6x
    6x

    7x
    7x

    6x

     // @flow
    import Syntax from "../Syntax";
    import walkNode from "../utils/walk-node";
    import type { NodeType, IntermediateMemoryType } from "./flow/types";

    const generateMemory = (node: NodeType): IntermediateMemoryType => {
      const memory = { max: 0, initial: 0 };
      walkNode({
        [Syntax.Pair]: ({ params }) => {
          // This could procude garbage values but that is a fault of the source code
          const [{ value: key }, { value }] = params;
          memory[key] = parseInt(value);
        },
      })(node);

      return memory;
    };

    export default generateMemory;