Explorar o código

ArrayElementNode: Optimize indexes (#30741)

sunag hai 1 ano
pai
achega
fcae5a2d0e
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/nodes/utils/ArrayElementNode.js

+ 3 - 1
src/nodes/utils/ArrayElementNode.js

@@ -63,8 +63,10 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
 
 	generate( builder ) {
 
+		const indexType = this.indexNode.getNodeType( builder );
+
 		const nodeSnippet = this.node.build( builder );
-		const indexSnippet = this.indexNode.build( builder, 'uint' );
+		const indexSnippet = this.indexNode.build( builder, indexType === 'int' ? indexType : 'uint' );
 
 		return `${ nodeSnippet }[ ${ indexSnippet } ]`;
 

粤ICP备19079148号