602 if (first_type == NULL || second_type == NULL) {return false;} |
602 if (first_type == NULL || second_type == NULL) {return false;} |
603 return (NULL != common_type__(first_type, second_type)); |
603 return (NULL != common_type__(first_type, second_type)); |
604 } |
604 } |
605 |
605 |
606 |
606 |
607 #if 0 |
|
608 #define is_num_type is_ANY_NUM_compatible |
|
609 #define is_integer_type is_ANY_INT_compatible |
|
610 #define is_real_type is_ANY_REAL_compatible |
|
611 #define is_binary_type is_ANY_BIT_compatible |
|
612 /* actually the ROR, ROL, SHL, and SHR function also accept boolean type! */ |
|
613 #define is_nbinary_type is_ANY_BIT_compatible |
|
614 #define compute_standard_function_default visit_expression_type_c::compute_standard_function_default |
|
615 #define compute_standard_function_il visit_expression_type_c::compute_standard_function_il |
|
616 #define search_expression_type_c visit_expression_type_c |
|
617 #define search(x) search_f(x) |
|
618 #define next() next_nf() |
|
619 // #define search_constant_type_c::constant_int_type_name search_expression_type_c::integer |
|
620 #define constant_int_type_name integer |
|
621 #define is_same_type is_compatible_type |
|
622 #include "../absyntax_utils/search_type_code.c" |
|
623 #undef is_same_type |
|
624 #undef constant_int_type_name |
|
625 // #undef search_constant_type_c::constant_int_type_name |
|
626 #undef next |
|
627 #undef search |
|
628 #undef compute_standard_function_default |
|
629 #undef compute_standard_function_il |
|
630 #undef search_expression_type_c |
|
631 #undef is_real_type |
|
632 #undef is_binary_type |
|
633 #undef is_nbinary_type |
|
634 #undef is_integer_type |
|
635 #undef is_num_type |
|
636 #endif |
|
637 |
|
638 |
|
639 |
|
640 |
607 |
641 |
608 |
642 /* A helper function... */ |
609 /* A helper function... */ |
643 /* |
610 /* |
644 symbol_c *visit_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type, |
611 symbol_c *visit_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type, |
670 if (error) |
637 if (error) |
671 return NULL; |
638 return NULL; |
672 else |
639 else |
673 return common_type(left_type, right_type); |
640 return common_type(left_type, right_type); |
674 } |
641 } |
675 |
|
676 |
|
677 # if 0 |
|
678 /* A helper function... */ |
|
679 symbol_c *visit_expression_type_c::compute_numeric_expression(symbol_c *left_type, symbol_c *right_type, |
|
680 is_data_type_t is_data_type) { |
|
681 bool error = false; |
|
682 |
|
683 if (!(this->*is_data_type)(left_type)) { |
|
684 STAGE3_ERROR(left_type, right_type, "Invalid data type of left operand."); |
|
685 error = true; |
|
686 } |
|
687 if (!(this->*is_data_type)(right_type)) { |
|
688 STAGE3_ERROR(left_type, right_type, "Invalid data type of right operand."); |
|
689 error = true; |
|
690 } |
|
691 if (!is_compatible_type(left_type, right_type)) { |
|
692 STAGE3_ERROR(left_type, right_type, "Type mismatch between operands."); |
|
693 error = true; |
|
694 } |
|
695 |
|
696 /* |
|
697 if (is_literal_integer_type(left_type) || is_literal_real_type(left_type)) { |
|
698 return right_type; |
|
699 } else { |
|
700 return left_type; |
|
701 } |
|
702 */ |
|
703 |
|
704 if (error) |
|
705 return NULL; |
|
706 else |
|
707 return common_type(left_type, right_type); |
|
708 |
|
709 /* humour the compiler... */ |
|
710 /* |
|
711 return NULL; |
|
712 */ |
|
713 } |
|
714 #endif |
|
715 |
|
716 |
642 |
717 |
643 |
718 |
644 |
719 |
645 |
720 /* A helper function... */ |
646 /* A helper function... */ |