JoinNode.js 696 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Node from '../core/Node.js';
  2. class JoinNode extends Node {
  3. constructor( values = [] ) {
  4. super();
  5. this.values = values;
  6. }
  7. getNodeType( builder ) {
  8. return builder.getTypeFromLength( this.values.length );
  9. }
  10. generate( builder, output ) {
  11. const type = this.getNodeType( builder );
  12. const values = this.values;
  13. const snippetValues = [];
  14. for ( let i = 0; i < values.length; i ++ ) {
  15. const input = values[ i ];
  16. const inputSnippet = input.build( builder, 'float' );
  17. snippetValues.push( inputSnippet );
  18. }
  19. const snippet = `${type}( ${ snippetValues.join( ', ' ) } )`;
  20. return builder.format( snippet, type, output );
  21. }
  22. }
  23. export default JoinNode;