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.

36 lines
649 B

import Node, { addNodeClass } from '../core/Node.js';
class ArrayElementNode extends Node { // @TODO: If extending from TempNode it breaks webgpu_compute
constructor( node, indexNode ) {
super();
this.node = node;
this.indexNode = indexNode;
this.isArrayElementNode = true;
}
getNodeType( builder ) {
return this.node.getNodeType( builder );
}
generate( builder ) {
const nodeSnippet = this.node.build( builder );
const indexSnippet = this.indexNode.build( builder, 'uint' );
return `${nodeSnippet}[ ${indexSnippet} ]`;
}
}
export default ArrayElementNode;
addNodeClass( 'ArrayElementNode', ArrayElementNode );