44 *
55 * GPU Accelerated JavaScript
66 *
7- * @version 2.6.4
8- * @date Tue Jan 21 2020 08:05:29 GMT-0500 (Eastern Standard Time)
7+ * @version 2.6.5
8+ * @date Thu Jan 23 2020 07:17:48 GMT-0500 (Eastern Standard Time)
99 *
1010 * @license MIT
1111 * The MIT License
@@ -6948,6 +6948,7 @@ module.exports = {
69486948 fragmentShader
69496949} ;
69506950} , { } ] , 37 :[ function ( require , module , exports ) {
6951+ const { utils } = require ( '../../utils' ) ;
69516952const { FunctionNode } = require ( '../function-node' ) ;
69526953
69536954class WebGLFunctionNode extends FunctionNode {
@@ -7033,11 +7034,11 @@ class WebGLFunctionNode extends FunctionNode {
70337034 if ( ! type ) {
70347035 throw this . astErrorOutput ( 'Unexpected expression' , ast ) ;
70357036 }
7036-
7037+ const name = utils . sanitizeName ( argumentName ) ;
70377038 if ( type === 'sampler2D' || type === 'sampler2DArray' ) {
7038- retArr . push ( `${ type } user_${ argumentName } ,ivec2 user_${ argumentName } Size,ivec3 user_${ argumentName } Dim` ) ;
7039+ retArr . push ( `${ type } user_${ name } ,ivec2 user_${ name } Size,ivec3 user_${ name } Dim` ) ;
70397040 } else {
7040- retArr . push ( `${ type } user_${ argumentName } ` ) ;
7041+ retArr . push ( `${ type } user_${ name } ` ) ;
70417042 }
70427043 }
70437044 }
@@ -7479,16 +7480,17 @@ class WebGLFunctionNode extends FunctionNode {
74797480
74807481 const type = this . getType ( idtNode ) ;
74817482
7483+ const name = utils . sanitizeName ( idtNode . name ) ;
74827484 if ( idtNode . name === 'Infinity' ) {
74837485 retArr . push ( '3.402823466e+38' ) ;
74847486 } else if ( type === 'Boolean' ) {
7485- if ( this . argumentNames . indexOf ( idtNode . name ) > - 1 ) {
7486- retArr . push ( `bool(user_${ idtNode . name } )` ) ;
7487+ if ( this . argumentNames . indexOf ( name ) > - 1 ) {
7488+ retArr . push ( `bool(user_${ name } )` ) ;
74877489 } else {
7488- retArr . push ( `user_${ idtNode . name } ` ) ;
7490+ retArr . push ( `user_${ name } ` ) ;
74897491 }
74907492 } else {
7491- retArr . push ( `user_${ idtNode . name } ` ) ;
7493+ retArr . push ( `user_${ name } ` ) ;
74927494 }
74937495
74947496 return retArr ;
@@ -7682,7 +7684,7 @@ class WebGLFunctionNode extends FunctionNode {
76827684 throw new Error ( 'Unhandled declaration' ) ;
76837685 }
76847686 lastType = type ;
7685- declarationResult . push ( `user_${ declaration . id . name } =` ) ;
7687+ declarationResult . push ( `user_${ utils . sanitizeName ( declaration . id . name ) } =` ) ;
76867688 declarationResult . push ( 'float(' ) ;
76877689 this . astGeneric ( init , declarationResult ) ;
76887690 declarationResult . push ( ')' ) ;
@@ -7696,7 +7698,7 @@ class WebGLFunctionNode extends FunctionNode {
76967698 declarationResult . push ( `${ markupType } ` ) ;
76977699 }
76987700 lastType = type ;
7699- declarationResult . push ( `user_${ declaration . id . name } =` ) ;
7701+ declarationResult . push ( `user_${ utils . sanitizeName ( declaration . id . name ) } =` ) ;
77007702 if ( actualType === 'Number' && type === 'Integer' ) {
77017703 if ( init . left && init . left . type === 'Literal' ) {
77027704 this . astGeneric ( init , declarationResult ) ;
@@ -7932,18 +7934,19 @@ class WebGLFunctionNode extends FunctionNode {
79327934 retArr . push ( Math [ name ] ) ;
79337935 return retArr ;
79347936 }
7937+ const cleanName = utils . sanitizeName ( name ) ;
79357938 switch ( property ) {
79367939 case 'r' :
7937- retArr . push ( `user_${ name } .r` ) ;
7940+ retArr . push ( `user_${ cleanName } .r` ) ;
79387941 return retArr ;
79397942 case 'g' :
7940- retArr . push ( `user_${ name } .g` ) ;
7943+ retArr . push ( `user_${ cleanName } .g` ) ;
79417944 return retArr ;
79427945 case 'b' :
7943- retArr . push ( `user_${ name } .b` ) ;
7946+ retArr . push ( `user_${ cleanName } .b` ) ;
79447947 return retArr ;
79457948 case 'a' :
7946- retArr . push ( `user_${ name } .a` ) ;
7949+ retArr . push ( `user_${ cleanName } .a` ) ;
79477950 return retArr ;
79487951 }
79497952 break ;
@@ -8225,7 +8228,7 @@ class WebGLFunctionNode extends FunctionNode {
82258228 case 'Array(4)' :
82268229 if ( targetType === argumentType ) {
82278230 if ( argument . type === 'Identifier' ) {
8228- retArr . push ( `user_${ argument . name } ` ) ;
8231+ retArr . push ( `user_${ utils . sanitizeName ( argument . name ) } ` ) ;
82298232 } else if ( argument . type === 'ArrayExpression' || argument . type === 'MemberExpression' ) {
82308233 this . astGeneric ( argument , retArr ) ;
82318234 } else {
@@ -8247,7 +8250,8 @@ class WebGLFunctionNode extends FunctionNode {
82478250 if ( targetType === argumentType ) {
82488251 if ( argument . type !== 'Identifier' ) throw this . astErrorOutput ( `Unhandled argument type ${ argument . type } ` , ast ) ;
82498252 this . triggerImplyArgumentBitRatio ( this . name , argument . name , functionName , i ) ;
8250- retArr . push ( `user_${ argument . name } ,user_${ argument . name } Size,user_${ argument . name } Dim` ) ;
8253+ const name = utils . sanitizeName ( argument . name ) ;
8254+ retArr . push ( `user_${ name } ,user_${ name } Size,user_${ name } Dim` ) ;
82518255 continue ;
82528256 }
82538257 break ;
@@ -8345,7 +8349,7 @@ const operatorMap = {
83458349module . exports = {
83468350 WebGLFunctionNode
83478351} ;
8348- } , { "../function-node" :9 } ] , 38 :[ function ( require , module , exports ) {
8352+ } , { "../../utils" : 113 , "../ function-node" :9 } ] , 38 :[ function ( require , module , exports ) {
83498353const { WebGLKernelValueBoolean } = require ( './kernel-value/boolean' ) ;
83508354const { WebGLKernelValueFloat } = require ( './kernel-value/float' ) ;
83518355const { WebGLKernelValueInteger } = require ( './kernel-value/integer' ) ;
@@ -9967,7 +9971,7 @@ class WebGLKernel extends GLKernel {
99679971
99689972 for ( let index = 0 ; index < args . length ; index ++ ) {
99699973 const value = args [ index ] ;
9970- const name = this . argumentNames [ index ] ;
9974+ const name = utils . sanitizeName ( this . argumentNames [ index ] ) ;
99719975 let type ;
99729976 if ( needsArgumentTypes ) {
99739977 type = utils . getVariableType ( value , this . strictIntegers ) ;
@@ -10016,7 +10020,8 @@ class WebGLKernel extends GLKernel {
1001610020 }
1001710021 this . constantBitRatios = { } ;
1001810022 let textureIndexes = 0 ;
10019- for ( const name in this . constants ) {
10023+ for ( const p in this . constants ) {
10024+ const name = utils . sanitizeName ( p ) ;
1002010025 const value = this . constants [ name ] ;
1002110026 let type ;
1002210027 if ( needsConstantTypes ) {
@@ -11463,6 +11468,7 @@ module.exports = {
1146311468 fragmentShader
1146411469} ;
1146511470} , { } ] , 72 :[ function ( require , module , exports ) {
11471+ const { utils } = require ( '../../utils' ) ;
1146611472const { WebGLFunctionNode } = require ( '../web-gl/function-node' ) ;
1146711473
1146811474class WebGL2FunctionNode extends WebGLFunctionNode {
@@ -11477,16 +11483,17 @@ class WebGL2FunctionNode extends WebGLFunctionNode {
1147711483
1147811484 const type = this . getType ( idtNode ) ;
1147911485
11486+ const name = utils . sanitizeName ( idtNode . name ) ;
1148011487 if ( idtNode . name === 'Infinity' ) {
1148111488 retArr . push ( 'intBitsToFloat(2139095039)' ) ;
1148211489 } else if ( type === 'Boolean' ) {
11483- if ( this . argumentNames . indexOf ( idtNode . name ) > - 1 ) {
11484- retArr . push ( `bool(user_${ idtNode . name } )` ) ;
11490+ if ( this . argumentNames . indexOf ( name ) > - 1 ) {
11491+ retArr . push ( `bool(user_${ name } )` ) ;
1148511492 } else {
11486- retArr . push ( `user_${ idtNode . name } ` ) ;
11493+ retArr . push ( `user_${ name } ` ) ;
1148711494 }
1148811495 } else {
11489- retArr . push ( `user_${ idtNode . name } ` ) ;
11496+ retArr . push ( `user_${ name } ` ) ;
1149011497 }
1149111498
1149211499 return retArr ;
@@ -11496,7 +11503,7 @@ class WebGL2FunctionNode extends WebGLFunctionNode {
1149611503module . exports = {
1149711504 WebGL2FunctionNode
1149811505} ;
11499- } , { "../web-gl/function-node" :37 } ] , 73 :[ function ( require , module , exports ) {
11506+ } , { "../../utils" : 113 , "../ web-gl/function-node" :37 } ] , 73 :[ function ( require , module , exports ) {
1150011507const { WebGL2KernelValueBoolean } = require ( './kernel-value/boolean' ) ;
1150111508const { WebGL2KernelValueFloat } = require ( './kernel-value/float' ) ;
1150211509const { WebGL2KernelValueInteger } = require ( './kernel-value/integer' ) ;
@@ -14539,8 +14546,23 @@ const utils = {
1453914546 throw new Error ( 'Unrecognized function type. Please use `() => yourFunctionVariableHere` or function() { return yourFunctionVariableHere; }' ) ;
1454014547 }
1454114548 } ,
14549+ sanitizeName : function ( name ) {
14550+ if ( dollarSign . test ( name ) ) {
14551+ name = name . replace ( dollarSign , 'S_S' ) ;
14552+ }
14553+ if ( doubleUnderscore . test ( name ) ) {
14554+ name = name . replace ( doubleUnderscore , 'U_U' ) ;
14555+ } else if ( singleUnderscore . test ( name ) ) {
14556+ name = name . replace ( singleUnderscore , 'u_u' ) ;
14557+ }
14558+ return name ;
14559+ }
1454214560} ;
1454314561
14562+ const dollarSign = / \$ / ;
14563+ const doubleUnderscore = / _ _ / ;
14564+ const singleUnderscore = / _ / ;
14565+
1454414566const _systemEndianness = utils . getSystemEndianness ( ) ;
1454514567
1454614568module . exports = {
0 commit comments