stage4/generate_c/generate_c_il.cc
changeset 345 894c0e6d951c
parent 344 8f71c46a0a55
child 355 30db860bd3bd
equal deleted inserted replaced
344:8f71c46a0a55 345:894c0e6d951c
  1660   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1660   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1661       search_expression_type->is_time_type(this->current_operand_type)) {
  1661       search_expression_type->is_time_type(this->current_operand_type)) {
  1662     XXX_function("__TIME_ADD", &(this->default_variable_name), this->current_operand);
  1662     XXX_function("__TIME_ADD", &(this->default_variable_name), this->current_operand);
  1663     /* the data type resulting from this operation... */
  1663     /* the data type resulting from this operation... */
  1664     this->default_variable_name.current_type = this->current_operand_type;
  1664     this->default_variable_name.current_type = this->current_operand_type;
  1665     return NULL;
  1665   }
  1666   }
  1666   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1667   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1668       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1667       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1669 	NUM_operator_result_type();
  1668 	NUM_operator_result_type();
  1670 	XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
  1669 	XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
  1671     /* the data type resulting from this operation... */
  1670     /* the data type resulting from this operation... */
  1672     this->default_variable_name.current_type = this->current_operand_type;
  1671     this->default_variable_name.current_type = this->current_operand_type;
  1673     return NULL;
  1672   }
  1674   }
  1673   else {ERROR;}
  1675   ERROR;
       
  1676   return NULL;
  1674   return NULL;
  1677 }
  1675 }
  1678 
  1676 
  1679 void *visit(SUB_operator_c *symbol)	{
  1677 void *visit(SUB_operator_c *symbol)	{
  1680   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1678   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1681       search_expression_type->is_time_type(this->current_operand_type)) {
  1679       search_expression_type->is_time_type(this->current_operand_type)) {
  1682     XXX_function("__TIME_SUB", &(this->default_variable_name), this->current_operand);
  1680     XXX_function("__TIME_SUB", &(this->default_variable_name), this->current_operand);
  1683     /* the data type resulting from this operation... */
  1681     /* the data type resulting from this operation... */
  1684     this->default_variable_name.current_type = this->current_operand_type;
  1682     this->default_variable_name.current_type = this->current_operand_type;
  1685     return NULL;
  1683   }
  1686   }
  1684   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1687   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1688       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1685       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1689 	NUM_operator_result_type();
  1686 	NUM_operator_result_type();
  1690 	XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
  1687 	XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
  1691     /* the data type resulting from this operation... */
  1688     /* the data type resulting from this operation... */
  1692     this->default_variable_name.current_type = this->current_operand_type;
  1689     this->default_variable_name.current_type = this->current_operand_type;
  1693     return NULL;
  1690   }
  1694   }
  1691   else {ERROR;}
  1695   ERROR;
       
  1696   return NULL;
  1692   return NULL;
  1697 }
  1693 }
  1698 
  1694 
  1699 void *visit(MUL_operator_c *symbol)	{
  1695 void *visit(MUL_operator_c *symbol)	{
  1700   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1696   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1701       search_expression_type->is_integer_type(this->current_operand_type)) {
  1697       search_expression_type->is_integer_type(this->current_operand_type)) {
  1702     XXX_function("__TIME_MUL", &(this->default_variable_name), this->current_operand);
  1698     XXX_function("__TIME_MUL", &(this->default_variable_name), this->current_operand);
  1703     /* the data type resulting from this operation... */
  1699     /* the data type resulting from this operation is unchanged! */
  1704     return NULL;
  1700   }
  1705   }
  1701   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1706   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1707       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1702       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1708 	NUM_operator_result_type();
  1703 	NUM_operator_result_type();
  1709     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1704     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1710     /* the data type resulting from this operation... */
  1705     /* the data type resulting from this operation... */
  1711     this->default_variable_name.current_type = this->current_operand_type;
  1706     this->default_variable_name.current_type = this->current_operand_type;
  1712     return NULL;
  1707   }
  1713   }
  1708   else {ERROR;}
  1714   ERROR;
       
  1715   return NULL;
  1709   return NULL;
  1716 }
  1710 }
  1717 
  1711 
  1718 void *visit(DIV_operator_c *symbol)	{
  1712 void *visit(DIV_operator_c *symbol)	{
  1719   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1713   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1720       search_expression_type->is_integer_type(this->current_operand_type)) {
  1714       search_expression_type->is_integer_type(this->current_operand_type)) {
  1721     XXX_function("__TIME_DIV", &(this->default_variable_name), this->current_operand);
  1715     XXX_function("__TIME_DIV", &(this->default_variable_name), this->current_operand);
  1722     /* the data type resulting from this operation... */
  1716     /* the data type resulting from this operation is unchanged! */
  1723     return NULL;
  1717   }
  1724   }
  1718   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1725   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1726       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1719       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1727 	NUM_operator_result_type();
  1720 	NUM_operator_result_type();
  1728 	XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
  1721 	XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
  1729     /* the data type resulting from this operation... */
  1722     /* the data type resulting from this operation... */
  1730     this->default_variable_name.current_type = this->current_operand_type;
  1723     this->default_variable_name.current_type = this->current_operand_type;
  1731   }
  1724     return NULL;
  1732   ERROR;
  1725   }
       
  1726   else {ERROR;}
  1733   return NULL;
  1727   return NULL;
  1734 }
  1728 }
  1735 
  1729 
  1736 void *visit(MOD_operator_c *symbol)	{
  1730 void *visit(MOD_operator_c *symbol)	{
  1737   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1731   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1739 	NUM_operator_result_type();
  1733 	NUM_operator_result_type();
  1740 	XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1734 	XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1741     /* the data type resulting from this operation... */
  1735     /* the data type resulting from this operation... */
  1742     this->default_variable_name.current_type = this->current_operand_type;
  1736     this->default_variable_name.current_type = this->current_operand_type;
  1743   }
  1737   }
  1744   ERROR;
  1738   else {ERROR;}
  1745   return NULL;
  1739   return NULL;
  1746 }
  1740 }
  1747 
  1741 
  1748 void *visit(GT_operator_c *symbol)	{
  1742 void *visit(GT_operator_c *symbol)	{
  1749   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1743   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1750       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1744       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1751     return CMP_operator(this->current_operand, "__gt_");
  1745     CMP_operator(this->current_operand, "__gt_");
  1752   ERROR;
  1746   }
       
  1747   else {ERROR;}
  1753   return NULL;
  1748   return NULL;
  1754 }
  1749 }
  1755 
  1750 
  1756 void *visit(GE_operator_c *symbol)	{
  1751 void *visit(GE_operator_c *symbol)	{
  1757   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1752   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1758       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1753       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1759     return CMP_operator(this->current_operand, "__ge_");
  1754     CMP_operator(this->current_operand, "__ge_");
  1760   ERROR;
  1755   }
       
  1756   else {ERROR;}
  1761   return NULL;
  1757   return NULL;
  1762 }
  1758 }
  1763 
  1759 
  1764 void *visit(EQ_operator_c *symbol)	{
  1760 void *visit(EQ_operator_c *symbol)	{
  1765   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1761   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1766     return CMP_operator(this->current_operand, "__eq_");
  1762     CMP_operator(this->current_operand, "__eq_");
  1767   ERROR;
  1763   }
       
  1764   else {ERROR;}
  1768   return NULL;
  1765   return NULL;
  1769 }
  1766 }
  1770 
  1767 
  1771 void *visit(LT_operator_c *symbol)	{
  1768 void *visit(LT_operator_c *symbol)	{
  1772   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1769   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1773       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1770       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1774     return CMP_operator(this->current_operand, "__lt_");
  1771     CMP_operator(this->current_operand, "__lt_");
  1775   ERROR;
  1772   }
       
  1773   else {ERROR;}
  1776   return NULL;
  1774   return NULL;
  1777 }
  1775 }
  1778 
  1776 
  1779 void *visit(LE_operator_c *symbol)	{
  1777 void *visit(LE_operator_c *symbol)	{
  1780   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1778   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1781       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1779       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1782     return CMP_operator(this->current_operand, "__le_");
  1780     CMP_operator(this->current_operand, "__le_");
  1783   ERROR;
  1781   }
       
  1782   else {ERROR;}
  1784   return NULL;
  1783   return NULL;
  1785 }
  1784 }
  1786 
  1785 
  1787 void *visit(NE_operator_c *symbol)	{
  1786 void *visit(NE_operator_c *symbol)	{
  1788   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1787   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1789     return CMP_operator(this->current_operand, "__ne_");
  1788     CMP_operator(this->current_operand, "__ne_");
  1790   ERROR;
  1789   }
       
  1790   else {ERROR;}
  1791   return NULL;
  1791   return NULL;
  1792 }
  1792 }
  1793 
  1793 
  1794 
  1794 
  1795 //SYM_REF0(CAL_operator_c)
  1795 //SYM_REF0(CAL_operator_c)