stage4/generate_c/generate_c_il.cc
changeset 240 f78fa87bb4cb
parent 238 0919986a5c98
child 279 c0453b7f99df
equal deleted inserted replaced
239:b3063ca418c1 240:f78fa87bb4cb
  1142 
  1142 
  1143   /* now call the function... */
  1143   /* now call the function... */
  1144   function_block_type_name->accept(*this);
  1144   function_block_type_name->accept(*this);
  1145   s4o.print(FB_FUNCTION_SUFFIX);
  1145   s4o.print(FB_FUNCTION_SUFFIX);
  1146   s4o.print("(&");
  1146   s4o.print("(&");
       
  1147   print_variable_prefix();
  1147   symbol->fb_name->accept(*this);
  1148   symbol->fb_name->accept(*this);
  1148   s4o.print(")");
  1149   s4o.print(")");
  1149 
  1150 
  1150   /* loop through each function parameter, find the variable to which
  1151   /* loop through each function parameter, find the variable to which
  1151    * we should atribute the value of all output or inoutput parameters.
  1152    * we should atribute the value of all output or inoutput parameters.
  1165     /* now output the value assignment */
  1166     /* now output the value assignment */
  1166     if (param_value != NULL)
  1167     if (param_value != NULL)
  1167       if ((param_direction == function_param_iterator_c::direction_out) ||
  1168       if ((param_direction == function_param_iterator_c::direction_out) ||
  1168           (param_direction == function_param_iterator_c::direction_inout)) {
  1169           (param_direction == function_param_iterator_c::direction_inout)) {
  1169         symbol_c *param_type = search_varfb_instance_type->get_rawtype(param_value);
  1170         symbol_c *param_type = search_varfb_instance_type->get_rawtype(param_value);
       
  1171         s4o.print(";\n" + s4o.indent_spaces);
  1170         if (this->is_variable_prefix_null()) {
  1172         if (this->is_variable_prefix_null()) {
  1171 		  param_value->accept(*this);
  1173           param_value->accept(*this);
  1172 		  s4o.print(" = ");
  1174 		  s4o.print(" = ");
  1173 		  print_check_function(param_type, param_name, symbol->fb_name);
  1175 		  print_check_function(param_type, param_name, symbol->fb_name);
  1174 		}
  1176 		}
  1175 		else {
  1177 		else {
  1176 		  print_setter(param_value, param_type, param_name, NULL, symbol->fb_name);
  1178 		  print_setter(param_value, param_type, param_name, NULL, symbol->fb_name);
  1573 void *visit(S_operator_c *symbol)	{
  1575 void *visit(S_operator_c *symbol)	{
  1574   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1576   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1575 
  1577 
  1576   C_modifier();
  1578   C_modifier();
  1577   this->current_operand->accept(*this);
  1579   this->current_operand->accept(*this);
  1578   s4o.print(search_expression_type->is_bool_type(this->current_operand_type)?" = true":" = 1");
  1580   s4o.print(" = __");
       
  1581   if (search_expression_type->is_bool_type(this->current_operand_type))
       
  1582     s4o.print("BOOL_LITERAL(TRUE)");
       
  1583   else if (search_expression_type->is_integer_type(this->current_operand_type)) {
       
  1584     this->current_operand_type->accept(*this);
       
  1585     s4o.print("_LITERAL(1)");
       
  1586   }
       
  1587   else
       
  1588     ERROR;
  1579   /* the data type resulting from this operation is unchanged! */
  1589   /* the data type resulting from this operation is unchanged! */
  1580   return NULL;
  1590   return NULL;
  1581 }
  1591 }
  1582 
  1592 
  1583 void *visit(R_operator_c *symbol)	{
  1593 void *visit(R_operator_c *symbol)	{
  1584   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1594   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1585 
  1595 
  1586   C_modifier();
  1596   C_modifier();
  1587   this->current_operand->accept(*this);
  1597   this->current_operand->accept(*this);
  1588   s4o.print(search_expression_type->is_bool_type(this->current_operand_type)?" = false":" = 0");
  1598   s4o.print(" = __");
       
  1599   if (search_expression_type->is_bool_type(this->current_operand_type))
       
  1600     s4o.print("BOOL_LITERAL(FALSE)");
       
  1601   else if (search_expression_type->is_integer_type(this->current_operand_type)) {
       
  1602     this->current_operand_type->accept(*this);
       
  1603     s4o.print("_LITERAL(0)");
       
  1604   }
       
  1605   else
       
  1606     ERROR;
  1589   /* the data type resulting from this operation is unchanged! */
  1607   /* the data type resulting from this operation is unchanged! */
  1590   return NULL;
  1608   return NULL;
  1591 }
  1609 }
  1592 
  1610 
  1593 void *visit(S1_operator_c *symbol)	{return XXX_CAL_operator("S1", this->current_operand);}
  1611 void *visit(S1_operator_c *symbol)	{return XXX_CAL_operator("S1", this->current_operand);}