stage4/generate_c/generate_c_il.cc
changeset 355 30db860bd3bd
parent 350 2c3c4dc34979
parent 345 894c0e6d951c
child 377 60b012b7793f
equal deleted inserted replaced
354:0f24db96b519 355:30db860bd3bd
   915     s4o.print("(");
   915     s4o.print("(");
   916     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
   916     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
   917     s4o.print(")");
   917     s4o.print(")");
   918   }
   918   }
   919   if (function_type_suffix != NULL) {
   919   if (function_type_suffix != NULL) {
   920     function_type_suffix = search_expression_type->default_literal_type(function_type_prefix);
   920   	function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
   921   }
   921   }
   922   if (has_output_params) {
   922   if (has_output_params) {
   923     fcall_number++;
   923     fcall_number++;
   924     s4o.print("__");
   924     s4o.print("__");
   925     fbname->accept(*this);
   925     fbname->accept(*this);
  1323     s4o.print("(");
  1323     s4o.print("(");
  1324     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
  1324     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
  1325     s4o.print(")");
  1325     s4o.print(")");
  1326   }
  1326   }
  1327   if (function_type_suffix != NULL) {
  1327   if (function_type_suffix != NULL) {
  1328     function_type_suffix = search_expression_type->default_literal_type(function_type_prefix);
  1328   	function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
  1329   }
  1329   }
  1330   if (has_output_params) {
  1330   if (has_output_params) {
  1331     fcall_number++;
  1331     fcall_number++;
  1332     s4o.print("__");
  1332     s4o.print("__");
  1333     fbname->accept(*this);
  1333     fbname->accept(*this);
  1732   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1732   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1733       search_expression_type->is_time_type(this->current_operand_type)) {
  1733       search_expression_type->is_time_type(this->current_operand_type)) {
  1734     XXX_function("__time_add", &(this->default_variable_name), this->current_operand);
  1734     XXX_function("__time_add", &(this->default_variable_name), this->current_operand);
  1735     /* the data type resulting from this operation... */
  1735     /* the data type resulting from this operation... */
  1736     this->default_variable_name.current_type = this->current_operand_type;
  1736     this->default_variable_name.current_type = this->current_operand_type;
  1737     return NULL;
  1737   }
  1738   }
  1738   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1739   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1740       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1739       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1741 	NUM_operator_result_type();
  1740 	NUM_operator_result_type();
  1742 	XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
  1741 	XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
  1743     /* the data type resulting from this operation... */
  1742     /* the data type resulting from this operation... */
  1744     this->default_variable_name.current_type = this->current_operand_type;
  1743     this->default_variable_name.current_type = this->current_operand_type;
  1745     return NULL;
  1744   }
  1746   }
  1745   else {ERROR;}
  1747   ERROR;
       
  1748   return NULL;
  1746   return NULL;
  1749 }
  1747 }
  1750 
  1748 
  1751 void *visit(SUB_operator_c *symbol)	{
  1749 void *visit(SUB_operator_c *symbol)	{
  1752   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1750   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1753       search_expression_type->is_time_type(this->current_operand_type)) {
  1751       search_expression_type->is_time_type(this->current_operand_type)) {
  1754     XXX_function("__time_sub", &(this->default_variable_name), this->current_operand);
  1752     XXX_function("__time_sub", &(this->default_variable_name), this->current_operand);
  1755     /* the data type resulting from this operation... */
  1753     /* the data type resulting from this operation... */
  1756     this->default_variable_name.current_type = this->current_operand_type;
  1754     this->default_variable_name.current_type = this->current_operand_type;
  1757     return NULL;
  1755   }
  1758   }
  1756   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1759   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1760       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1757       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1761 	NUM_operator_result_type();
  1758 	NUM_operator_result_type();
  1762 	XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
  1759 	XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
  1763     /* the data type resulting from this operation... */
  1760     /* the data type resulting from this operation... */
  1764     this->default_variable_name.current_type = this->current_operand_type;
  1761     this->default_variable_name.current_type = this->current_operand_type;
  1765     return NULL;
  1762   }
  1766   }
  1763   else {ERROR;}
  1767   ERROR;
       
  1768   return NULL;
  1764   return NULL;
  1769 }
  1765 }
  1770 
  1766 
  1771 void *visit(MUL_operator_c *symbol)	{
  1767 void *visit(MUL_operator_c *symbol)	{
  1772   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1768   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1773       search_expression_type->is_integer_type(this->current_operand_type)) {
  1769       search_expression_type->is_integer_type(this->current_operand_type)) {
  1774     XXX_function("__time_mul", &(this->default_variable_name), this->current_operand);
  1770     XXX_function("__time_mul", &(this->default_variable_name), this->current_operand);
  1775     /* the data type resulting from this operation... */
  1771     /* the data type resulting from this operation is unchanged! */
  1776     return NULL;
  1772   }
  1777   }
  1773   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1778   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1779       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1774       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1780 	NUM_operator_result_type();
  1775 	NUM_operator_result_type();
  1781     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1776     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1782     /* the data type resulting from this operation... */
  1777     /* the data type resulting from this operation... */
  1783     this->default_variable_name.current_type = this->current_operand_type;
  1778     this->default_variable_name.current_type = this->current_operand_type;
  1784     return NULL;
  1779   }
  1785   }
  1780   else {ERROR;}
  1786   ERROR;
       
  1787   return NULL;
  1781   return NULL;
  1788 }
  1782 }
  1789 
  1783 
  1790 void *visit(DIV_operator_c *symbol)	{
  1784 void *visit(DIV_operator_c *symbol)	{
  1791   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1785   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1792       search_expression_type->is_integer_type(this->current_operand_type)) {
  1786       search_expression_type->is_integer_type(this->current_operand_type)) {
  1793     XXX_function("__time_div", &(this->default_variable_name), this->current_operand);
  1787     XXX_function("__time_div", &(this->default_variable_name), this->current_operand);
  1794     /* the data type resulting from this operation... */
  1788     /* the data type resulting from this operation is unchanged! */
  1795     return NULL;
  1789   }
  1796   }
  1790   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1797   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
       
  1798       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1791       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1799 	NUM_operator_result_type();
  1792 	NUM_operator_result_type();
  1800 	XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
  1793 	XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
  1801     /* the data type resulting from this operation... */
  1794     /* the data type resulting from this operation... */
  1802     this->default_variable_name.current_type = this->current_operand_type;
  1795     this->default_variable_name.current_type = this->current_operand_type;
  1803   }
  1796     return NULL;
  1804   ERROR;
  1797   }
       
  1798   else {ERROR;}
  1805   return NULL;
  1799   return NULL;
  1806 }
  1800 }
  1807 
  1801 
  1808 void *visit(MOD_operator_c *symbol)	{
  1802 void *visit(MOD_operator_c *symbol)	{
  1809   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1803   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1811 	NUM_operator_result_type();
  1805 	NUM_operator_result_type();
  1812 	XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1806 	XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1813     /* the data type resulting from this operation... */
  1807     /* the data type resulting from this operation... */
  1814     this->default_variable_name.current_type = this->current_operand_type;
  1808     this->default_variable_name.current_type = this->current_operand_type;
  1815   }
  1809   }
  1816   ERROR;
  1810   else {ERROR;}
  1817   return NULL;
  1811   return NULL;
  1818 }
  1812 }
  1819 
  1813 
  1820 void *visit(GT_operator_c *symbol)	{
  1814 void *visit(GT_operator_c *symbol)	{
  1821   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1815   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1822       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1816       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1823     return CMP_operator(this->current_operand, "GT_");
  1817     CMP_operator(this->current_operand, "GT_");
  1824   ERROR;
  1818   } else {
       
  1819     ERROR;
       
  1820   }
  1825   return NULL;
  1821   return NULL;
  1826 }
  1822 }
  1827 
  1823 
  1828 void *visit(GE_operator_c *symbol)	{
  1824 void *visit(GE_operator_c *symbol)	{
  1829   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1825   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1830       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1826       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1831     return CMP_operator(this->current_operand, "GE_");
  1827     CMP_operator(this->current_operand, "GE_");
  1832   ERROR;
  1828   } else {
       
  1829     ERROR;
       
  1830   }
  1833   return NULL;
  1831   return NULL;
  1834 }
  1832 }
  1835 
  1833 
  1836 void *visit(EQ_operator_c *symbol)	{
  1834 void *visit(EQ_operator_c *symbol)	{
  1837   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1835   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1838     return CMP_operator(this->current_operand, "EQ_");
  1836     CMP_operator(this->current_operand, "EQ_");
  1839   ERROR;
  1837   } else {
       
  1838     ERROR;
       
  1839   }
  1840   return NULL;
  1840   return NULL;
  1841 }
  1841 }
  1842 
  1842 
  1843 void *visit(LT_operator_c *symbol)	{
  1843 void *visit(LT_operator_c *symbol)	{
  1844   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1844   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1845       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1845       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1846     return CMP_operator(this->current_operand, "LT_");
  1846     CMP_operator(this->current_operand, "LT_");
  1847   ERROR;
  1847   } else {
       
  1848     ERROR;
       
  1849   }
  1848   return NULL;
  1850   return NULL;
  1849 }
  1851 }
  1850 
  1852 
  1851 void *visit(LE_operator_c *symbol)	{
  1853 void *visit(LE_operator_c *symbol)	{
  1852   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1854   if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
  1853       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1855       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1854     return CMP_operator(this->current_operand, "LE_");
  1856     CMP_operator(this->current_operand, "LE_");
  1855   ERROR;
  1857   } else {
       
  1858     ERROR;
       
  1859   }
  1856   return NULL;
  1860   return NULL;
  1857 }
  1861 }
  1858 
  1862 
  1859 void *visit(NE_operator_c *symbol)	{
  1863 void *visit(NE_operator_c *symbol)	{
  1860   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
  1864   if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1861     return CMP_operator(this->current_operand, "NE_");
  1865     CMP_operator(this->current_operand, "NE_");
  1862   ERROR;
  1866   } else {
       
  1867     ERROR;
       
  1868   }
  1863   return NULL;
  1869   return NULL;
  1864 }
  1870 }
  1865 
  1871 
  1866 
  1872 
  1867 //SYM_REF0(CAL_operator_c)
  1873 //SYM_REF0(CAL_operator_c)