ArrayElementNode.js 487 B

12345678910111213141516171819202122232425262728293031
  1. import TempNode from '../core/Node.js';
  2. class ArrayElementNode extends TempNode {
  3. constructor( node, indexNode ) {
  4. super();
  5. this.node = node;
  6. this.indexNode = indexNode;
  7. }
  8. getNodeType( builder ) {
  9. return this.node.getNodeType( builder );
  10. }
  11. generate( builder ) {
  12. const nodeSnippet = this.node.build( builder );
  13. const indexSnippet = this.indexNode.build( builder, 'uint' );
  14. return `${nodeSnippet}[ ${indexSnippet} ]`;
  15. }
  16. }
  17. export default ArrayElementNode;