stage4/generate_c/generate_c_il.cc
changeset 1021 21a97cdb317d
parent 1016 91bef6704b44
child 1041 56ebe2a31b5b
equal deleted inserted replaced
1008:59435d4c5e0c 1021:21a97cdb317d
   325       if (NULL == operand->datatype) ERROR;
   325       if (NULL == operand->datatype) ERROR;
   326       if (NULL == this->implicit_variable_current.datatype) ERROR;
   326       if (NULL == this->implicit_variable_current.datatype) ERROR;
   327 
   327 
   328       this->implicit_variable_result.accept(*this);
   328       this->implicit_variable_result.accept(*this);
   329       s4o.print(" = ");
   329       s4o.print(" = ");
   330       s4o.print(operation);
   330       // print_compare_function is in generate_c_base_c, which is inherited by generate_c_il_c
   331       operand->datatype->accept(*this);
   331       print_compare_function(operation, operand->datatype, &(this->implicit_variable_current), operand);
   332       /* NOTE: we are calling a standard Function: 
       
   333        *         1st parameter: EN  (enable)
       
   334        *         2nd parameter: ENO (enable output)
       
   335        *         3rd parameter: number of operands we will be passing (required because we are calling an extensible standard function!)
       
   336        *         4th parameter: the left  hand side of the comparison expression (in out case, the IL implicit variable)
       
   337        *         4th parameter: the right hand side of the comparison expression (in out case, current operand)
       
   338        */
       
   339       s4o.print("(__BOOL_LITERAL(TRUE), NULL, 2, ");
       
   340       this->implicit_variable_current.accept(*this);
       
   341       s4o.print(", ");
       
   342       operand->accept(*this);
       
   343       s4o.print(")");
       
   344 
       
   345       return NULL;
   332       return NULL;
   346     }
   333     }
   347 
   334 
   348 
   335 
   349     /* A helper function... */
   336     /* A helper function... */
   895   /* Check whether we are calling an overloaded function! */
   882   /* Check whether we are calling an overloaded function! */
   896   /* (fdecl_mutiplicity > 1)  => calling overloaded function */
   883   /* (fdecl_mutiplicity > 1)  => calling overloaded function */
   897   int fdecl_mutiplicity =  function_symtable.count(symbol->function_name);
   884   int fdecl_mutiplicity =  function_symtable.count(symbol->function_name);
   898   if (fdecl_mutiplicity == 0) ERROR;
   885   if (fdecl_mutiplicity == 0) ERROR;
   899 
   886 
   900   this->implicit_variable_result.accept(*this);
   887   /* when function returns a void, we do not store the value in the default variable! */
   901   s4o.print(" = ");
   888   if (!get_datatype_info_c::is_VOID(symbol->datatype)) {
       
   889     this->implicit_variable_result.accept(*this);
       
   890     s4o.print(" = ");
       
   891   }
   902     
   892     
   903   if (function_type_prefix != NULL) {
   893   if (function_type_prefix != NULL) {
   904     s4o.print("(");
   894     s4o.print("(");
   905     default_literal_type(function_type_prefix)->accept(*this);
   895     default_literal_type(function_type_prefix)->accept(*this);
   906     s4o.print(")");
   896     s4o.print(")");
   935     if (function_type_suffix != NULL)
   925     if (function_type_suffix != NULL)
   936       function_type_suffix->accept(*this);
   926       function_type_suffix->accept(*this);
   937   }
   927   }
   938   s4o.print("(");
   928   s4o.print("(");
   939   s4o.indent_right();
   929   s4o.indent_right();
       
   930   s4o.print("\n"+s4o.indent_spaces);
   940   
   931   
   941   int nb_param = 0;
   932   int nb_param = 0;
   942   PARAM_LIST_ITERATOR() {
   933   PARAM_LIST_ITERATOR() {
   943     symbol_c *param_value = PARAM_VALUE;
   934     symbol_c *param_value = PARAM_VALUE;
   944     current_param_type = PARAM_TYPE;
   935     current_param_type = PARAM_TYPE;
   989       s4o.print(",\n"+s4o.indent_spaces);
   980       s4o.print(",\n"+s4o.indent_spaces);
   990     s4o.print(FB_FUNCTION_PARAM);
   981     s4o.print(FB_FUNCTION_PARAM);
   991   }
   982   }
   992   
   983   
   993   s4o.print(")");
   984   s4o.print(")");
       
   985   s4o.indent_left();  
   994 
   986 
   995   CLEAR_PARAM_LIST()
   987   CLEAR_PARAM_LIST()
   996 
   988 
   997   return NULL;
   989   return NULL;
   998 }
   990 }
  1297   if (fdecl_mutiplicity == 0) ERROR;
  1289   if (fdecl_mutiplicity == 0) ERROR;
  1298   if (fdecl_mutiplicity == 1) 
  1290   if (fdecl_mutiplicity == 1) 
  1299     /* function being called is NOT overloaded! */
  1291     /* function being called is NOT overloaded! */
  1300     f_decl = NULL; 
  1292     f_decl = NULL; 
  1301 
  1293 
  1302   this->implicit_variable_result.accept(*this);
  1294   /* when function returns a void, we do not store the value in the default variable! */
  1303   s4o.print(" = ");
  1295   if (!get_datatype_info_c::is_VOID(symbol->datatype)) {
       
  1296     this->implicit_variable_result.accept(*this);
       
  1297     s4o.print(" = ");
       
  1298   }
  1304   
  1299   
  1305   if (function_type_prefix != NULL) {
  1300   if (function_type_prefix != NULL) {
  1306     s4o.print("(");
  1301     s4o.print("(");
  1307     default_literal_type(function_type_prefix)->accept(*this);
  1302     default_literal_type(function_type_prefix)->accept(*this);
  1308     s4o.print(")");
  1303     s4o.print(")");
  1709   return NULL;
  1704   return NULL;
  1710 }
  1705 }
  1711 
  1706 
  1712 void *visit(MOD_operator_c *symbol)	{XXX_operator(&(this->implicit_variable_result), " %= ", this->current_operand); return NULL;}
  1707 void *visit(MOD_operator_c *symbol)	{XXX_operator(&(this->implicit_variable_result), " %= ", this->current_operand); return NULL;}
  1713 
  1708 
  1714 void *visit(GT_operator_c *symbol)	{CMP_operator(this->current_operand, "GT_"); return NULL;}
  1709 void *visit(GT_operator_c *symbol)	{CMP_operator(this->current_operand, "GT"); return NULL;}
  1715 void *visit(GE_operator_c *symbol)	{CMP_operator(this->current_operand, "GE_"); return NULL;}
  1710 void *visit(GE_operator_c *symbol)	{CMP_operator(this->current_operand, "GE"); return NULL;}
  1716 void *visit(EQ_operator_c *symbol)	{CMP_operator(this->current_operand, "EQ_"); return NULL;}
  1711 void *visit(EQ_operator_c *symbol)	{CMP_operator(this->current_operand, "EQ"); return NULL;}
  1717 void *visit(LT_operator_c *symbol)	{CMP_operator(this->current_operand, "LT_"); return NULL;}
  1712 void *visit(LT_operator_c *symbol)	{CMP_operator(this->current_operand, "LT"); return NULL;}
  1718 void *visit(LE_operator_c *symbol)	{CMP_operator(this->current_operand, "LE_"); return NULL;}
  1713 void *visit(LE_operator_c *symbol)	{CMP_operator(this->current_operand, "LE"); return NULL;}
  1719 void *visit(NE_operator_c *symbol)	{CMP_operator(this->current_operand, "NE_"); return NULL;}
  1714 void *visit(NE_operator_c *symbol)	{CMP_operator(this->current_operand, "NE"); return NULL;}
  1720 
  1715 
  1721 
  1716 
  1722 //SYM_REF0(CAL_operator_c)
  1717 //SYM_REF0(CAL_operator_c)
  1723 // This method will be called from within the il_fb_call_c visitor method
  1718 // This method will be called from within the il_fb_call_c visitor method
  1724 void *visit(CAL_operator_c *symbol) {return NULL;}
  1719 void *visit(CAL_operator_c *symbol) {return NULL;}