@@ -147,10 +147,10 @@ export default class Builder {
147
147
prefixedIdentifiers . push ( negatedPredicate ) ;
148
148
}
149
149
150
- this . expandMacro (
151
- path ,
152
- this . _buildLogicalExpressions ( prefixedIdentifiers , callExpression ) ,
153
- ) ;
150
+ // Expand the macro!
151
+ let replacementPath = this . _buildLogicalExpressions ( prefixedIdentifiers , callExpression , this . _debugExpression ( path ) ) ;
152
+ path . replaceWith ( replacementPath ) ;
153
+ path . scope . crawl ( ) ;
154
154
}
155
155
156
156
/**
@@ -208,15 +208,6 @@ export default class Builder {
208
208
} ) ;
209
209
}
210
210
211
- /**
212
- * Performs the actually expansion of macro
213
- */
214
- expandMacro ( exp : CallStatementPath , logicalExp : ( debugIdentifier : t . Expression ) => t . Expression ) {
215
- const flag = this . _debugExpression ( exp ) ;
216
- exp . replaceWith ( this . t . parenthesizedExpression ( logicalExp ( flag ) ) ) ;
217
- exp . scope . crawl ( ) ;
218
- }
219
-
220
211
_debugExpression ( target : NodePath ) {
221
212
if ( typeof this . isDebug === 'boolean' ) {
222
213
return this . t . booleanLiteral ( this . isDebug ) ;
@@ -244,26 +235,25 @@ export default class Builder {
244
235
245
236
_buildLogicalExpressions (
246
237
identifiers : t . Expression [ ] ,
247
- callExpression : t . Expression
248
- ) : ( debugIdentifier : t . Expression ) => t . Expression {
238
+ callExpression : t . Expression ,
239
+ debugIdentifier : t . Expression
240
+ ) : t . Expression {
249
241
let t = this . t ;
250
242
251
- return ( debugIdentifier : t . Expression ) => {
252
- identifiers . unshift ( debugIdentifier ) ;
253
- identifiers . push ( callExpression ) ;
254
- let logicalExpressions ;
243
+ identifiers . unshift ( debugIdentifier ) ;
244
+ identifiers . push ( callExpression ) ;
245
+ let logicalExpressions ;
255
246
256
- for ( let i = 0 ; i < identifiers . length ; i ++ ) {
257
- let left = identifiers [ i ] ;
258
- let right = identifiers [ i + 1 ] ;
259
- if ( ! logicalExpressions ) {
260
- logicalExpressions = t . logicalExpression ( '&&' , left , right ) ;
261
- } else if ( right ) {
262
- logicalExpressions = t . logicalExpression ( '&&' , logicalExpressions , right ) ;
263
- }
247
+ for ( let i = 0 ; i < identifiers . length ; i ++ ) {
248
+ let left = identifiers [ i ] ;
249
+ let right = identifiers [ i + 1 ] ;
250
+ if ( ! logicalExpressions ) {
251
+ logicalExpressions = t . logicalExpression ( '&&' , left , right ) ;
252
+ } else if ( right ) {
253
+ logicalExpressions = t . logicalExpression ( '&&' , logicalExpressions , right ) ;
264
254
}
255
+ }
265
256
266
- return logicalExpressions ! ;
267
- } ;
257
+ return t . parenthesizedExpression ( logicalExpressions ! ) ;
268
258
}
269
259
}
0 commit comments