File tree Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -246,25 +246,16 @@ function arrFun(node) {
246
246
247
247
function calExp ( node ) {
248
248
// console.log('calExp()', node.name, node);
249
- const { arguments : args , callee : { name } } = node ;
249
+ const { arguments : args , callee : { name, object } } = node ;
250
+ if ( object && object . name === 'console' ) {
251
+ return '/* console statement */' ;
252
+ }
250
253
if ( name === 'discard' ) {
251
254
return 'discard' ;
252
255
}
253
256
if ( name === 'calc' ) {
254
257
return `(${ handleNode ( args [ 0 ] . body ) } )` ;
255
258
}
256
- if ( name === 'debug' ) {
257
- return '/* debug statement */' ;
258
- }
259
- if ( name === 'log' ) {
260
- return '/* log statement */' ;
261
- }
262
- if ( name === 'warn' ) {
263
- return '/* warn statement */' ;
264
- }
265
- if ( name === 'error' ) {
266
- return '/* error statement */' ;
267
- }
268
259
return `${ name } (${ args . map ( handleNode ) . join ( ', ' ) } )` ;
269
260
}
270
261
Original file line number Diff line number Diff line change @@ -324,22 +324,24 @@ float action(vec2 one, vec2 two) {
324
324
it ( 'works fine even with debug statements' , ( ) => {
325
325
326
326
let warnRes ;
327
- const warn = ( arg ) => warnRes = arg ;
327
+ const console = {
328
+ warn : ( arg ) => warnRes = arg
329
+ } ;
328
330
329
331
const shader = ( { vec4, vec2 } ) => {
330
332
let bar = vec4 ( ( x = vec2 ( ) ) => {
331
- warn ( `warning: ${ x . x . toPrecision ( 8 ) } ` ) ;
333
+ console . warn ( `warning: ${ x . x . toPrecision ( 8 ) } ` ) ;
332
334
return vec4 ( x , 1.0 , 1.0 ) ;
333
335
} ) ;
334
336
return { bar } ;
335
337
} ;
336
- const { js, glsl } = buildGLSL ( shader , { js : true } ) ;
338
+ const { js, glsl } = buildGLSL ( shader , { js : true , ast : true } ) ;
337
339
338
340
const { bar } = js ;
339
341
340
342
const expected = `
341
343
vec4 bar(vec2 x) {
342
- \t/* warn statement */
344
+ \t/* console statement */
343
345
\treturn vec4(x, 1.0, 1.0);
344
346
}
345
347
` ;
You can’t perform that action at this time.
0 commit comments