stage4/generate_c/generate_c_il.cc
changeset 669 7049fd6fe515
parent 667 bd1360f29f15
child 682 966f32af570d
equal deleted inserted replaced
668:90b6eb7f1775 669:7049fd6fe515
   123 /***********************************************************************/
   123 /***********************************************************************/
   124 /***********************************************************************/
   124 /***********************************************************************/
   125 
   125 
   126 
   126 
   127 
   127 
       
   128 
       
   129 
   128 class generate_c_il_c: public generate_c_typedecl_c, il_default_variable_visitor_c {
   130 class generate_c_il_c: public generate_c_typedecl_c, il_default_variable_visitor_c {
   129 
   131 
   130   public:
   132   public:
   131     typedef enum {
   133     typedef enum {
   132       expression_vg,
   134       expression_vg,
   136       complextype_suffix_vg,
   138       complextype_suffix_vg,
   137       fparam_output_vg
   139       fparam_output_vg
   138     } variablegeneration_t;
   140     } variablegeneration_t;
   139 
   141 
   140   private:
   142   private:
   141     /* When compiling il code, it becomes necessary to determine the
       
   142      * data type of il operands. To do this, we must first find the
       
   143      * il operand's declaration, within the scope of the function block
       
   144      * or function currently being processed.
       
   145      * The following object does just that...
       
   146      * This object instance will then later be called while the
       
   147      * remaining il code is being handled.
       
   148      */
       
   149     search_expression_type_c *search_expression_type;
       
   150 
       
   151     /* The initial value that should be given to the IL default variable
   143     /* The initial value that should be given to the IL default variable
   152      * imediately after a parenthesis is opened.
   144      * imediately after a parenthesis is opened.
   153      * This variable is only used to pass data from the
   145      * This variable is only used to pass data from the
   154      * il_expression_c visitor to the simple_instr_list_c visitor.
   146      * il_expression_c visitor to the simple_instr_list_c visitor.
   155      *
   147      *
   246     generate_c_il_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL)
   238     generate_c_il_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL)
   247     : generate_c_typedecl_c(s4o_ptr),
   239     : generate_c_typedecl_c(s4o_ptr),
   248       default_variable_name(IL_DEFVAR, NULL),
   240       default_variable_name(IL_DEFVAR, NULL),
   249       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   241       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   250     {
   242     {
   251       search_expression_type = new search_expression_type_c(scope);
   243       search_fb_instance_decl    = new search_fb_instance_decl_c   (scope);
   252       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
       
   253       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   244       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   254       search_var_instance_decl   = new search_var_instance_decl_c(scope);
   245       search_var_instance_decl   = new search_var_instance_decl_c  (scope);
   255       
   246       
   256       current_operand = NULL;
   247       current_operand = NULL;
   257       current_operand_type = NULL;
   248       current_operand_type = NULL;
   258       il_default_variable_init_value = NULL;
   249       il_default_variable_init_value = NULL;
   259       current_array_type = NULL;
   250       current_array_type = NULL;
   264       this->set_variable_prefix(variable_prefix);
   255       this->set_variable_prefix(variable_prefix);
   265     }
   256     }
   266 
   257 
   267     virtual ~generate_c_il_c(void) {
   258     virtual ~generate_c_il_c(void) {
   268       delete search_fb_instance_decl;
   259       delete search_fb_instance_decl;
   269       delete search_expression_type;
       
   270       delete search_varfb_instance_type;
   260       delete search_varfb_instance_type;
   271       delete search_var_instance_decl;
   261       delete search_var_instance_decl;
   272     }
   262     }
   273 
   263 
   274     void generate(instruction_list_c *il) {
   264     void generate(instruction_list_c *il) {
   294       this->default_variable_name.current_type = NULL;
   284       this->default_variable_name.current_type = NULL;
   295       this->default_variable_back_name.current_type = NULL;
   285       this->default_variable_back_name.current_type = NULL;
   296     }
   286     }
   297 
   287 
   298   private:
   288   private:
   299     /* A helper function... */
   289     /* a small helper function */
   300     /*
   290     symbol_c *default_literal_type(symbol_c *symbol) {
   301     bool is_bool_type(symbol_c *type_symbol) {
   291       if (get_datatype_info_c::is_ANY_INT_literal(symbol)) {
   302       return (NULL != dynamic_cast<bool_type_name_c *>(type_symbol));
   292         return &search_constant_type_c::lint_type_name;
   303     }
   293       }
   304     */
   294       else if (get_datatype_info_c::is_ANY_REAL_literal(symbol)) {
       
   295         return &search_constant_type_c::lreal_type_name;
       
   296       }
       
   297       return symbol;
       
   298     }
   305 
   299 
   306     /* A helper function... */
   300     /* A helper function... */
   307     void *XXX_operator(symbol_c *lo, const char *op, symbol_c *ro) {
   301     void *XXX_operator(symbol_c *lo, const char *op, symbol_c *ro) {
   308       if ((NULL == lo) || (NULL == ro)) ERROR;
   302       if ((NULL == lo) || (NULL == ro) || (NULL == op)) ERROR;
   309       if (NULL == op) ERROR;
       
   310 
   303 
   311       lo->accept(*this);
   304       lo->accept(*this);
   312       s4o.print(op);
   305       s4o.print(op);
   313       ro->accept(*this);
   306       ro->accept(*this);
   314       return NULL;
   307       return NULL;
   384     }
   377     }
   385 
   378 
   386 
   379 
   387     /* A helper function... */
   380     /* A helper function... */
   388     void C_modifier(void) {
   381     void C_modifier(void) {
   389       if (search_expression_type->is_bool_type(default_variable_name.current_type)) {
   382       if (get_datatype_info_c::is_BOOL_compatible(default_variable_name.current_type)) {
   390         s4o.print("if (");
   383         s4o.print("if (");
   391         this->default_variable_name.accept(*this);
   384         this->default_variable_name.accept(*this);
   392         s4o.print(") ");
   385         s4o.print(") ");
   393       }
   386       }
   394       else {ERROR;}
   387       else {ERROR;}
   395     }
   388     }
   396 
   389 
   397     /* A helper function... */
   390     /* A helper function... */
   398     void CN_modifier(void) {
   391     void CN_modifier(void) {
   399       if (search_expression_type->is_bool_type(default_variable_name.current_type)) {
   392       if (get_datatype_info_c::is_BOOL_compatible(default_variable_name.current_type)) {
   400         s4o.print("if (!");
   393         s4o.print("if (!");
   401         this->default_variable_name.accept(*this);
   394         this->default_variable_name.accept(*this);
   402         s4o.print(") ");
   395         s4o.print(") ");
   403       }
   396       }
   404       else {ERROR;}
   397       else {ERROR;}
   405     }
   398     }
   406 
   399 
   407     void BYTE_operator_result_type(void) {
   400     void BYTE_operator_result_type(void) {
   408       if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type)) {
   401       if (get_datatype_info_c::is_ANY_INT_literal(this->default_variable_name.current_type)) {
   409         if (search_expression_type->is_literal_integer_type(this->current_operand_type))
   402         if (get_datatype_info_c::is_ANY_INT_literal(this->current_operand_type))
   410           this->default_variable_name.current_type = &(this->lword_type);
   403           this->default_variable_name.current_type = &(this->lword_type);
   411         else
   404         else
   412           this->default_variable_name.current_type = this->current_operand_type;
   405           this->default_variable_name.current_type = this->current_operand_type;
   413       }
   406       }
   414       else if (search_expression_type->is_literal_integer_type(this->current_operand_type))
   407       else if (get_datatype_info_c::is_ANY_INT_literal(this->current_operand_type))
   415     	  this->current_operand_type = this->default_variable_name.current_type;
   408     	  this->current_operand_type = this->default_variable_name.current_type;
   416     }
   409     }
   417 
   410 
   418     void NUM_operator_result_type(void) {
   411     void NUM_operator_result_type(void) {
   419       if (search_expression_type->is_literal_real_type(this->default_variable_name.current_type)) {
   412       if (get_datatype_info_c::is_ANY_REAL_literal(this->default_variable_name.current_type)) {
   420         if (search_expression_type->is_literal_integer_type(this->current_operand_type) ||
   413         if (get_datatype_info_c::is_ANY_INT_literal(this->current_operand_type) ||
   421             search_expression_type->is_literal_real_type(this->current_operand_type))
   414             get_datatype_info_c::is_ANY_REAL_literal(this->current_operand_type))
   422           this->default_variable_name.current_type = &(this->lreal_type);
   415           this->default_variable_name.current_type = &(this->lreal_type);
   423         else
   416         else
   424           this->default_variable_name.current_type = this->current_operand_type;
   417           this->default_variable_name.current_type = this->current_operand_type;
   425       }
   418       }
   426       else if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type)) {
   419       else if (get_datatype_info_c::is_ANY_INT_literal(this->default_variable_name.current_type)) {
   427         if (search_expression_type->is_literal_integer_type(this->current_operand_type))
   420         if (get_datatype_info_c::is_ANY_INT_literal(this->current_operand_type))
   428           this->default_variable_name.current_type = &(this->lint_type);
   421           this->default_variable_name.current_type = &(this->lint_type);
   429         else if (search_expression_type->is_literal_real_type(this->current_operand_type))
   422         else if (get_datatype_info_c::is_ANY_REAL_literal(this->current_operand_type))
   430           this->default_variable_name.current_type = &(this->lreal_type);
   423           this->default_variable_name.current_type = &(this->lreal_type);
   431         else
   424         else
   432           this->default_variable_name.current_type = this->current_operand_type;
   425           this->default_variable_name.current_type = this->current_operand_type;
   433       }
   426       }
   434       else if (search_expression_type->is_literal_integer_type(this->current_operand_type) ||
   427       else if (get_datatype_info_c::is_ANY_INT_literal(this->current_operand_type) ||
   435                search_expression_type->is_literal_real_type(this->current_operand_type))
   428                get_datatype_info_c::is_ANY_REAL_literal(this->current_operand_type))
   436         this->current_operand_type = this->default_variable_name.current_type;
   429         this->current_operand_type = this->default_variable_name.current_type;
   437     }
   430     }
   438 
   431 
   439     void *print_getter(symbol_c *symbol) {
   432     void *print_getter(symbol_c *symbol) {
   440       unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   433       unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   501         wanted_variablegeneration = assignment_vg;
   494         wanted_variablegeneration = assignment_vg;
   502 
   495 
   503       symbol->accept(*this);
   496       symbol->accept(*this);
   504       s4o.print(",");
   497       s4o.print(",");
   505       if (negative) {
   498       if (negative) {
   506 	    if (search_expression_type->is_bool_type(this->current_operand_type))
   499 	    if (get_datatype_info_c::is_BOOL_compatible(this->current_operand_type))
   507 		  s4o.print("!");
   500 		  s4o.print("!");
   508 	    else
   501 	    else
   509 		  s4o.print("~");
   502 		  s4o.print("~");
   510       }
   503       }
   511       wanted_variablegeneration = expression_vg;
   504       wanted_variablegeneration = expression_vg;
   523 public:
   516 public:
   524 void *visit(il_default_variable_c *symbol) {
   517 void *visit(il_default_variable_c *symbol) {
   525   symbol->var_name->accept(*this);
   518   symbol->var_name->accept(*this);
   526   if (NULL != symbol->current_type) {
   519   if (NULL != symbol->current_type) {
   527     s4o.print(".");
   520     s4o.print(".");
   528     if      ( search_expression_type->is_literal_integer_type(symbol->current_type))                  this->lint_type.accept(*this);
   521     if      ( get_datatype_info_c::is_ANY_INT_literal(symbol->current_type))                        this->lint_type.accept(*this);
   529     else if ( search_expression_type->is_literal_real_type(this->default_variable_name.current_type)) this->lreal_type.accept(*this);
   522     else if ( get_datatype_info_c::is_ANY_REAL_literal(this->default_variable_name.current_type))   this->lreal_type.accept(*this);
   530     else if ( search_expression_type->is_bool_type(this->default_variable_name.current_type))         this->bool_type.accept(*this); 
   523     else if ( get_datatype_info_c::is_BOOL_compatible(this->default_variable_name.current_type))    this->bool_type.accept(*this); 
   531     else symbol->current_type->accept(*this);
   524     else symbol->current_type->accept(*this);
   532     s4o.print("var");
   525     s4o.print("var");
   533   } return NULL;
   526   } return NULL;
   534 }
   527 }
   535 
   528 
   811 void *visit(il_simple_operation_c *symbol) {
   804 void *visit(il_simple_operation_c *symbol) {
   812   this->current_operand = symbol->il_operand;
   805   this->current_operand = symbol->il_operand;
   813   if (NULL == this->current_operand) {
   806   if (NULL == this->current_operand) {
   814     this->current_operand_type = NULL;
   807     this->current_operand_type = NULL;
   815   } else {
   808   } else {
   816     this->current_operand_type = search_expression_type->get_type(this->current_operand);
   809     this->current_operand_type = this->current_operand->datatype;
   817     if (NULL == this->current_operand_type) ERROR;
   810     if (NULL == this->current_operand_type) ERROR;
   818   }
   811   }
   819 
   812 
   820   symbol->il_simple_operator->accept(*this);
   813   symbol->il_simple_operator->accept(*this);
   821 
   814 
   960   default_variable_name.current_type = param_data_type;
   953   default_variable_name.current_type = param_data_type;
   961   s4o.print(" = ");
   954   s4o.print(" = ");
   962     
   955     
   963   if (function_type_prefix != NULL) {
   956   if (function_type_prefix != NULL) {
   964     s4o.print("(");
   957     s4o.print("(");
   965     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
   958     default_literal_type(function_type_prefix)->accept(*this);
   966     s4o.print(")");
   959     s4o.print(")");
   967   }
   960   }
   968   if (function_type_suffix != NULL) {
   961   if (function_type_suffix != NULL) {
   969   	function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
   962   	function_type_suffix = default_literal_type(function_type_suffix);
   970   }
   963   }
   971   if (has_output_params) {
   964   if (has_output_params) {
   972     fcall_number++;
   965     fcall_number++;
   973     s4o.print("__");
   966     s4o.print("__");
   974     fbname->accept(*this);
   967     fbname->accept(*this);
  1011           /* If not, get the default value of this variable's type */
  1004           /* If not, get the default value of this variable's type */
  1012           param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance());
  1005           param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance());
  1013         }
  1006         }
  1014         if (param_value == NULL) ERROR;
  1007         if (param_value == NULL) ERROR;
  1015         s4o.print("(");
  1008         s4o.print("(");
  1016         if (search_expression_type->is_literal_integer_type(current_param_type))
  1009         if (get_datatype_info_c::is_ANY_INT_literal(current_param_type))
  1017           search_expression_type->lint_type_name.accept(*this);
  1010           search_constant_type_c::lint_type_name.accept(*this);
  1018         else if (search_expression_type->is_literal_real_type(current_param_type))
  1011         else if (get_datatype_info_c::is_ANY_REAL_literal(current_param_type))
  1019           search_expression_type->lreal_type_name.accept(*this);
  1012           search_constant_type_c::lreal_type_name.accept(*this);
  1020         else
  1013         else
  1021           current_param_type->accept(*this);
  1014           current_param_type->accept(*this);
  1022         s4o.print(")");
  1015         s4o.print(")");
  1023         print_check_function(current_param_type, param_value);
  1016         print_check_function(current_param_type, param_value);
  1024         nb_param++;
  1017         nb_param++;
  1368   this->default_variable_name.accept(*this);
  1361   this->default_variable_name.accept(*this);
  1369   s4o.print(" = ");
  1362   s4o.print(" = ");
  1370   
  1363   
  1371   if (function_type_prefix != NULL) {
  1364   if (function_type_prefix != NULL) {
  1372     s4o.print("(");
  1365     s4o.print("(");
  1373     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
  1366     default_literal_type(function_type_prefix)->accept(*this);
  1374     s4o.print(")");
  1367     s4o.print(")");
  1375   }
  1368   }
  1376   if (function_type_suffix != NULL) {
  1369   if (function_type_suffix != NULL) {
  1377   	function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
  1370   	function_type_suffix = default_literal_type(function_type_suffix);
  1378   }
  1371   }
  1379   if (has_output_params) {
  1372   if (has_output_params) {
  1380     fcall_number++;
  1373     fcall_number++;
  1381     s4o.print("__");
  1374     s4o.print("__");
  1382     fbname->accept(*this);
  1375     fbname->accept(*this);
  1418           /* If not, get the default value of this variable's type */
  1411           /* If not, get the default value of this variable's type */
  1419           param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance());
  1412           param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance());
  1420         }
  1413         }
  1421         if (param_value == NULL) ERROR;
  1414         if (param_value == NULL) ERROR;
  1422         s4o.print("(");
  1415         s4o.print("(");
  1423         if (search_expression_type->is_literal_integer_type(current_param_type))
  1416         if (get_datatype_info_c::is_ANY_INT_literal(current_param_type))
  1424           search_expression_type->lint_type_name.accept(*this);
  1417           search_constant_type_c::lint_type_name.accept(*this);
  1425         else if (search_expression_type->is_literal_real_type(current_param_type))
  1418         else if (get_datatype_info_c::is_ANY_REAL_literal(current_param_type))
  1426           search_expression_type->lreal_type_name.accept(*this);
  1419           search_constant_type_c::lreal_type_name.accept(*this);
  1427         else
  1420         else
  1428           current_param_type->accept(*this);
  1421           current_param_type->accept(*this);
  1429         s4o.print(")");
  1422         s4o.print(")");
  1430         print_check_function(current_param_type, param_value);
  1423         print_check_function(current_param_type, param_value);
  1431         nb_param++;
  1424         nb_param++;
  1609 
  1602 
  1610 void *visit(LDN_operator_c *symbol)	{
  1603 void *visit(LDN_operator_c *symbol)	{
  1611   /* the data type resulting from this operation... */
  1604   /* the data type resulting from this operation... */
  1612   this->default_variable_name.current_type = this->current_operand_type;
  1605   this->default_variable_name.current_type = this->current_operand_type;
  1613   XXX_operator(&(this->default_variable_name),
  1606   XXX_operator(&(this->default_variable_name),
  1614                search_expression_type->is_bool_type(this->current_operand_type)?" = !":" = ~",
  1607                get_datatype_info_c::is_BOOL_compatible(this->current_operand_type)?" = !":" = ~",
  1615                this->current_operand);
  1608                this->current_operand);
  1616   return NULL;
  1609   return NULL;
  1617 }
  1610 }
  1618 
  1611 
  1619 void *visit(ST_operator_c *symbol)	{
  1612 void *visit(ST_operator_c *symbol)	{
  1620   symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand);
  1613   symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand);
  1621   if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type) ||
  1614   if (get_datatype_info_c::is_ANY_INT_literal(this->default_variable_name.current_type) ||
  1622   	  search_expression_type->is_literal_real_type(this->default_variable_name.current_type))
  1615   	  get_datatype_info_c::is_ANY_REAL_literal(this->default_variable_name.current_type))
  1623       this->default_variable_name.current_type = this->current_operand_type;
  1616       this->default_variable_name.current_type = this->current_operand_type;
  1624   if (this->is_variable_prefix_null()) {
  1617   if (this->is_variable_prefix_null()) {
  1625     this->current_operand->accept(*this);
  1618     this->current_operand->accept(*this);
  1626     s4o.print(" = ");
  1619     s4o.print(" = ");
  1627     print_check_function(operand_type, (symbol_c*)&(this->default_variable_name));
  1620     print_check_function(operand_type, (symbol_c*)&(this->default_variable_name));
  1633   return NULL;
  1626   return NULL;
  1634 }
  1627 }
  1635 
  1628 
  1636 void *visit(STN_operator_c *symbol)	{
  1629 void *visit(STN_operator_c *symbol)	{
  1637   symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand);
  1630   symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand);
  1638   if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type))
  1631   if (get_datatype_info_c::is_ANY_INT_literal(this->default_variable_name.current_type))
  1639 	this->default_variable_name.current_type = this->current_operand_type;
  1632 	this->default_variable_name.current_type = this->current_operand_type;
  1640   
  1633   
  1641   if (this->is_variable_prefix_null()) {
  1634   if (this->is_variable_prefix_null()) {
  1642     this->current_operand->accept(*this);
  1635     this->current_operand->accept(*this);
  1643     s4o.print(" = ");
  1636     s4o.print(" = ");
  1644     if (search_expression_type->is_bool_type(this->current_operand_type))
  1637     if (get_datatype_info_c::is_BOOL_compatible(this->current_operand_type))
  1645       s4o.print("!");
  1638       s4o.print("!");
  1646     else
  1639     else
  1647 	  s4o.print("~");
  1640 	  s4o.print("~");
  1648     this->default_variable_name.accept(*this);
  1641     this->default_variable_name.accept(*this);
  1649   }
  1642   }
  1661    *       We therefore consider it an error if an il_operand is specified!
  1654    *       We therefore consider it an error if an il_operand is specified!
  1662    *       The error is caught in stage 3!
  1655    *       The error is caught in stage 3!
  1663    */  
  1656    */  
  1664   if ((NULL != this->current_operand) || (NULL != this->current_operand_type)) ERROR;
  1657   if ((NULL != this->current_operand) || (NULL != this->current_operand_type)) ERROR;
  1665   XXX_operator(&(this->default_variable_name),
  1658   XXX_operator(&(this->default_variable_name),
  1666                search_expression_type->is_bool_type(this->default_variable_name.current_type)?" = !":" = ~",
  1659                get_datatype_info_c::is_BOOL_compatible(this->default_variable_name.current_type)?" = !":" = ~",
  1667                &(this->default_variable_name));
  1660                &(this->default_variable_name));
  1668   /* the data type resulting from this operation is unchanged. */
  1661   /* the data type resulting from this operation is unchanged. */
  1669   return NULL;
  1662   return NULL;
  1670 }
  1663 }
  1671 
  1664 
  1678   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1671   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1679 
  1672 
  1680   C_modifier();
  1673   C_modifier();
  1681   this->current_operand->accept(*this);
  1674   this->current_operand->accept(*this);
  1682   s4o.print(" = __");
  1675   s4o.print(" = __");
  1683   if (search_expression_type->is_bool_type(this->current_operand_type))
  1676   if (get_datatype_info_c::is_BOOL_compatible(this->current_operand_type))
  1684     s4o.print("BOOL_LITERAL(TRUE)");
  1677     s4o.print("BOOL_LITERAL(TRUE)");
  1685   else if (search_expression_type->is_integer_type(this->current_operand_type)) {
  1678   else if (get_datatype_info_c::is_ANY_INT_compatible(this->current_operand_type)) {
  1686     this->current_operand_type->accept(*this);
  1679     this->current_operand_type->accept(*this);
  1687     s4o.print("_LITERAL(1)");
  1680     s4o.print("_LITERAL(1)");
  1688   }
  1681   }
  1689   else
  1682   else
  1690     ERROR;
  1683     ERROR;
  1701   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1694   if ((NULL == this->current_operand) || (NULL == this->current_operand_type)) ERROR;
  1702 
  1695 
  1703   C_modifier();
  1696   C_modifier();
  1704   this->current_operand->accept(*this);
  1697   this->current_operand->accept(*this);
  1705   s4o.print(" = __");
  1698   s4o.print(" = __");
  1706   if (search_expression_type->is_bool_type(this->current_operand_type))
  1699   if (get_datatype_info_c::is_BOOL_compatible(this->current_operand_type))
  1707     s4o.print("BOOL_LITERAL(FALSE)");
  1700     s4o.print("BOOL_LITERAL(FALSE)");
  1708   else if (search_expression_type->is_integer_type(this->current_operand_type)) {
  1701   else if (get_datatype_info_c::is_ANY_INT_compatible(this->current_operand_type)) {
  1709     this->current_operand_type->accept(*this);
  1702     this->current_operand_type->accept(*this);
  1710     s4o.print("_LITERAL(0)");
  1703     s4o.print("_LITERAL(0)");
  1711   }
  1704   }
  1712   else
  1705   else
  1713     ERROR;
  1706     ERROR;
  1723 void *visit(PV_operator_c *symbol)	{return XXX_CAL_operator("PV", this->current_operand);}
  1716 void *visit(PV_operator_c *symbol)	{return XXX_CAL_operator("PV", this->current_operand);}
  1724 void *visit(IN_operator_c *symbol)	{return XXX_CAL_operator("IN", this->current_operand);}
  1717 void *visit(IN_operator_c *symbol)	{return XXX_CAL_operator("IN", this->current_operand);}
  1725 void *visit(PT_operator_c *symbol)	{return XXX_CAL_operator("PT", this->current_operand);}
  1718 void *visit(PT_operator_c *symbol)	{return XXX_CAL_operator("PT", this->current_operand);}
  1726 
  1719 
  1727 void *visit(AND_operator_c *symbol)	{
  1720 void *visit(AND_operator_c *symbol)	{
  1728   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1721   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1729       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1730 	BYTE_operator_result_type();
  1722 	BYTE_operator_result_type();
  1731 	XXX_operator(&(this->default_variable_name), " &= ", this->current_operand);
  1723 	XXX_operator(&(this->default_variable_name), " &= ", this->current_operand);
  1732     /* the data type resulting from this operation... */
  1724     /* the data type resulting from this operation... */
  1733     this->default_variable_name.current_type = this->current_operand_type;
  1725     this->default_variable_name.current_type = this->current_operand_type;
  1734   }
  1726   }
  1735   else {ERROR;}
  1727   else {ERROR;}
  1736   return NULL;
  1728   return NULL;
  1737 }
  1729 }
  1738 
  1730 
  1739 void *visit(OR_operator_c *symbol)	{
  1731 void *visit(OR_operator_c *symbol)	{
  1740   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1732   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1741       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1742 	BYTE_operator_result_type();
  1733 	BYTE_operator_result_type();
  1743 	XXX_operator(&(this->default_variable_name), " |= ", this->current_operand);
  1734 	XXX_operator(&(this->default_variable_name), " |= ", this->current_operand);
  1744     /* the data type resulting from this operation... */
  1735     /* the data type resulting from this operation... */
  1745     this->default_variable_name.current_type = this->current_operand_type;
  1736     this->default_variable_name.current_type = this->current_operand_type;
  1746   }
  1737   }
  1747   else {ERROR;}
  1738   else {ERROR;}
  1748   return NULL;
  1739   return NULL;
  1749 }
  1740 }
  1750 
  1741 
  1751 void *visit(XOR_operator_c *symbol)	{
  1742 void *visit(XOR_operator_c *symbol)	{
  1752   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1743   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1753       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1754 	BYTE_operator_result_type();
  1744 	BYTE_operator_result_type();
  1755 	// '^' is a bit by bit exclusive OR !! Also seems to work with boolean types!
  1745 	// '^' is a bit by bit exclusive OR !! Also seems to work with boolean types!
  1756     XXX_operator(&(this->default_variable_name), " ^= ", this->current_operand);
  1746     XXX_operator(&(this->default_variable_name), " ^= ", this->current_operand);
  1757     /* the data type resulting from this operation... */
  1747     /* the data type resulting from this operation... */
  1758     this->default_variable_name.current_type = this->current_operand_type;
  1748     this->default_variable_name.current_type = this->current_operand_type;
  1760   else {ERROR;}
  1750   else {ERROR;}
  1761   return NULL;
  1751   return NULL;
  1762 }
  1752 }
  1763 
  1753 
  1764 void *visit(ANDN_operator_c *symbol)	{
  1754 void *visit(ANDN_operator_c *symbol)	{
  1765   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1755   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1766       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1767 	BYTE_operator_result_type();
  1756 	BYTE_operator_result_type();
  1768 	XXX_operator(&(this->default_variable_name),
  1757 	XXX_operator(&(this->default_variable_name),
  1769                  search_expression_type->is_bool_type(this->current_operand_type)?" &= !":" &= ~",
  1758                  get_datatype_info_c::is_BOOL_compatible(this->current_operand_type)?" &= !":" &= ~",
  1770                  this->current_operand);
  1759                  this->current_operand);
  1771     /* the data type resulting from this operation... */
  1760     /* the data type resulting from this operation... */
  1772     this->default_variable_name.current_type = this->current_operand_type;
  1761     this->default_variable_name.current_type = this->current_operand_type;
  1773   }
  1762   }
  1774   else {ERROR;}
  1763   else {ERROR;}
  1775   return NULL;
  1764   return NULL;
  1776 }
  1765 }
  1777 
  1766 
  1778 void *visit(ORN_operator_c *symbol)	{
  1767 void *visit(ORN_operator_c *symbol)	{
  1779   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1768   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1780       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1781 	BYTE_operator_result_type();
  1769 	BYTE_operator_result_type();
  1782 	XXX_operator(&(this->default_variable_name),
  1770 	XXX_operator(&(this->default_variable_name),
  1783                  search_expression_type->is_bool_type(this->current_operand_type)?" |= !":" |= ~",
  1771                  get_datatype_info_c::is_BOOL_compatible(this->current_operand_type)?" |= !":" |= ~",
  1784                  this->current_operand);
  1772                  this->current_operand);
  1785     /* the data type resulting from this operation... */
  1773     /* the data type resulting from this operation... */
  1786     this->default_variable_name.current_type = this->current_operand_type;
  1774     this->default_variable_name.current_type = this->current_operand_type;
  1787   }
  1775   }
  1788   else {ERROR;}
  1776   else {ERROR;}
  1789   return NULL;
  1777   return NULL;
  1790 }
  1778 }
  1791 
  1779 
  1792 void *visit(XORN_operator_c *symbol)	{
  1780 void *visit(XORN_operator_c *symbol)	{
  1793   if (search_expression_type->is_binary_type(this->default_variable_name.current_type) &&
  1781   if (get_datatype_info_c::is_ANY_BIT_compatible(this->default_variable_name.current_type)) {
  1794       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1795 	BYTE_operator_result_type();
  1782 	BYTE_operator_result_type();
  1796 	XXX_operator(&(this->default_variable_name),
  1783 	XXX_operator(&(this->default_variable_name),
  1797                  // bit by bit exclusive OR !! Also seems to work with boolean types!
  1784                  // bit by bit exclusive OR !! Also seems to work with boolean types!
  1798                  search_expression_type->is_bool_type(this->current_operand_type)?" ^= !":" ^= ~",
  1785                  get_datatype_info_c::is_BOOL_compatible(this->current_operand_type)?" ^= !":" ^= ~",
  1799                  this->current_operand);
  1786                  this->current_operand);
  1800     /* the data type resulting from this operation... */
  1787     /* the data type resulting from this operation... */
  1801     this->default_variable_name.current_type = this->current_operand_type;
  1788     this->default_variable_name.current_type = this->current_operand_type;
  1802   }
  1789   }
  1803   else {ERROR;}
  1790   else {ERROR;}
  1804   return NULL;
  1791   return NULL;
  1805 }
  1792 }
  1806 
  1793 
       
  1794 
  1807 void *visit(ADD_operator_c *symbol)	{
  1795 void *visit(ADD_operator_c *symbol)	{
  1808   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1796   if (get_datatype_info_c::is_TIME_compatible      (symbol->datatype) ||
  1809       search_expression_type->is_time_type(this->current_operand_type)) {
  1797       get_datatype_info_c::is_ANY_DATE_compatible  (symbol->datatype)) {
  1810     XXX_function("__time_add", &(this->default_variable_name), this->current_operand);
  1798     XXX_function("__time_add", &(this->default_variable_name), this->current_operand);
  1811     /* the data type resulting from this operation... */
  1799     /* the data type resulting from this operation... */
  1812     this->default_variable_name.current_type = this->current_operand_type;
  1800     this->default_variable_name.current_type = this->current_operand_type;
  1813   }
  1801   } else {
  1814   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1802     NUM_operator_result_type();
  1815       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1803     XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
  1816 	NUM_operator_result_type();
       
  1817 	XXX_operator(&(this->default_variable_name), " += ", this->current_operand);
       
  1818     /* the data type resulting from this operation... */
  1804     /* the data type resulting from this operation... */
  1819     this->default_variable_name.current_type = this->current_operand_type;
  1805     this->default_variable_name.current_type = this->current_operand_type;
  1820   }
  1806   }
  1821   else {ERROR;}
       
  1822   return NULL;
  1807   return NULL;
  1823 }
  1808 }
  1824 
  1809 
  1825 void *visit(SUB_operator_c *symbol)	{
  1810 void *visit(SUB_operator_c *symbol)	{
  1826   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1811   if (get_datatype_info_c::is_TIME_compatible      (symbol->datatype) ||
  1827       search_expression_type->is_time_type(this->current_operand_type)) {
  1812       get_datatype_info_c::is_ANY_DATE_compatible  (symbol->datatype)) {
  1828     XXX_function("__time_sub", &(this->default_variable_name), this->current_operand);
  1813     XXX_function("__time_sub", &(this->default_variable_name), this->current_operand);
  1829     /* the data type resulting from this operation... */
  1814     /* the data type resulting from this operation... */
  1830     this->default_variable_name.current_type = this->current_operand_type;
  1815     this->default_variable_name.current_type = this->current_operand_type;
  1831   }
  1816   } else  {
  1832   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1817     NUM_operator_result_type();
  1833       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1818     XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
  1834 	NUM_operator_result_type();
       
  1835 	XXX_operator(&(this->default_variable_name), " -= ", this->current_operand);
       
  1836     /* the data type resulting from this operation... */
  1819     /* the data type resulting from this operation... */
  1837     this->default_variable_name.current_type = this->current_operand_type;
  1820     this->default_variable_name.current_type = this->current_operand_type;
  1838   }
  1821   }
  1839   else {ERROR;}
       
  1840   return NULL;
  1822   return NULL;
  1841 }
  1823 }
  1842 
  1824 
  1843 void *visit(MUL_operator_c *symbol)	{
  1825 void *visit(MUL_operator_c *symbol)	{
  1844   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1826   if (get_datatype_info_c::is_TIME_compatible      (symbol->datatype)) {
  1845       search_expression_type->is_integer_type(this->current_operand_type)) {
       
  1846     XXX_function("__time_mul", &(this->default_variable_name), this->current_operand);
  1827     XXX_function("__time_mul", &(this->default_variable_name), this->current_operand);
  1847     /* the data type resulting from this operation is unchanged! */
  1828     /* the data type resulting from this operation is unchanged! */
  1848   }
  1829   } else {
  1849   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1830     NUM_operator_result_type();
  1850       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
       
  1851 	NUM_operator_result_type();
       
  1852     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1831     XXX_operator(&(this->default_variable_name), " *= ", this->current_operand);
  1853     /* the data type resulting from this operation... */
  1832     /* the data type resulting from this operation... */
  1854     this->default_variable_name.current_type = this->current_operand_type;
  1833     this->default_variable_name.current_type = this->current_operand_type;
  1855   }
  1834   }
  1856   else {ERROR;}
       
  1857   return NULL;
  1835   return NULL;
  1858 }
  1836 }
  1859 
  1837 
  1860 void *visit(DIV_operator_c *symbol)	{
  1838 void *visit(DIV_operator_c *symbol)	{
  1861   if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
  1839   if (get_datatype_info_c::is_TIME_compatible      (symbol->datatype)) {
  1862       search_expression_type->is_integer_type(this->current_operand_type)) {
       
  1863     XXX_function("__time_div", &(this->default_variable_name), this->current_operand);
  1840     XXX_function("__time_div", &(this->default_variable_name), this->current_operand);
  1864     /* the data type resulting from this operation is unchanged! */
  1841     /* the data type resulting from this operation is unchanged! */
  1865   }
  1842   } else {
  1866   else if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1843     NUM_operator_result_type();
  1867       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1844     XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
  1868 	NUM_operator_result_type();
       
  1869 	XXX_operator(&(this->default_variable_name), " /= ", this->current_operand);
       
  1870     /* the data type resulting from this operation... */
  1845     /* the data type resulting from this operation... */
  1871     this->default_variable_name.current_type = this->current_operand_type;
  1846     this->default_variable_name.current_type = this->current_operand_type;
  1872     return NULL;
  1847     return NULL;
  1873   }
  1848   }
  1874   else {ERROR;}
       
  1875   return NULL;
  1849   return NULL;
  1876 }
  1850 }
  1877 
  1851 
  1878 void *visit(MOD_operator_c *symbol)	{
  1852 void *visit(MOD_operator_c *symbol)	{
  1879   if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
  1853   NUM_operator_result_type();
  1880       search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
  1854   XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1881 	NUM_operator_result_type();
  1855   /* the data type resulting from this operation... */
  1882 	XXX_operator(&(this->default_variable_name), " %= ", this->current_operand);
  1856   this->default_variable_name.current_type = this->current_operand_type;
  1883     /* the data type resulting from this operation... */
       
  1884     this->default_variable_name.current_type = this->current_operand_type;
       
  1885   }
       
  1886   else {ERROR;}
       
  1887   return NULL;
  1857   return NULL;
  1888 }
  1858 }
  1889 
  1859 
  1890 void *visit(GT_operator_c *symbol)	{CMP_operator(this->current_operand, "GT_"); return NULL;}
  1860 void *visit(GT_operator_c *symbol)	{CMP_operator(this->current_operand, "GT_"); return NULL;}
  1891 void *visit(GE_operator_c *symbol)	{CMP_operator(this->current_operand, "GE_"); return NULL;}
  1861 void *visit(GE_operator_c *symbol)	{CMP_operator(this->current_operand, "GE_"); return NULL;}