@@ -4,6 +4,7 @@ var functionNode_webgl = (function() {
44 var gpu , opt , jsFunctionString ;
55
66 function isIdentifierConstant ( paramName ) {
7+ if ( ! opt . constants ) return false ;
78 return opt . constants . indexOf ( paramName ) != - 1 ;
89 }
910
@@ -384,8 +385,12 @@ var functionNode_webgl = (function() {
384385 retArr . push ( forNode . test . operator ) ;
385386 ast_generic ( forNode . test . right , retArr , funcParam ) ;
386387 retArr . push ( ") {\n" ) ;
387- for ( var i = 0 ; i < forNode . body . body . length ; i ++ ) {
388- ast_generic ( forNode . body . body [ i ] , retArr , funcParam ) ;
388+ if ( forNode . body . type == "BlockStatement" ) {
389+ for ( var i = 0 ; i < forNode . body . body . length ; i ++ ) {
390+ ast_generic ( forNode . body . body [ i ] , retArr , funcParam ) ;
391+ }
392+ } else {
393+ ast_generic ( forNode . body , retArr , funcParam ) ;
389394 }
390395 retArr . push ( "} else {\n" ) ;
391396 retArr . push ( "break;\n" ) ;
@@ -501,11 +506,23 @@ var functionNode_webgl = (function() {
501506 retArr . push ( "if(" ) ;
502507 ast_generic ( ifNode . test , retArr , funcParam ) ;
503508 retArr . push ( ")" ) ;
504- ast_generic ( ifNode . consequent , retArr , funcParam ) ;
509+ if ( ifNode . consequent . type == "BlockStatement" ) {
510+ ast_generic ( ifNode . consequent , retArr , funcParam ) ;
511+ } else {
512+ retArr . push ( " {\n" ) ;
513+ ast_generic ( ifNode . consequent , retArr , funcParam ) ;
514+ retArr . push ( "\n}\n" ) ;
515+ }
505516
506517 if ( ifNode . alternate ) {
507518 retArr . push ( "else " ) ;
508- ast_generic ( ifNode . alternate , retArr , funcParam ) ;
519+ if ( ifNode . alternate . type == "BlockStatement" ) {
520+ ast_generic ( ifNode . alternate , retArr , funcParam ) ;
521+ } else {
522+ retArr . push ( " {\n" ) ;
523+ ast_generic ( ifNode . alternate , retArr , funcParam ) ;
524+ retArr . push ( "\n}\n" ) ;
525+ }
509526 }
510527 return retArr ;
511528
0 commit comments