File tree Expand file tree Collapse file tree 2 files changed +13
-23
lines changed
csharp/ToolGood.Algorithm2/Internals
java/toolgood.algorithm/src/main/java/toolgood/algorithm/internals Expand file tree Collapse file tree 2 files changed +13
-23
lines changed Original file line number Diff line number Diff line change @@ -310,20 +310,19 @@ public Operand VisitAndOr_fun(mathParser.AndOr_funContext context)
310310 #region flow
311311 public Operand VisitIF_fun ( mathParser . IF_funContext context )
312312 {
313- var args = new List < Operand > ( ) ;
314- foreach ( var item in context . expr ( ) ) { var aa = this . Visit ( item ) ; if ( aa . IsError ) { return aa ; } args . Add ( aa ) ; }
313+ var exprs = context . expr ( ) ;
315314
316- var b = args [ 0 ] . ToBoolean ( "Function IF first parameter is error!" ) ;
315+ var b = Visit ( exprs [ 0 ] ) . ToBoolean ( "Function IF first parameter is error!" ) ;
317316 if ( b . IsError ) { return b ; }
318317
319318 if ( b . BooleanValue ) {
320- if ( args . Count > 1 ) {
321- return args [ 1 ] ;
319+ if ( exprs . Length > 1 ) {
320+ return Visit ( exprs [ 1 ] ) ;
322321 }
323322 return Operand . True ;
324323 }
325- if ( args . Count == 3 ) {
326- return args [ 2 ] ;
324+ if ( exprs . Length == 3 ) {
325+ return Visit ( exprs [ 2 ] ) ;
327326 }
328327 return Operand . False ;
329328 }
Original file line number Diff line number Diff line change @@ -402,28 +402,19 @@ public Operand visitAndOr_fun(final AndOr_funContext context) {
402402 }
403403
404404 public Operand visitIF_fun (final IF_funContext context ) {
405- final List <Operand > args = new ArrayList <Operand >();
406- for (final ExprContext item : context .expr ()) {
407- final Operand aa = visit (item );
408- if (aa .IsError ()) {
409- return aa ;
410- }
411- args .add (aa );
412- }
405+ List <ExprContext > exprs = context .expr ();
413406
414- final Operand b = args .get (0 ).ToBoolean ("Function IF first parameter is error!" );
415- if (b .IsError ()) {
416- return b ;
417- }
407+ Operand b = visit (exprs .get (0 )).ToBoolean ("Function IF first parameter is error!" );
408+ if (b .IsError ()) { return b ; }
418409
419410 if (b .BooleanValue ()) {
420- if (args .size () > 1 ) {
421- return args .get (1 );
411+ if (exprs .size () > 1 ) {
412+ return visit ( exprs .get (1 ) );
422413 }
423414 return Operand .True ;
424415 }
425- if (args .size () == 3 ) {
426- return args .get (2 );
416+ if (exprs .size () == 3 ) {
417+ return visit ( exprs .get (2 ) );
427418 }
428419 return Operand .False ;
429420 }
You can’t perform that action at this time.
0 commit comments