469 s4o.print(" && "); |
449 s4o.print(" && "); |
470 symbol->r_exp->accept(*this); |
450 symbol->r_exp->accept(*this); |
471 s4o.print(")"); |
451 s4o.print(")"); |
472 return NULL; |
452 return NULL; |
473 } |
453 } |
474 if (search_expression_type->is_binary_type(left_type)) |
454 if (get_datatype_info_c::is_ANY_nBIT_compatible(symbol->datatype)) |
475 return print_binary_expression(symbol->l_exp, symbol->r_exp, " ^ "); |
455 return print_binary_expression(symbol->l_exp, symbol->r_exp, " ^ "); |
476 ERROR; |
456 ERROR; |
477 return NULL; |
457 return NULL; |
478 } |
458 } |
479 |
459 |
480 void *visit(and_expression_c *symbol) { |
460 void *visit(and_expression_c *symbol) { |
481 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
461 if (get_datatype_info_c::is_BOOL_compatible(symbol->datatype)) |
482 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
483 if (!search_expression_type->is_same_type(left_type, right_type)) |
|
484 ERROR; |
|
485 if (search_expression_type->is_bool_type(left_type)) |
|
486 return print_binary_expression(symbol->l_exp, symbol->r_exp, " && "); |
462 return print_binary_expression(symbol->l_exp, symbol->r_exp, " && "); |
487 if (search_expression_type->is_binary_type(left_type)) |
463 if (get_datatype_info_c::is_ANY_nBIT_compatible(symbol->datatype)) |
488 return print_binary_expression(symbol->l_exp, symbol->r_exp, " & "); |
464 return print_binary_expression(symbol->l_exp, symbol->r_exp, " & "); |
489 ERROR; |
465 ERROR; |
490 return NULL; |
466 return NULL; |
491 } |
467 } |
492 |
468 |
493 void *visit(equ_expression_c *symbol) { |
469 void *visit(equ_expression_c *symbol) { |
494 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
470 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
495 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
471 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
496 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
472 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
497 if (search_expression_type->is_time_type(left_type) || |
473 return print_compare_function("EQ_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
498 search_expression_type->is_string_type(left_type)) |
|
499 return print_compare_function("EQ_", left_type, symbol->l_exp, symbol->r_exp); |
|
500 return print_binary_expression(symbol->l_exp, symbol->r_exp, " == "); |
474 return print_binary_expression(symbol->l_exp, symbol->r_exp, " == "); |
501 } |
475 } |
502 |
476 |
503 void *visit(notequ_expression_c *symbol) { |
477 void *visit(notequ_expression_c *symbol) { |
504 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
478 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
505 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
479 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
506 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
480 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
507 if (search_expression_type->is_time_type(left_type) || |
481 return print_compare_function("NE_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
508 search_expression_type->is_string_type(left_type)) |
|
509 return print_compare_function("NE_", left_type, symbol->l_exp, symbol->r_exp); |
|
510 return print_binary_expression(symbol->l_exp, symbol->r_exp, " != "); |
482 return print_binary_expression(symbol->l_exp, symbol->r_exp, " != "); |
511 } |
483 } |
512 |
484 |
513 void *visit(lt_expression_c *symbol) { |
485 void *visit(lt_expression_c *symbol) { |
514 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
486 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
515 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
487 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
516 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
488 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
517 if (search_expression_type->is_time_type(left_type) || |
489 return print_compare_function("LT_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
518 search_expression_type->is_string_type(left_type)) |
|
519 return print_compare_function("LT_", left_type, symbol->l_exp, symbol->r_exp); |
|
520 return print_binary_expression(symbol->l_exp, symbol->r_exp, " < "); |
490 return print_binary_expression(symbol->l_exp, symbol->r_exp, " < "); |
521 } |
491 } |
522 |
492 |
523 void *visit(gt_expression_c *symbol) { |
493 void *visit(gt_expression_c *symbol) { |
524 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
494 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
525 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
495 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
526 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
496 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
527 if (search_expression_type->is_time_type(left_type) || |
497 return print_compare_function("GT_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
528 search_expression_type->is_string_type(left_type)) |
|
529 return print_compare_function("GT_", left_type, symbol->l_exp, symbol->r_exp); |
|
530 return print_binary_expression(symbol->l_exp, symbol->r_exp, " > "); |
498 return print_binary_expression(symbol->l_exp, symbol->r_exp, " > "); |
531 } |
499 } |
532 |
500 |
533 void *visit(le_expression_c *symbol) { |
501 void *visit(le_expression_c *symbol) { |
534 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
502 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
535 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
503 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
536 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
504 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
537 if (search_expression_type->is_time_type(left_type) || |
505 return print_compare_function("LE_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
538 search_expression_type->is_string_type(left_type)) |
|
539 return print_compare_function("LE_", left_type, symbol->l_exp, symbol->r_exp); |
|
540 return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= "); |
506 return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= "); |
541 } |
507 } |
542 |
508 |
543 void *visit(ge_expression_c *symbol) { |
509 void *visit(ge_expression_c *symbol) { |
544 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
510 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
545 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
511 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype) || |
546 // if (!search_expression_type->is_same_type(left_type, right_type)) ERROR; // This check is no longer needed! |
512 get_datatype_info_c::is_ANY_STRING_compatible(symbol->datatype)) |
547 if (search_expression_type->is_time_type(left_type) || |
513 return print_compare_function("GE_", symbol->datatype, symbol->l_exp, symbol->r_exp); |
548 search_expression_type->is_string_type(left_type)) |
|
549 return print_compare_function("GE_", left_type, symbol->l_exp, symbol->r_exp); |
|
550 return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= "); |
514 return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= "); |
551 } |
515 } |
552 |
516 |
553 void *visit(add_expression_c *symbol) { |
517 void *visit(add_expression_c *symbol) { |
554 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
518 /* |
555 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
519 symbol_c *left_type = symbol->l_exp->datatype; |
556 if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
520 symbol_c *right_type = symbol->r_exp->datatype; |
557 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
521 if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
558 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))) |
522 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
523 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))) |
559 return print_binary_function("__time_add", symbol->l_exp, symbol->r_exp); |
524 return print_binary_function("__time_add", symbol->l_exp, symbol->r_exp); |
560 if (!search_expression_type->is_same_type(left_type, right_type)) |
525 */ |
561 ERROR; |
526 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
562 if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
527 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
563 return print_binary_expression(symbol->l_exp, symbol->r_exp, " + "); |
528 return print_binary_function("__time_add", symbol->l_exp, symbol->r_exp); |
564 ERROR; |
529 return print_binary_expression(symbol->l_exp, symbol->r_exp, " + "); |
565 return NULL; |
|
566 } |
530 } |
567 |
531 |
568 void *visit(sub_expression_c *symbol) { |
532 void *visit(sub_expression_c *symbol) { |
569 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
533 /* |
570 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
534 symbol_c *left_type = symbol->l_exp->datatype; |
|
535 symbol_c *right_type = symbol->r_exp->datatype; |
571 if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
536 if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
572 (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) || |
537 (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) || |
573 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
538 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
574 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) || |
539 (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) || |
575 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
540 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
576 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c))) |
541 (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c))) |
577 return print_binary_function("__time_sub", symbol->l_exp, symbol->r_exp); |
542 return print_binary_function("__time_sub", symbol->l_exp, symbol->r_exp); |
578 if (!search_expression_type->is_same_type(left_type, right_type)) |
543 */ |
579 ERROR; |
544 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype) || |
580 if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
545 get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
581 return print_binary_expression(symbol->l_exp, symbol->r_exp, " - "); |
546 return print_binary_function("__time_sub", symbol->l_exp, symbol->r_exp); |
582 ERROR; |
547 return print_binary_expression(symbol->l_exp, symbol->r_exp, " - "); |
583 return NULL; |
|
584 } |
548 } |
585 |
549 |
586 void *visit(mul_expression_c *symbol) { |
550 void *visit(mul_expression_c *symbol) { |
587 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
551 /* |
588 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
552 symbol_c *left_type = symbol->l_exp->datatype; |
589 if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) || |
553 symbol_c *right_type = symbol->r_exp->datatype; |
590 (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type))) |
554 if ((typeid(*left_type) == typeid(time_type_name_c) && get_datatype_info_c::is_ANY_INT_compatible (right_type)) || |
|
555 (typeid(*left_type) == typeid(time_type_name_c) && get_datatype_info_c::is_ANY_REAL_compatible(right_type))) |
591 return print_binary_function("__time_mul", symbol->l_exp, symbol->r_exp); |
556 return print_binary_function("__time_mul", symbol->l_exp, symbol->r_exp); |
592 if (!search_expression_type->is_same_type(left_type, right_type)) |
557 */ |
593 ERROR; |
558 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype)) |
594 if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
559 return print_binary_function("__time_mul", symbol->l_exp, symbol->r_exp); |
595 return print_binary_expression(symbol->l_exp, symbol->r_exp, " * "); |
560 return print_binary_expression(symbol->l_exp, symbol->r_exp, " * "); |
596 ERROR; |
|
597 return NULL; |
|
598 } |
561 } |
599 |
562 |
600 void *visit(div_expression_c *symbol) { |
563 void *visit(div_expression_c *symbol) { |
601 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
564 /* |
602 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
565 symbol_c *left_type = symbol->l_exp->datatype; |
603 if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) || |
566 symbol_c *right_type = symbol->r_exp->datatype; |
604 (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type))) |
567 if ((typeid(*left_type) == typeid(time_type_name_c) && get_datatype_info_c::is_ANY_INT_compatible (right_type)) || |
|
568 (typeid(*left_type) == typeid(time_type_name_c) && get_datatype_info_c::is_ANY_REAL_compatible(right_type))) |
605 return print_binary_function("__time_div", symbol->l_exp, symbol->r_exp); |
569 return print_binary_function("__time_div", symbol->l_exp, symbol->r_exp); |
606 if (!search_expression_type->is_same_type(left_type, right_type)) |
570 */ |
607 ERROR; |
571 if (get_datatype_info_c::is_TIME_compatible (symbol->datatype)) |
608 if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
572 return print_binary_function("__time_div", symbol->l_exp, symbol->r_exp); |
609 return print_binary_expression(symbol->l_exp, symbol->r_exp, " / "); |
573 return print_binary_expression(symbol->l_exp, symbol->r_exp, " / "); |
610 ERROR; |
|
611 return NULL; |
|
612 } |
574 } |
613 |
575 |
614 void *visit(mod_expression_c *symbol) { |
576 void *visit(mod_expression_c *symbol) { |
615 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
577 s4o.print("(("); |
616 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
578 symbol->r_exp->accept(*this); |
617 if (!search_expression_type->is_same_type(left_type, right_type)) |
579 s4o.print(" == 0)?0:"); |
618 ERROR; |
580 print_binary_expression(symbol->l_exp, symbol->r_exp, " % "); |
619 if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) { |
581 s4o.print(")"); |
620 s4o.print("(("); |
|
621 symbol->r_exp->accept(*this); |
|
622 s4o.print(" == 0)?0:"); |
|
623 print_binary_expression(symbol->l_exp, symbol->r_exp, " % "); |
|
624 s4o.print(")"); |
|
625 return NULL; |
|
626 } |
|
627 ERROR; |
|
628 return NULL; |
582 return NULL; |
629 } |
583 } |
630 |
584 |
631 void *visit(power_expression_c *symbol) { |
585 void *visit(power_expression_c *symbol) { |
632 symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
586 s4o.print("EXPT__LREAL__LREAL__LREAL((BOOL)__BOOL_LITERAL(TRUE),\n"); |
633 symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
587 s4o.indent_right(); |
634 if (search_expression_type->is_real_type(left_type) && search_expression_type->is_num_type(right_type)) { |
588 s4o.print(s4o.indent_spaces + "NULL,\n"); |
635 s4o.print("EXPT__LREAL__LREAL__LREAL((BOOL)__BOOL_LITERAL(TRUE),\n"); |
589 s4o.print(s4o.indent_spaces + "(LREAL)("); |
636 s4o.indent_right(); |
590 symbol->l_exp->accept(*this); |
637 s4o.print(s4o.indent_spaces + "NULL,\n"); |
591 s4o.print("),\n"); |
638 s4o.print(s4o.indent_spaces + "(LREAL)("); |
592 s4o.print(s4o.indent_spaces + "(LREAL)("); |
639 symbol->l_exp->accept(*this); |
593 symbol->r_exp->accept(*this); |
640 s4o.print("),\n"); |
594 s4o.print("))"); |
641 s4o.print(s4o.indent_spaces + "(LREAL)("); |
|
642 symbol->r_exp->accept(*this); |
|
643 s4o.print("))"); |
|
644 return NULL; |
|
645 } |
|
646 ERROR; |
|
647 return NULL; |
595 return NULL; |
648 } |
596 } |
649 |
597 |
650 void *visit(neg_expression_c *symbol) { |
598 void *visit(neg_expression_c *symbol) { |
651 return print_unary_expression(symbol->exp, " -"); |
599 return print_unary_expression(symbol->exp, " -"); |
652 } |
600 } |
653 |
601 |
654 void *visit(not_expression_c *symbol) { |
602 void *visit(not_expression_c *symbol) { |
655 symbol_c *exp_type = search_expression_type->get_type(symbol->exp); |
603 return print_unary_expression(symbol->exp, get_datatype_info_c::is_BOOL_compatible(symbol->datatype)?"!":"~"); |
656 if (search_expression_type->is_binary_type(exp_type)) |
|
657 return print_unary_expression(symbol->exp, search_expression_type->is_bool_type(exp_type)?"!":"~"); |
|
658 ERROR; |
|
659 return NULL; |
|
660 } |
604 } |
661 |
605 |
662 void *visit(function_invocation_c *symbol) { |
606 void *visit(function_invocation_c *symbol) { |
663 symbol_c* function_name = NULL; |
607 symbol_c* function_name = NULL; |
664 DECLARE_PARAM_LIST() |
608 DECLARE_PARAM_LIST() |