absyntax_utils/get_datatype_info.cc
changeset 832 8cd104e483c6
parent 778 44e02a88f1e7
child 858 c5f145364a4f
equal deleted inserted replaced
831:691e1cc38d3a 832:8cd104e483c6
   258 
   258 
   259 
   259 
   260 
   260 
   261 bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) {
   261 bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) {
   262   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   262   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
       
   263   if (NULL == type_decl)                                             {return false;}
   263   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   264   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   264   return false;
   265   return false;
   265 }
   266 }
   266 
   267 
   267 
   268 
   268 
   269 
   269 
   270 
   270 
   271 
   271 bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) {
   272 bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) {
   272   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   273   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
       
   274   if (NULL == type_decl)                                             {return false;}
   273   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   275   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   274   if (typeid(*type_decl) == typeid(        step_c))                  {return true;}   /*         STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   276   if (typeid(*type_decl) == typeid(        step_c))                  {return true;}   /*         STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   275   return false;
   277   return false;
   276 }
   278 }
   277 
   279 
   278 
   280 
   279 
   281 
   280 
   282 
   281 bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) {
   283 bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) {
   282   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   284   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
       
   285   if (NULL == type_decl)                                             {return false;}
   283   if (typeid(*type_decl) == typeid(function_block_declaration_c))    {return true;}   /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
   286   if (typeid(*type_decl) == typeid(function_block_declaration_c))    {return true;}   /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
   284   return false;
   287   return false;
   285 }
   288 }
   286 
   289 
   287 
   290 
   288 
   291 
   289 
   292 
   290 
   293 
   291 bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) {
   294 bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) {
   292   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); /* NOTE: will work correctly once we update the way search_base_type_c works, by adding a new search_effective_type:c */
   295   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); /* NOTE: will work correctly once we update the way search_base_type_c works, by adding a new search_effective_type:c */
       
   296   if (NULL == type_decl)                                             {return false;}
   293   
   297   
   294   if (typeid(*type_decl) == typeid(subrange_type_declaration_c))     {return true;}   /*  subrange_type_name ':' subrange_spec_init */
   298   if (typeid(*type_decl) == typeid(subrange_type_declaration_c))     {return true;}   /*  subrange_type_name ':' subrange_spec_init */
   295   if (typeid(*type_decl) == typeid(subrange_spec_init_c))            {return true;}   /* subrange_specification ASSIGN signed_integer */
   299   if (typeid(*type_decl) == typeid(subrange_spec_init_c))            {return true;}   /* subrange_specification ASSIGN signed_integer */
   296   if (typeid(*type_decl) == typeid(subrange_specification_c))        {return true;}   /*  integer_type_name '(' subrange')' */
   300   if (typeid(*type_decl) == typeid(subrange_specification_c))        {return true;}   /*  integer_type_name '(' subrange')' */
   297     
   301     
   303 
   307 
   304 
   308 
   305 
   309 
   306 bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) {
   310 bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) {
   307   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   311   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
       
   312   if (NULL == type_decl)                                             {return false;}
   308   
   313   
   309   if (typeid(*type_decl) == typeid(enumerated_type_declaration_c))   {return true;}   /*  enumerated_type_name ':' enumerated_spec_init */
   314   if (typeid(*type_decl) == typeid(enumerated_type_declaration_c))   {return true;}   /*  enumerated_type_name ':' enumerated_spec_init */
   310   if (typeid(*type_decl) == typeid(enumerated_spec_init_c))          {return true;}   /* enumerated_specification ASSIGN enumerated_value */
   315   if (typeid(*type_decl) == typeid(enumerated_spec_init_c))          {return true;}   /* enumerated_specification ASSIGN enumerated_value */
   311   if (typeid(*type_decl) == typeid(enumerated_value_list_c))         {return true;}   /* enumerated_value_list ',' enumerated_value */        /* once we change the way we handle enums, this will probably become an ERROR! */
   316   if (typeid(*type_decl) == typeid(enumerated_value_list_c))         {return true;}   /* enumerated_value_list ',' enumerated_value */        /* once we change the way we handle enums, this will probably become an ERROR! */
   312   
   317   
   318 
   323 
   319 
   324 
   320 
   325 
   321 bool get_datatype_info_c::is_array(symbol_c *type_symbol) {
   326 bool get_datatype_info_c::is_array(symbol_c *type_symbol) {
   322   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   327   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
       
   328   if (NULL == type_decl)                                             {return false;}
   323   
   329   
   324   if (typeid(*type_decl) == typeid(array_type_declaration_c))        {return true;}   /*  identifier ':' array_spec_init */
   330   if (typeid(*type_decl) == typeid(array_type_declaration_c))        {return true;}   /*  identifier ':' array_spec_init */
   325   if (typeid(*type_decl) == typeid(array_spec_init_c))               {return true;}   /* array_specification [ASSIGN array_initialization} */
   331   if (typeid(*type_decl) == typeid(array_spec_init_c))               {return true;}   /* array_specification [ASSIGN array_initialization} */
   326   if (typeid(*type_decl) == typeid(array_specification_c))           {return true;}   /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
   332   if (typeid(*type_decl) == typeid(array_specification_c))           {return true;}   /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
   327   
   333   
   335 
   341 
   336 
   342 
   337 
   343 
   338 bool get_datatype_info_c::is_structure(symbol_c *type_symbol) {
   344 bool get_datatype_info_c::is_structure(symbol_c *type_symbol) {
   339   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   345   symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
       
   346   if (NULL == type_decl)                                                       {return false;}
   340   
   347   
   341   if (typeid(*type_decl) == typeid(structure_type_declaration_c))              {return true;}   /*  structure_type_name ':' structure_specification */
   348   if (typeid(*type_decl) == typeid(structure_type_declaration_c))              {return true;}   /*  structure_type_name ':' structure_specification */
   342   if (typeid(*type_decl) == typeid(initialized_structure_c))                   {return true;}   /* structure_type_name ASSIGN structure_initialization */
   349   if (typeid(*type_decl) == typeid(initialized_structure_c))                   {return true;}   /* structure_type_name ASSIGN structure_initialization */
   343   if (typeid(*type_decl) == typeid(structure_element_declaration_list_c))      {return true;}   /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */ /* structure_element_declaration_list structure_element_declaration ';' */
   350   if (typeid(*type_decl) == typeid(structure_element_declaration_list_c))      {return true;}   /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */ /* structure_element_declaration_list structure_element_declaration ';' */
   344   
   351