You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
867 B
48 lines
867 B
import TempNode from '../core/Node.js';
|
|
|
|
class JoinNode extends TempNode {
|
|
|
|
constructor( nodes = [], nodeType = null ) {
|
|
|
|
super( nodeType );
|
|
|
|
this.nodes = nodes;
|
|
|
|
}
|
|
|
|
getNodeType( builder ) {
|
|
|
|
if ( this.nodeType !== null ) {
|
|
|
|
return builder.getVectorType( this.nodeType );
|
|
|
|
}
|
|
|
|
return builder.getTypeFromLength( this.nodes.reduce( ( count, cur ) => count + builder.getTypeLength( cur.getNodeType( builder ) ), 0 ) );
|
|
|
|
}
|
|
|
|
generate( builder, output ) {
|
|
|
|
const type = this.getNodeType( builder );
|
|
const nodes = this.nodes;
|
|
|
|
const snippetValues = [];
|
|
|
|
for ( const input of nodes ) {
|
|
|
|
const inputSnippet = input.build( builder );
|
|
|
|
snippetValues.push( inputSnippet );
|
|
|
|
}
|
|
|
|
const snippet = `${ builder.getType( type ) }( ${ snippetValues.join( ', ' ) } )`;
|
|
|
|
return builder.format( snippet, type, output );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default JoinNode;
|
|
|