36 lines
		
	
	
		
			649 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			36 lines
		
	
	
		
			649 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|  | 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 ); |