44 *
55 * GPU Accelerated JavaScript
66 *
7- * @version 2.10.6
8- * @date Wed Dec 02 2020 15:14:25 GMT-0500 (Eastern Standard Time)
7+ * @version 2.11.0
8+ * @date Tue Jan 05 2021 15:55:59 GMT-0500 (Eastern Standard Time)
99 *
1010 * @license MIT
1111 * The MIT License
1212 *
13- * Copyright (c) 2020 gpu.js Team
13+ * Copyright (c) 2021 gpu.js Team
1414 */ ( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . GPU = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function ( ) { function r ( e , n , t ) { function o ( i , f ) { if ( ! n [ i ] ) { if ( ! e [ i ] ) { var c = "function" == typeof require && require ; if ( ! f && c ) return c ( i , ! 0 ) ; if ( u ) return u ( i , ! 0 ) ; var a = new Error ( "Cannot find module '" + i + "'" ) ; throw a . code = "MODULE_NOT_FOUND" , a } var p = n [ i ] = { exports :{ } } ; e [ i ] [ 0 ] . call ( p . exports , function ( r ) { var n = e [ i ] [ 1 ] [ r ] ; return o ( n || r ) } , p , p . exports , r , e , n , t ) } return n [ i ] . exports } for ( var u = "function" == typeof require && require , i = 0 ; i < t . length ; i ++ ) o ( t [ i ] ) ; return o } return r } ) ( ) ( { 1 :[ function ( require , module , exports ) {
1515
1616} , { } ] , 2 :[ function ( require , module , exports ) {
@@ -1020,18 +1020,6 @@ class CPUFunctionNode extends FunctionNode {
10201020 return retArr ;
10211021 }
10221022 break ;
1023- case 'value.value[]' :
1024- if ( this . removeIstanbulCoverage ) {
1025- return retArr ;
1026- }
1027- retArr . push ( `${ mNode . object . object . name } .${ mNode . object . property . name } [${ mNode . property . value } ]` ) ;
1028- return retArr ;
1029- case 'value.value[][]' :
1030- if ( this . removeIstanbulCoverage ) {
1031- return retArr ;
1032- }
1033- retArr . push ( `${ mNode . object . object . object . name } .${ mNode . object . object . property . name } [${ mNode . object . property . value } ][${ mNode . property . value } ]` ) ;
1034- return retArr ;
10351023 case 'this.constants.value' :
10361024 case 'this.constants.value[]' :
10371025 case 'this.constants.value[][]' :
@@ -2039,8 +2027,6 @@ class FunctionBuilder {
20392027 followingReturnStatement,
20402028 dynamicArguments,
20412029 dynamicOutput,
2042- onIstanbulCoverageVariable,
2043- removeIstanbulCoverage,
20442030 } = kernel ;
20452031
20462032 const argumentTypes = new Array ( kernelArguments . length ) ;
@@ -2127,8 +2113,6 @@ class FunctionBuilder {
21272113 triggerImplyArgumentType,
21282114 triggerImplyArgumentBitRatio,
21292115 onFunctionCall,
2130- onIstanbulCoverageVariable : onIstanbulCoverageVariable ? ( name ) => onIstanbulCoverageVariable ( name , kernel ) : null ,
2131- removeIstanbulCoverage,
21322116 optimizeFloatMemory,
21332117 precision,
21342118 constants,
@@ -2181,8 +2165,6 @@ class FunctionBuilder {
21812165 triggerImplyArgumentBitRatio,
21822166 onFunctionCall,
21832167 onNestedFunction,
2184- onIstanbulCoverageVariable : onIstanbulCoverageVariable ? ( name ) => onIstanbulCoverageVariable ( name , kernel ) : null ,
2185- removeIstanbulCoverage,
21862168 } ) ) ;
21872169 }
21882170
@@ -2608,8 +2590,6 @@ class FunctionNode {
26082590 this . dynamicArguments = null ;
26092591 this . strictTypingChecking = false ;
26102592 this . fixIntegerDivisionAccuracy = null ;
2611- this . onIstanbulCoverageVariable = null ;
2612- this . removeIstanbulCoverage = false ;
26132593
26142594 if ( settings ) {
26152595 for ( const p in settings ) {
@@ -2685,7 +2665,7 @@ class FunctionNode {
26852665
26862666 if ( ast . type === 'MemberExpression' ) {
26872667 if ( ast . object && ast . property ) {
2688- if ( ast . object . hasOwnProperty ( 'name' ) && ast . object . name [ 0 ] === '_ ') {
2668+ if ( ast . object . hasOwnProperty ( 'name' ) && ast . object . name !== 'Math ') {
26892669 return this . astMemberExpressionUnroll ( ast . property ) ;
26902670 }
26912671
@@ -2905,6 +2885,11 @@ class FunctionNode {
29052885 if ( this . getVariableSignature ( ast . callee , true ) === 'this.color' ) {
29062886 return null ;
29072887 }
2888+ if ( ast . callee . type === 'MemberExpression' && ast . callee . object && ast . callee . property && ast . callee . property . name && ast . arguments ) {
2889+ const functionName = ast . callee . property . name ;
2890+ this . inferArgumentTypesIfNeeded ( functionName , ast . arguments ) ;
2891+ return this . lookupReturnType ( functionName , ast , this ) ;
2892+ }
29082893 throw this . astErrorOutput ( 'Unknown call expression' , ast ) ;
29092894 }
29102895 if ( ast . callee && ast . callee . name ) {
@@ -3345,8 +3330,6 @@ class FunctionNode {
33453330 'value[][][]' ,
33463331 'value[][][][]' ,
33473332 'value.value' ,
3348- 'value.value[]' ,
3349- 'value.value[][]' ,
33503333 'value.thread.value' ,
33513334 'this.thread.value' ,
33523335 'this.output.value' ,
@@ -3560,20 +3543,11 @@ class FunctionNode {
35603543 astThisExpression ( ast , retArr ) {
35613544 return retArr ;
35623545 }
3563- isIstanbulAST ( ast ) {
3564- const variableSignature = this . getVariableSignature ( ast ) ;
3565- return variableSignature === 'value.value[]' || variableSignature === 'value.value[][]' ;
3566- }
35673546 astSequenceExpression ( sNode , retArr ) {
35683547 const { expressions } = sNode ;
35693548 const sequenceResult = [ ] ;
35703549 for ( let i = 0 ; i < expressions . length ; i ++ ) {
35713550 const expression = expressions [ i ] ;
3572- if ( this . removeIstanbulCoverage ) {
3573- if ( expression . type === 'UpdateExpression' && this . isIstanbulAST ( expression . argument ) ) {
3574- continue ;
3575- }
3576- }
35773551 const expressionResult = [ ] ;
35783552 this . astGeneric ( expression , expressionResult ) ;
35793553 sequenceResult . push ( expressionResult . join ( '' ) ) ;
@@ -3605,12 +3579,6 @@ class FunctionNode {
36053579 checkAndUpconvertBitwiseUnary ( uNode , retArr ) { }
36063580
36073581 astUpdateExpression ( uNode , retArr ) {
3608- if ( this . removeIstanbulCoverage ) {
3609- const signature = this . getVariableSignature ( uNode . argument ) ;
3610- if ( this . isIstanbulAST ( uNode . argument ) ) {
3611- return retArr ;
3612- }
3613- }
36143582 if ( uNode . prefix ) {
36153583 retArr . push ( uNode . operator ) ;
36163584 this . astGeneric ( uNode . argument , retArr ) ;
@@ -3814,28 +3782,8 @@ class FunctionNode {
38143782 signature : variableSignature ,
38153783 property : ast . property ,
38163784 } ;
3817- case 'value.value[]' :
3818- if ( this . removeIstanbulCoverage ) {
3819- return { signature : variableSignature } ;
3820- }
3821- if ( this . onIstanbulCoverageVariable ) {
3822- this . onIstanbulCoverageVariable ( ast . object . object . name ) ;
3823- return {
3824- signature : variableSignature
3825- } ;
3826- }
3827- case 'value.value[][]' :
3828- if ( this . removeIstanbulCoverage ) {
3829- return { signature : variableSignature } ;
3830- }
3831- if ( this . onIstanbulCoverageVariable ) {
3832- this . onIstanbulCoverageVariable ( ast . object . object . object . name ) ;
3833- return {
3834- signature : variableSignature
3835- } ;
3836- }
3837- default :
3838- throw this . astErrorOutput ( 'Unexpected expression' , ast ) ;
3785+ default :
3786+ throw this . astErrorOutput ( 'Unexpected expression' , ast ) ;
38393787 }
38403788 }
38413789
@@ -6311,8 +6259,6 @@ class Kernel {
63116259 this . optimizeFloatMemory = null ;
63126260 this . strictIntegers = false ;
63136261 this . fixIntegerDivisionAccuracy = null ;
6314- this . onIstanbulCoverageVariable = null ;
6315- this . removeIstanbulCoverage = false ;
63166262 this . built = false ;
63176263 this . signature = null ;
63186264 }
@@ -6339,11 +6285,6 @@ class Kernel {
63396285 }
63406286 this [ p ] = settings [ p ] ;
63416287 continue ;
6342- case 'removeIstanbulCoverage' :
6343- if ( settings [ p ] !== null ) {
6344- this [ p ] = settings [ p ] ;
6345- }
6346- continue ;
63476288 case 'nativeFunctions' :
63486289 if ( ! settings . nativeFunctions ) continue ;
63496290 this . nativeFunctions = [ ] ;
@@ -8338,13 +8279,8 @@ class WebGLFunctionNode extends FunctionNode {
83388279 retArr . push ( this . memberExpressionPropertyMarkup ( property ) ) ;
83398280 retArr . push ( ']' ) ;
83408281 return retArr ;
8341- case 'value.value[]' :
8342- case 'value.value[][]' :
8343- if ( this . removeIstanbulCoverage ) {
8344- return retArr ;
8345- }
8346- default :
8347- throw this . astErrorOutput ( 'Unexpected expression' , mNode ) ;
8282+ default :
8283+ throw this . astErrorOutput ( 'Unexpected expression' , mNode ) ;
83488284 }
83498285
83508286 if ( mNode . computed === false ) {
@@ -10183,7 +10119,6 @@ class WebGLKernel extends GLKernel {
1018310119
1018410120 this . maxTexSize = null ;
1018510121 this . onRequestSwitchKernel = null ;
10186- this . removeIstanbulCoverage = true ;
1018710122
1018810123 this . texture = null ;
1018910124 this . mappedTextures = null ;
@@ -13538,8 +13473,6 @@ class GPU {
1353813473 this . functions = [ ] ;
1353913474 this . nativeFunctions = [ ] ;
1354013475 this . injectedNative = null ;
13541- this . onIstanbulCoverageVariable = settings . onIstanbulCoverageVariable || null ;
13542- this . removeIstanbulCoverage = settings . hasOwnProperty ( 'removeIstanbulCoverage' ) ? settings . removeIstanbulCoverage : null ;
1354313476 if ( this . mode === 'dev' ) return ;
1354413477 this . chooseKernel ( ) ;
1354513478 if ( settings . functions ) {
@@ -13715,8 +13648,6 @@ class GPU {
1371513648 gpu : _kernel . gpu ,
1371613649 validate,
1371713650 returnType : _kernel . returnType ,
13718- onIstanbulCoverageVariable : _kernel . onIstanbulCoverageVariable ,
13719- removeIstanbulCoverage : _kernel . removeIstanbulCoverage ,
1372013651 tactic : _kernel . tactic ,
1372113652 onRequestFallback,
1372213653 onRequestSwitchKernel,
@@ -13735,8 +13666,6 @@ class GPU {
1373513666 functions : this . functions ,
1373613667 nativeFunctions : this . nativeFunctions ,
1373713668 injectedNative : this . injectedNative ,
13738- onIstanbulCoverageVariable : this . onIstanbulCoverageVariable ,
13739- removeIstanbulCoverage : this . removeIstanbulCoverage ,
1374013669 gpu : this ,
1374113670 validate,
1374213671 onRequestFallback,
0 commit comments