5
5
* GPU Accelerated JavaScript
6
6
*
7
7
* @version 2.0.0-rc.14
8
- * @date Thu May 23 2019 16:47:15 GMT-0400 (Eastern Daylight Time)
8
+ * @date Thu May 23 2019 18:11:34 GMT-0400 (Eastern Daylight Time)
9
9
*
10
10
* @license MIT
11
11
* The MIT License
18
18
* GPU Accelerated JavaScript
19
19
*
20
20
* @version 2.0.0-rc.14
21
- * @date Thu May 23 2019 16:47:13 GMT-0400 (Eastern Daylight Time)
21
+ * @date Thu May 23 2019 18:11:32 GMT-0400 (Eastern Daylight Time)
22
22
*
23
23
* @license MIT
24
24
* The MIT License
@@ -1525,6 +1525,7 @@ class CPUKernel extends Kernel {
1525
1525
module . exports = {
1526
1526
CPUKernel
1527
1527
} ;
1528
+
1528
1529
} , { "../../utils" :88 , "../function-builder" :8 , "../kernel" :33 , "./function-node" :5 , "./kernel-string" :6 } ] , 8 :[ function ( require , module , exports ) {
1529
1530
class FunctionBuilder {
1530
1531
static fromKernel ( kernel , FunctionNode , extraNodeOptions ) {
@@ -4594,7 +4595,6 @@ class HeadlessGLKernel extends WebGLKernel {
4594
4595
module . exports = {
4595
4596
HeadlessGLKernel
4596
4597
} ;
4597
-
4598
4598
} , { "../gl/kernel-string" :10 , "../web-gl/kernel" :55 , "gl" :2 } ] , 32 :[ function ( require , module , exports ) {
4599
4599
const { utils } = require ( '../utils' ) ;
4600
4600
@@ -4986,6 +4986,7 @@ class Kernel {
4986
4986
return this . getBitRatio ( value . value ) ;
4987
4987
}
4988
4988
switch ( value . constructor ) {
4989
+ case Uint8ClampedArray :
4989
4990
case Uint8Array :
4990
4991
case Int8Array :
4991
4992
return 1 ;
@@ -5869,76 +5870,65 @@ class WebGLFunctionNode extends FunctionNode {
5869
5870
throw this . astErrorOutput ( 'Unexpected expression' , varDecNode ) ;
5870
5871
}
5871
5872
const result = [ ] ;
5872
- const firstDeclaration = declarations [ 0 ] ;
5873
- const init = firstDeclaration . init ;
5874
- const actualType = this . getType ( init ) ;
5873
+ let lastType = null ;
5875
5874
const inForLoopInit = this . isState ( 'in-for-loop-init' ) ;
5876
- let type = inForLoopInit ? 'Integer' : actualType ;
5877
- if ( type === 'LiteralInteger' ) {
5878
- type = 'Number' ;
5879
- }
5880
- const markupType = typeMap [ type ] ;
5881
- if ( ! markupType ) {
5882
- throw this . astErrorOutput ( `Markup type ${ markupType } not handled` , varDecNode ) ;
5883
- }
5884
- let dependencies = this . getDependencies ( firstDeclaration . init ) ;
5885
- const initResult = [ ] ;
5886
- if ( actualType === 'Integer' && type === 'Integer' && ! inForLoopInit ) {
5887
- this . declarations [ firstDeclaration . id . name ] = Object . freeze ( {
5888
- type : 'Number' ,
5889
- dependencies,
5890
- isSafe : this . isSafeDependencies ( dependencies ) ,
5891
- } ) ;
5892
- initResult . push ( 'float ' ) ;
5893
- initResult . push ( `user_${ firstDeclaration . id . name } =` ) ;
5894
- initResult . push ( 'float(' ) ;
5895
- this . astGeneric ( init , initResult ) ;
5896
- initResult . push ( ')' ) ;
5897
- } else {
5898
- this . declarations [ firstDeclaration . id . name ] = Object . freeze ( {
5899
- type,
5900
- dependencies,
5901
- isSafe : this . isSafeDependencies ( dependencies ) ,
5902
- } ) ;
5903
- initResult . push ( `${ markupType } ` ) ;
5904
- initResult . push ( `user_${ firstDeclaration . id . name } =` ) ;
5905
- if ( actualType === 'Number' && type === 'Integer' ) {
5906
- initResult . push ( 'int(' ) ;
5907
- this . astGeneric ( init , initResult ) ;
5908
- initResult . push ( ')' ) ;
5909
- } else {
5910
- this . astGeneric ( init , initResult ) ;
5911
- }
5912
- }
5913
- result . push ( initResult . join ( '' ) ) ;
5914
-
5915
- let lastType = type ;
5916
- for ( let i = 1 ; i < declarations . length ; i ++ ) {
5875
+ for ( let i = 0 ; i < declarations . length ; i ++ ) {
5917
5876
const declaration = declarations [ i ] ;
5918
- const nextResult = [ ] ;
5919
- if ( ! inForLoopInit ) {
5920
- let possibleNewType = this . getType ( declaration . init ) ;
5921
- if ( possibleNewType === 'LiteralInteger' ) {
5922
- possibleNewType = 'Number' ;
5923
- }
5924
- if ( possibleNewType !== lastType ) {
5925
- nextResult . push ( ';' ) ;
5926
- nextResult . push ( typeMap [ possibleNewType ] , ' ' ) ;
5927
- lastType = possibleNewType ;
5877
+ const init = declaration . init ;
5878
+ const actualType = this . getType ( init ) ;
5879
+ let dependencies = this . getDependencies ( init ) ;
5880
+ let type = inForLoopInit ? 'Integer' : actualType ;
5881
+ if ( type === 'LiteralInteger' ) {
5882
+ type = 'Number' ;
5883
+ }
5884
+ const markupType = typeMap [ type ] ;
5885
+ if ( ! markupType ) {
5886
+ throw this . astErrorOutput ( `Markup type ${ markupType } not handled` , varDecNode ) ;
5887
+ }
5888
+ const declarationResult = [ ] ;
5889
+ if ( actualType === 'Integer' && type === 'Integer' && ! inForLoopInit ) {
5890
+ this . declarations [ declaration . id . name ] = Object . freeze ( {
5891
+ type : 'Number' ,
5892
+ dependencies,
5893
+ isSafe : this . isSafeDependencies ( dependencies ) ,
5894
+ } ) ;
5895
+ if ( i === 0 || lastType === null ) {
5896
+ declarationResult . push ( 'float ' ) ;
5897
+ } else if ( actualType !== lastType ) {
5898
+ throw new Error ( 'Unhandled declaration' ) ;
5928
5899
} else {
5929
- nextResult . push ( ',' ) ;
5900
+ declarationResult . push ( ',' ) ;
5930
5901
}
5902
+ lastType = type ;
5903
+ declarationResult . push ( `user_${ declaration . id . name } =` ) ;
5904
+ declarationResult . push ( 'float(' ) ;
5905
+ this . astGeneric ( init , declarationResult ) ;
5906
+ declarationResult . push ( ')' ) ;
5931
5907
} else {
5932
- nextResult . push ( ',' ) ;
5908
+ this . declarations [ declaration . id . name ] = Object . freeze ( {
5909
+ type,
5910
+ dependencies,
5911
+ isSafe : this . isSafeDependencies ( dependencies ) ,
5912
+ } ) ;
5913
+ if ( i === 0 || lastType === null ) {
5914
+ declarationResult . push ( `${ markupType } ` ) ;
5915
+ } else if ( actualType !== lastType ) {
5916
+ result . push ( ';' ) ;
5917
+ declarationResult . push ( `${ markupType } ` ) ;
5918
+ } else {
5919
+ declarationResult . push ( ',' ) ;
5920
+ }
5921
+ lastType = type ;
5922
+ declarationResult . push ( `user_${ declaration . id . name } =` ) ;
5923
+ if ( actualType === 'Number' && type === 'Integer' ) {
5924
+ declarationResult . push ( 'int(' ) ;
5925
+ this . astGeneric ( init , declarationResult ) ;
5926
+ declarationResult . push ( ')' ) ;
5927
+ } else {
5928
+ this . astGeneric ( init , declarationResult ) ;
5929
+ }
5933
5930
}
5934
- dependencies = this . getDependencies ( declaration ) ;
5935
- this . declarations [ declaration . id . name ] = Object . freeze ( {
5936
- type : lastType ,
5937
- dependencies : dependencies ,
5938
- isSafe : this . isSafeDependencies ( dependencies ) ,
5939
- } ) ;
5940
- this . astGeneric ( declaration , nextResult ) ;
5941
- result . push ( nextResult . join ( '' ) ) ;
5931
+ result . push ( declarationResult . join ( '' ) ) ;
5942
5932
}
5943
5933
5944
5934
retArr . push ( result . join ( '' ) ) ;
@@ -6875,6 +6865,7 @@ class WebGLKernelValue extends KernelValue {
6875
6865
return valuesFlat ;
6876
6866
} else {
6877
6867
switch ( value . constructor ) {
6868
+ case Uint8ClampedArray :
6878
6869
case Uint8Array :
6879
6870
case Int8Array :
6880
6871
case Uint16Array :
@@ -6901,6 +6892,7 @@ class WebGLKernelValue extends KernelValue {
6901
6892
return this . getBitRatio ( value . value ) ;
6902
6893
}
6903
6894
switch ( value . constructor ) {
6895
+ case Uint8ClampedArray :
6904
6896
case Uint8Array :
6905
6897
case Int8Array :
6906
6898
return 1 ;
0 commit comments