Add new get_datatype_info_c (preparing to remove search_expression_type_c)
authorMario de Sousa <msousa@fe.up.pt>
Thu, 04 Oct 2012 14:30:51 +0100
changeset 666 8ba9ec4bae50
parent 665 50fca2d3abd9
child 667 bd1360f29f15
Add new get_datatype_info_c (preparing to remove search_expression_type_c)
absyntax_utils/Makefile.am
absyntax_utils/Makefile.in
absyntax_utils/absyntax_utils.hh
absyntax_utils/get_datatype_info.cc
absyntax_utils/get_datatype_info.hh
stage3/datatype_functions.cc
stage3/datatype_functions.hh
stage3/fill_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.cc
--- a/absyntax_utils/Makefile.am	Thu Oct 04 13:12:19 2012 +0100
+++ b/absyntax_utils/Makefile.am	Thu Oct 04 14:30:51 2012 +0100
@@ -26,8 +26,5 @@
 	search_varfb_instance_type.cc \
 	search_var_instance_decl.cc \
 	spec_init_separator.cc \
-	type_initial_value.cc 
-
-#search_il_operand_type.cc 
-#search_type_code.c
-
+	type_initial_value.cc \
+	get_datatype_info.cc
--- a/absyntax_utils/Makefile.in	Thu Oct 04 13:12:19 2012 +0100
+++ b/absyntax_utils/Makefile.in	Thu Oct 04 14:30:51 2012 +0100
@@ -94,7 +94,9 @@
 	spec_init_separator.$(OBJEXT) type_initial_value.$(OBJEXT) \
 	search_varfb_instance_type.$(OBJEXT) \
 	search_var_instance_decl.$(OBJEXT) \
-	spec_init_separator.$(OBJEXT) type_initial_value.$(OBJEXT)
+	spec_init_separator.$(OBJEXT) type_initial_value.$(OBJEXT) \
+	get_datatype_info.$(OBJEXT)
+
 libabsyntax_utils_a_OBJECTS = $(am_libabsyntax_utils_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/config
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -233,7 +235,9 @@
 	search_varfb_instance_type.cc \
 	search_var_instance_decl.cc \
 	spec_init_separator.cc \
-	type_initial_value.cc 
+	type_initial_value.cc \
+	get_datatype_info.cc
+
 
 all: all-am
 
@@ -319,6 +323,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/function_call_iterator.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/function_call_param_iterator.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/function_param_iterator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_datatype_info.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_sizeof_datatype.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_var_name.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_base_type.Po@am__quote@
@@ -550,9 +555,6 @@
 	uninstall-am uninstall-libLIBRARIES
 
 
-#search_il_operand_type.cc 
-#search_type_code.c
-
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
--- a/absyntax_utils/absyntax_utils.hh	Thu Oct 04 13:12:19 2012 +0100
+++ b/absyntax_utils/absyntax_utils.hh	Thu Oct 04 14:30:51 2012 +0100
@@ -118,6 +118,7 @@
 #include "get_sizeof_datatype.hh"
 #include "search_il_label.hh"
 #include "get_var_name.hh"
+#include "get_datatype_info.hh"
 
 /***********************************************************************/
 /***********************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/absyntax_utils/get_datatype_info.cc	Thu Oct 04 14:30:51 2012 +0100
@@ -0,0 +1,583 @@
+/*
+ *  matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ *  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
+ *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * This code is made available on the understanding that it will not be
+ * used in safety-critical situations without a full and competent review.
+ */
+
+/*
+ * An IEC 61131-3 compiler.
+ *
+ * Based on the
+ * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
+ *
+ */
+
+/* Determine the characteristics of a specific data type
+ *  e.g., is it an enumeration, is it an array, is it ANY_INT, etc...
+ *
+ * The methods of this class may be passed either:
+ *  - a data type declaration symbol_c, 
+ *   OR
+ *  - the name of a data type (identifier_c)
+ *    In this case, we shall first serach for the basetype declaration using search_base_type_c, and then 
+ *    run the normal process.
+ */
+#include "absyntax_utils.hh"
+
+#include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
+
+
+
+#include <typeinfo>  // required for typeid
+
+
+
+
+
+
+static search_base_type_c search_base_type;
+
+
+
+
+bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
+  return false;
+}
+
+
+
+
+
+bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
+  if (typeid(*type_decl) == typeid(        step_c))                  {return true;}   /*         STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
+  return false;
+}
+
+
+
+
+bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  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 */
+  return false;
+}
+
+
+
+
+
+bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.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 */
+  
+  if (typeid(*type_decl) == typeid(subrange_type_declaration_c))     {return true;}   /*  subrange_type_name ':' subrange_spec_init */
+  if (typeid(*type_decl) == typeid(subrange_spec_init_c))            {return true;}   /* subrange_specification ASSIGN signed_integer */
+  if (typeid(*type_decl) == typeid(subrange_specification_c))        {return true;}   /*  integer_type_name '(' subrange')' */
+    
+  if (typeid(*type_decl) == typeid(subrange_c))                      {ERROR;}         /*  signed_integer DOTDOT signed_integer */
+  return false;
+}
+
+
+
+
+
+bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  
+  if (typeid(*type_decl) == typeid(enumerated_type_declaration_c))   {return true;}   /*  enumerated_type_name ':' enumerated_spec_init */
+  if (typeid(*type_decl) == typeid(enumerated_spec_init_c))          {return true;}   /* enumerated_specification ASSIGN enumerated_value */
+  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! */
+  
+  if (typeid(*type_decl) == typeid(enumerated_value_c))              {ERROR;}         /* enumerated_type_name '#' identifier */
+  return false;
+}
+
+
+
+
+
+bool get_datatype_info_c::is_array(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  
+  if (typeid(*type_decl) == typeid(array_type_declaration_c))        {return true;}   /*  identifier ':' array_spec_init */
+  if (typeid(*type_decl) == typeid(array_spec_init_c))               {return true;}   /* array_specification [ASSIGN array_initialization} */
+  if (typeid(*type_decl) == typeid(array_specification_c))           {return true;}   /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
+  
+  if (typeid(*type_decl) == typeid(array_subrange_list_c))           {ERROR;}         /* array_subrange_list ',' subrange */
+  if (typeid(*type_decl) == typeid(array_initial_elements_list_c))   {ERROR;}         /* array_initialization:  '[' array_initial_elements_list ']' */  /* array_initial_elements_list ',' array_initial_elements */
+  if (typeid(*type_decl) == typeid(array_initial_elements_c))        {ERROR;}         /* integer '(' [array_initial_element] ')' */
+  return false;
+}
+
+
+
+
+
+bool get_datatype_info_c::is_structure(symbol_c *type_symbol) {
+  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  
+  if (typeid(*type_decl) == typeid(structure_type_declaration_c))              {return true;}   /*  structure_type_name ':' structure_specification */
+  if (typeid(*type_decl) == typeid(initialized_structure_c))                   {return true;}   /* structure_type_name ASSIGN structure_initialization */
+  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 ';' */
+  
+  if (typeid(*type_decl) == typeid(structure_element_declaration_c))           {ERROR;}         /*  structure_element_name ':' *_spec_init */
+  if (typeid(*type_decl) == typeid(structure_element_initialization_list_c))   {ERROR;}         /* structure_initialization: '(' structure_element_initialization_list ')' */  /* structure_element_initialization_list ',' structure_element_initialization */
+  if (typeid(*type_decl) == typeid(structure_element_initialization_c))        {ERROR;}         /*  structure_element_name ASSIGN value */
+  return false;
+}
+
+
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_ELEMENTARY(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_MAGNITUDE(type_symbol))                           {return true;}
+  if (is_ANY_BIT      (type_symbol))                           {return true;}
+  if (is_ANY_STRING   (type_symbol))                           {return true;}
+  if (is_ANY_DATE     (type_symbol))                           {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEELEMENTARY(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_SAFEMAGNITUDE(type_symbol))                       {return true;}
+  if (is_ANY_SAFEBIT      (type_symbol))                       {return true;}
+  if (is_ANY_SAFESTRING   (type_symbol))                       {return true;}
+  if (is_ANY_SAFEDATE     (type_symbol))                       {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_ELEMENTARY    (type_symbol))                      {return true;}
+  if (is_ANY_SAFEELEMENTARY(type_symbol))                      {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_MAGNITUDE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(time_type_name_c))        {return true;}
+  if (is_ANY_NUM(type_symbol))                                 {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEMAGNITUDE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safetime_type_name_c))    {return true;}
+  if (is_ANY_SAFENUM(type_symbol))                             {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_MAGNITUDE    (type_symbol))                       {return true;}
+  if (is_ANY_SAFEMAGNITUDE(type_symbol))                       {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_signed_MAGNITUDE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(time_type_name_c))        {return true;}
+  if (is_ANY_signed_NUM(type_symbol))                          {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_SAFEMAGNITUDE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safetime_type_name_c))    {return true;}
+  return is_ANY_signed_SAFENUM(type_symbol);
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_MAGNITUDE_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_signed_MAGNITUDE    (type_symbol))                {return true;}
+  if (is_ANY_signed_SAFEMAGNITUDE(type_symbol))                {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_NUM(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_REAL(type_symbol))                                {return true;}
+  if (is_ANY_INT (type_symbol))                                {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFENUM(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_SAFEREAL(type_symbol))                            {return true;}
+  if (is_ANY_SAFEINT (type_symbol))                            {return true;}
+}
+
+
+bool get_datatype_info_c::is_ANY_NUM_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_NUM    (type_symbol))                             {return true;}
+  if (is_ANY_SAFENUM(type_symbol))                             {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_signed_NUM(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_REAL      (type_symbol))                          {return true;}
+  if (is_ANY_signed_INT(type_symbol))                          {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_SAFENUM(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_SAFEREAL      (type_symbol))                      {return true;}
+  if (is_ANY_signed_SAFEINT(type_symbol))                      {return true;}
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_NUM_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_signed_NUM    (type_symbol))                      {return true;}
+  if (is_ANY_signed_SAFENUM(type_symbol))                      {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_DATE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(date_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(tod_type_name_c))         {return true;}
+  if (typeid(*type_symbol) == typeid(dt_type_name_c))          {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEDATE(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safedate_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safetod_type_name_c))     {return true;}
+  if (typeid(*type_symbol) == typeid(safedt_type_name_c))      {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_DATE_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_DATE    (type_symbol))                            {return true;}
+  if (is_ANY_SAFEDATE(type_symbol))                            {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_STRING(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(string_type_name_c))      {return true;}
+  if (typeid(*type_symbol) == typeid(wstring_type_name_c))     {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFESTRING(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safestring_type_name_c))  {return true;}
+  if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_STRING_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_STRING    (type_symbol))                          {return true;}
+  if (is_ANY_SAFESTRING(type_symbol))                          {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_INT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_signed_INT  (type_symbol))                        {return true;}
+  if (is_ANY_unsigned_INT(type_symbol))                        {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEINT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_signed_SAFEINT  (type_symbol))                    {return true;}
+  if (is_ANY_unsigned_SAFEINT(type_symbol))                    {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_INT_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_INT    (type_symbol))                             {return true;}
+  if (is_ANY_SAFEINT(type_symbol))                             {return true;}
+  return false;
+}
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_signed_INT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(sint_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(int_type_name_c))         {return true;}
+  if (typeid(*type_symbol) == typeid(dint_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(lint_type_name_c))        {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_SAFEINT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safesint_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safeint_type_name_c))     {return true;}
+  if (typeid(*type_symbol) == typeid(safedint_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safelint_type_name_c))    {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_signed_INT_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_signed_INT    (type_symbol))                      {return true;}
+  if (is_ANY_signed_SAFEINT(type_symbol))                      {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_unsigned_INT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(usint_type_name_c))       {return true;}
+  if (typeid(*type_symbol) == typeid(uint_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(udint_type_name_c))       {return true;}
+  if (typeid(*type_symbol) == typeid(ulint_type_name_c))       {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_unsigned_SAFEINT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safeusint_type_name_c))   {return true;}
+  if (typeid(*type_symbol) == typeid(safeuint_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safeudint_type_name_c))   {return true;}
+  if (typeid(*type_symbol) == typeid(safeulint_type_name_c))   {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_unsigned_INT_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_unsigned_INT    (type_symbol))                    {return true;}
+  if (is_ANY_unsigned_SAFEINT(type_symbol))                    {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_REAL(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(real_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(lreal_type_name_c))       {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEREAL(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safereal_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safelreal_type_name_c))   {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_REAL_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_REAL    (type_symbol))                            {return true;}
+  if (is_ANY_SAFEREAL(type_symbol))                            {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_nBIT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(byte_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(word_type_name_c))        {return true;}
+  if (typeid(*type_symbol) == typeid(dword_type_name_c))       {return true;}
+  if (typeid(*type_symbol) == typeid(lword_type_name_c))       {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEnBIT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safebyte_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safeword_type_name_c))    {return true;}
+  if (typeid(*type_symbol) == typeid(safedword_type_name_c))   {return true;}
+  if (typeid(*type_symbol) == typeid(safelword_type_name_c))   {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_nBIT_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_nBIT    (type_symbol))                            {return true;}
+  if (is_ANY_SAFEnBIT(type_symbol))                            {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_BOOL(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(bool_type_name_c))        {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_SAFEBOOL(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (typeid(*type_symbol) == typeid(safebool_type_name_c))    {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_BOOL_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_BOOL    (type_symbol))                                {return true;}
+  if (is_SAFEBOOL(type_symbol))                                {return true;}
+  return false;
+}
+
+
+
+
+
+
+
+
+
+bool get_datatype_info_c::is_ANY_BIT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_BOOL    (type_symbol))                                {return true;}
+  if (is_ANY_nBIT(type_symbol))                                {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_SAFEBIT(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_SAFEBOOL    (type_symbol))                            {return true;}
+  if (is_ANY_SAFEnBIT(type_symbol))                            {return true;}
+  return false;
+}
+
+
+bool get_datatype_info_c::is_ANY_BIT_compatible(symbol_c *type_symbol) {
+  if (type_symbol == NULL)                                     {return false;}
+  if (is_ANY_BIT    (type_symbol))                             {return true;}
+  if (is_ANY_SAFEBIT(type_symbol))                             {return true;}
+  return false;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/absyntax_utils/get_datatype_info.hh	Thu Oct 04 14:30:51 2012 +0100
@@ -0,0 +1,126 @@
+/*
+ *  matiec - a compiler for the programming languages defined in IEC 61131-3
+ *
+ *  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * This code is made available on the understanding that it will not be
+ * used in safety-critical situations without a full and competent review.
+ */
+
+/*
+ * An IEC 61131-3 compiler.
+ *
+ * Based on the
+ * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
+ *
+ */
+
+/* Determine the characteristics of a specific data type
+ *  e.g., is it an enumeration, is it an array, is it ANY_INT, etc...
+ *
+ * The methods of this class may be passed either:
+ *  - a data type declaration symbol_c, 
+ *   OR
+ *  - the name of a data type (identifier_c)
+ *    In this case, we shall first serach for the basetype declaration using search_base_type_c, and then 
+ *    run the normal process.
+ */
+#include "absyntax_utils.hh"
+
+#include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
+
+
+
+
+
+
+class get_datatype_info_c { 
+
+
+  private: // this is a purely static class. No need for constructors!
+     get_datatype_info_c(void) {};
+    ~get_datatype_info_c(void) {};
+
+ 
+  public:
+    static bool is_sfc_initstep                    (symbol_c *type_symbol);
+    static bool is_sfc_step                        (symbol_c *type_symbol);
+    static bool is_function_block                  (symbol_c *type_symbol);
+    static bool is_subrange                        (symbol_c *type_symbol);
+    static bool is_enumerated                      (symbol_c *type_symbol);
+    static bool is_array                           (symbol_c *type_symbol);
+    static bool is_structure                       (symbol_c *type_symbol);
+
+  
+  
+    static bool is_ANY_ELEMENTARY                  (symbol_c *type_symbol);
+    static bool is_ANY_SAFEELEMENTARY              (symbol_c *type_symbol);
+    static bool is_ANY_ELEMENTARY_compatible       (symbol_c *type_symbol);
+
+    static bool is_ANY_MAGNITUDE                   (symbol_c *type_symbol);
+    static bool is_ANY_SAFEMAGNITUDE               (symbol_c *type_symbol);
+    static bool is_ANY_MAGNITUDE_compatible        (symbol_c *type_symbol);
+
+    static bool is_ANY_signed_MAGNITUDE            (symbol_c *type_symbol);
+    static bool is_ANY_signed_SAFEMAGNITUDE        (symbol_c *type_symbol);
+    static bool is_ANY_signed_MAGNITUDE_compatible (symbol_c *type_symbol);
+
+    static bool is_ANY_NUM                         (symbol_c *type_symbol);
+    static bool is_ANY_SAFENUM                     (symbol_c *type_symbol);
+    static bool is_ANY_NUM_compatible              (symbol_c *type_symbol);
+
+    static bool is_ANY_signed_NUM                  (symbol_c *type_symbol);
+    static bool is_ANY_signed_SAFENUM              (symbol_c *type_symbol);
+    static bool is_ANY_signed_NUM_compatible       (symbol_c *type_symbol);
+
+    static bool is_ANY_DATE                        (symbol_c *type_symbol);
+    static bool is_ANY_SAFEDATE                    (symbol_c *type_symbol);
+    static bool is_ANY_DATE_compatible             (symbol_c *type_symbol);
+
+    static bool is_ANY_STRING                      (symbol_c *type_symbol);
+    static bool is_ANY_SAFESTRING                  (symbol_c *type_symbol);
+    static bool is_ANY_STRING_compatible           (symbol_c *type_symbol);
+
+    static bool is_ANY_INT                         (symbol_c *type_symbol);
+    static bool is_ANY_SAFEINT                     (symbol_c *type_symbol);
+    static bool is_ANY_INT_compatible              (symbol_c *type_symbol);
+
+    static bool is_ANY_signed_INT                  (symbol_c *type_symbol);
+    static bool is_ANY_signed_SAFEINT              (symbol_c *type_symbol);
+    static bool is_ANY_signed_INT_compatible       (symbol_c *type_symbol);
+
+    static bool is_ANY_unsigned_INT                (symbol_c *type_symbol);
+    static bool is_ANY_unsigned_SAFEINT            (symbol_c *type_symbol);
+    static bool is_ANY_unsigned_INT_compatible     (symbol_c *type_symbol);
+
+    static bool is_ANY_REAL                        (symbol_c *type_symbol);
+    static bool is_ANY_SAFEREAL                    (symbol_c *type_symbol);
+    static bool is_ANY_REAL_compatible             (symbol_c *type_symbol);
+
+    static bool is_ANY_nBIT                        (symbol_c *type_symbol);
+    static bool is_ANY_SAFEnBIT                    (symbol_c *type_symbol);
+    static bool is_ANY_nBIT_compatible             (symbol_c *type_symbol);
+
+    static bool is_BOOL                            (symbol_c *type_symbol);
+    static bool is_SAFEBOOL                        (symbol_c *type_symbol);
+    static bool is_BOOL_compatible                 (symbol_c *type_symbol);
+
+    static bool is_ANY_BIT                         (symbol_c *type_symbol);
+    static bool is_ANY_SAFEBIT                     (symbol_c *type_symbol);
+    static bool is_ANY_BIT_compatible              (symbol_c *type_symbol);
+};
+
--- a/stage3/datatype_functions.cc	Thu Oct 04 13:12:19 2012 +0100
+++ b/stage3/datatype_functions.cc	Thu Oct 04 14:30:51 2012 +0100
@@ -461,319 +461,6 @@
 
 
 
-/* A helper function... */
-bool is_ANY_ELEMENTARY_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  return is_ANY_MAGNITUDE_type(type_symbol)
-      || is_ANY_BIT_type      (type_symbol)
-      || is_ANY_STRING_type   (type_symbol)
-      || is_ANY_DATE_type     (type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_SAFEELEMENTARY_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  return is_ANY_SAFEMAGNITUDE_type(type_symbol)
-      || is_ANY_SAFEBIT_type      (type_symbol)
-      || is_ANY_SAFESTRING_type   (type_symbol)
-      || is_ANY_SAFEDATE_type     (type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  /* NOTE: doing
-   *          return is_ANY_SAFEELEMENTARY_type() || is_ANY_ELEMENTARY_type()
-   *       is incorrect, as the literals would never be considered compatible...
-   */
-  return is_ANY_MAGNITUDE_compatible(type_symbol)
-      || is_ANY_BIT_compatible      (type_symbol)
-      || is_ANY_STRING_compatible   (type_symbol)
-      || is_ANY_DATE_compatible     (type_symbol);
-}
-
-
-/* A helper function... */
-bool is_ANY_MAGNITUDE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;}
-  return is_ANY_NUM_type(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_signed_MAGNITUDE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;}
-  return is_ANY_signed_NUM_type(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_SAFEMAGNITUDE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;}
-  return is_ANY_SAFENUM_type(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_signed_SAFEMAGNITUDE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;}
-  return is_ANY_signed_SAFENUM_type(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_MAGNITUDE_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFEMAGNITUDE_type(type_symbol))              {return true;}
-  return is_ANY_NUM_compatible(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_signed_MAGNITUDE_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_signed_MAGNITUDE_type    (type_symbol))       {return true;}
-  if (is_ANY_signed_SAFEMAGNITUDE_type(type_symbol))       {return true;}
-  return is_ANY_signed_NUM_compatible(type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_NUM_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_REAL_type(type_symbol))                       {return true;}
-  if (is_ANY_INT_type(type_symbol))                        {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_signed_NUM_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_REAL_type(type_symbol))                       {return true;}
-  if (is_ANY_signed_INT_type(type_symbol))                 {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFENUM_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  return is_ANY_SAFEREAL_type(type_symbol)
-      || is_ANY_SAFEINT_type (type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_signed_SAFENUM_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  return is_ANY_SAFEREAL_type(type_symbol)
-      || is_ANY_signed_SAFEINT_type (type_symbol);
-}
-
-/* A helper function... */
-bool is_ANY_NUM_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_REAL_compatible(type_symbol))                       {return true;}
-  if (is_ANY_INT_compatible(type_symbol))                        {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_signed_NUM_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_REAL_compatible(type_symbol))                       {return true;}
-  if (is_ANY_signed_INT_compatible(type_symbol))                 {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_DATE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(tod_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(dt_type_name_c))   {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFEDATE_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(safetod_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safedt_type_name_c))   {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_DATE_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_DATE_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFEDATE_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_STRING_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFESTRING_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_STRING_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_STRING_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFESTRING_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_INT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(sint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(int_type_name_c))   {return true;}
-  if (typeid(*type_symbol) == typeid(dint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(lint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(uint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_signed_INT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(sint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(int_type_name_c))   {return true;}
-  if (typeid(*type_symbol) == typeid(dint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(lint_type_name_c))  {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_signed_SAFEINT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safesint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safeint_type_name_c))   {return true;}
-  if (typeid(*type_symbol) == typeid(safedint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safelint_type_name_c))  {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFEINT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safesint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safeint_type_name_c))   {return true;}
-  if (typeid(*type_symbol) == typeid(safedint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safelint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safeusint_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(safeuint_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safeudint_type_name_c)) {return true;}
-  if (typeid(*type_symbol) == typeid(safeulint_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_signed_INT_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_signed_INT_type    (type_symbol))              {return true;}
-  if (is_ANY_signed_SAFEINT_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_INT_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_INT_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFEINT_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_REAL_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(real_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFEREAL_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safereal_type_name_c))  {return true;}
-  if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_REAL_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_REAL_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFEREAL_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_BIT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(bool_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(byte_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(word_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(dword_type_name_c))    {return true;}
-  if (typeid(*type_symbol) == typeid(lword_type_name_c))    {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_SAFEBIT_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safebool_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(safebyte_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(safeword_type_name_c))     {return true;}
-  if (typeid(*type_symbol) == typeid(safedword_type_name_c))    {return true;}
-  if (typeid(*type_symbol) == typeid(safelword_type_name_c))    {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_BIT_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_ANY_BIT_type    (type_symbol))              {return true;}
-  if (is_ANY_SAFEBIT_type(type_symbol))              {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_BOOL_type(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(bool_type_name_c))      {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_SAFEBOOL_type(symbol_c *type_symbol){
-  if (type_symbol == NULL) {return false;}
-  if (typeid(*type_symbol) == typeid(safebool_type_name_c))  {return true;}
-  return false;
-}
-
-/* A helper function... */
-bool is_ANY_BOOL_compatible(symbol_c *type_symbol) {
-  if (type_symbol == NULL) {return false;}
-  if (is_BOOL_type    (type_symbol))              {return true;}
-  if (is_SAFEBOOL_type(type_symbol))              {return true;}
-  return false;
-}
-
-
 
 
 
@@ -785,7 +472,7 @@
   if (typeid(*second_type) == typeid(invalid_type_name_c))
       return false;
     
-  if (is_ANY_ELEMENTARY_type(first_type)) {
+  if (get_datatype_info_c::is_ANY_ELEMENTARY(first_type)) {
       if (typeid(*first_type) == typeid(*second_type))
           return true;
   } else   /* ANY_DERIVED */
--- a/stage3/datatype_functions.hh	Thu Oct 04 13:12:19 2012 +0100
+++ b/stage3/datatype_functions.hh	Thu Oct 04 14:30:51 2012 +0100
@@ -161,54 +161,6 @@
 
 
 
-/* A helper function... */
-bool is_ANY_ELEMENTARY_type                (symbol_c *type_symbol);
-bool is_ANY_SAFEELEMENTARY_type            (symbol_c *type_symbol);
-bool is_ANY_ELEMENTARY_compatible          (symbol_c *type_symbol);
-
-bool is_ANY_MAGNITUDE_type                 (symbol_c *type_symbol);
-bool is_ANY_SAFEMAGNITUDE_type             (symbol_c *type_symbol);
-bool is_ANY_MAGNITUDE_compatible           (symbol_c *type_symbol);
-
-bool is_ANY_signed_MAGNITUDE_type          (symbol_c *type_symbol);
-bool is_ANY_signed_SAFEMAGNITUDE_type      (symbol_c *type_symbol);
-bool is_ANY_signed_MAGNITUDE_compatible    (symbol_c *type_symbol);
-
-bool is_ANY_DATE_type                      (symbol_c *type_symbol);
-bool is_ANY_SAFEDATE_type                  (symbol_c *type_symbol);
-bool is_ANY_DATE_compatible                (symbol_c *type_symbol);
-
-bool is_ANY_STRING_type                    (symbol_c *type_symbol);
-bool is_ANY_SAFESTRING_type                (symbol_c *type_symbol);
-bool is_ANY_STRING_compatible              (symbol_c *type_symbol);
-
-bool is_ANY_INT_type                       (symbol_c *type_symbol);
-bool is_ANY_SAFEINT_type                   (symbol_c *type_symbol);
-bool is_ANY_INT_compatible                 (symbol_c *type_symbol);
-
-bool is_ANY_signed_INT_type                (symbol_c *type_symbol);
-bool is_ANY_signed_SAFEINT_type            (symbol_c *type_symbol);
-bool is_ANY_signed_INT_compatible          (symbol_c *type_symbol);
-
-bool is_ANY_REAL_type                      (symbol_c *type_symbol);
-bool is_ANY_SAFEREAL_type                  (symbol_c *type_symbol);
-bool is_ANY_REAL_compatible                (symbol_c *type_symbol);
-
-bool is_ANY_NUM_type                       (symbol_c *type_symbol);
-bool is_ANY_SAFENUM_type                   (symbol_c *type_symbol);
-bool is_ANY_NUM_compatible                 (symbol_c *type_symbol);
-
-bool is_ANY_signed_NUM_type                (symbol_c *type_symbol);
-bool is_ANY_signed_SAFENUM_type            (symbol_c *type_symbol);
-bool is_ANY_signed_NUM_compatible          (symbol_c *type_symbol);
-
-bool is_ANY_BIT_type                       (symbol_c *type_symbol);
-bool is_ANY_SAFEBIT_type                   (symbol_c *type_symbol);
-bool is_ANY_BIT_compatible                 (symbol_c *type_symbol);
-
-bool is_BOOL_type                          (symbol_c *type_symbol);
-bool is_SAFEBOOL_type                      (symbol_c *type_symbol);
-bool is_ANY_BOOL_compatible                (symbol_c *type_symbol);
 
 
 bool is_type_equal(symbol_c *first_type, symbol_c *second_type);
--- a/stage3/fill_candidate_datatypes.cc	Thu Oct 04 13:12:19 2012 +0100
+++ b/stage3/fill_candidate_datatypes.cc	Thu Oct 04 14:30:51 2012 +0100
@@ -1175,7 +1175,7 @@
 
 void *fill_candidate_datatypes_c::visit(LDN_operator_c *symbol) {
 	for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) {
-		if      (is_ANY_BIT_compatible(il_operand->candidate_datatypes[i]))
+		if      (get_datatype_info_c::is_ANY_BIT_compatible(il_operand->candidate_datatypes[i]))
 			add_datatype_to_candidate_list(symbol, il_operand->candidate_datatypes[i]);
 	}
 	if (debug) std::cout << "LDN [" << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
@@ -1206,7 +1206,7 @@
 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
 			operand_type = il_operand->candidate_datatypes[j];
-			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BIT_compatible(operand_type))
+			if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_ANY_BIT_compatible(operand_type))
 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
 		}
 	}
@@ -1223,7 +1223,7 @@
 	 */
 	if (NULL == prev_il_instruction) return NULL;
 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
-		if (is_ANY_BIT_compatible(prev_il_instruction->candidate_datatypes[i]))
+		if (get_datatype_info_c::is_ANY_BIT_compatible(prev_il_instruction->candidate_datatypes[i]))
 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
 	}
 	if (debug) std::cout <<  "NOT_operator [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
@@ -1244,7 +1244,7 @@
 			 * the prev_instruction_type MUST be BOOL compatible.
 			 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check!
 			 */
-			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
+			if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type))
 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
 		}
 	}
@@ -1266,7 +1266,7 @@
 			 * the prev_instruction_type MUST be BOOL compatible.
 			 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check!
 			 */
-			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
+			if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type))
 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
 		}
 	}
@@ -1309,7 +1309,7 @@
 void *fill_candidate_datatypes_c::handle_conditional_il_flow_control_operator(symbol_c *symbol) {
 	if (NULL == prev_il_instruction) return NULL;
 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
-		if (is_ANY_BOOL_compatible(prev_il_instruction->candidate_datatypes[i]))
+		if (get_datatype_info_c::is_BOOL_compatible(prev_il_instruction->candidate_datatypes[i]))
 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
 	}
 	return NULL;
@@ -1395,7 +1395,7 @@
    */
 	symbol->exp->accept(*this);
 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
-		if (is_ANY_signed_MAGNITUDE_compatible(symbol->exp->candidate_datatypes[i]))
+		if (get_datatype_info_c::is_ANY_signed_MAGNITUDE_compatible(symbol->exp->candidate_datatypes[i]))
 			add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]);
 	}
 	if (debug) std::cout << "neg [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
@@ -1406,7 +1406,7 @@
 void *fill_candidate_datatypes_c::visit(not_expression_c *symbol) {
 	symbol->exp->accept(*this);
 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
-		if      (is_ANY_BIT_compatible(symbol->exp->candidate_datatypes[i]))
+		if      (get_datatype_info_c::is_ANY_BIT_compatible(symbol->exp->candidate_datatypes[i]))
 			add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]);
 	}
 	if (debug) std::cout << "not [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
--- a/stage3/narrow_candidate_datatypes.cc	Thu Oct 04 13:12:19 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Thu Oct 04 14:30:51 2012 +0100
@@ -481,7 +481,7 @@
 void *narrow_candidate_datatypes_c::visit(subscript_list_c *symbol) {
 	for (int i = 0; i < symbol->n; i++) {
 		for (unsigned int k = 0; k < symbol->elements[i]->candidate_datatypes.size(); k++) {
-			if (is_ANY_INT_type(symbol->elements[i]->candidate_datatypes[k]))
+			if (get_datatype_info_c::is_ANY_INT(symbol->elements[i]->candidate_datatypes[k]))
 				symbol->elements[i]->datatype = symbol->elements[i]->candidate_datatypes[k];
 		}
 		symbol->elements[i]->accept(*this);
@@ -1010,7 +1010,7 @@
 	/* if the next IL instructions needs us to provide a datatype other than a bool, 
 	 * then we have an internal compiler error - most likely in fill_candidate_datatypes_c 
 	 */
-	if ((NULL != symbol->datatype) && (!is_ANY_BOOL_compatible(symbol->datatype))) ERROR;
+	if ((NULL != symbol->datatype) && (!get_datatype_info_c::is_BOOL_compatible(symbol->datatype))) ERROR;
 	if (symbol->candidate_datatypes.size() > 1) ERROR;
 
 	/* NOTE: If there is no IL instruction following this CALC, CALCN, JMPC, JMPC, ..., instruction,
@@ -1019,7 +1019,7 @@
 	 */
 	if (symbol->candidate_datatypes.size() == 0)    symbol->datatype = NULL;
 	else    symbol->datatype = symbol->candidate_datatypes[0]; /* i.e. a bool_type_name_c! */
-	if ((NULL != symbol->datatype) && (!is_ANY_BOOL_compatible(symbol->datatype))) ERROR;
+	if ((NULL != symbol->datatype) && (!get_datatype_info_c::is_BOOL_compatible(symbol->datatype))) ERROR;
 
 	/* set the required datatype of the previous IL instruction, i.e. a bool_type_name_c! */
 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
@@ -1079,7 +1079,7 @@
 				l_expr->datatype = l_type;
 				r_expr->datatype = r_type;
 				count ++;
-			} else if ((l_type == r_type) && search_base_type.type_is_enumerated(l_type) && is_ANY_BOOL_compatible(symbol->datatype)) {
+			} else if ((l_type == r_type) && search_base_type.type_is_enumerated(l_type) && get_datatype_info_c::is_BOOL_compatible(symbol->datatype)) {
 				if (NULL != deprecated_operation)  *deprecated_operation = false;
 				l_expr->datatype = l_type;
 				r_expr->datatype = r_type;
@@ -1205,7 +1205,7 @@
 
 void *narrow_candidate_datatypes_c::visit(if_statement_c *symbol) {
 	for(unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
-		if (is_ANY_BOOL_compatible(symbol->expression->candidate_datatypes[i]))
+		if (get_datatype_info_c::is_BOOL_compatible(symbol->expression->candidate_datatypes[i]))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
 	symbol->expression->accept(*this);
@@ -1221,7 +1221,7 @@
 
 void *narrow_candidate_datatypes_c::visit(elseif_statement_c *symbol) {
 	for (unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
-		if (is_ANY_BOOL_compatible(symbol->expression->candidate_datatypes[i]))
+		if (get_datatype_info_c::is_BOOL_compatible(symbol->expression->candidate_datatypes[i]))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
 	symbol->expression->accept(*this);
@@ -1234,7 +1234,7 @@
 // SYM_REF3(case_statement_c, expression, case_element_list, statement_list)
 void *narrow_candidate_datatypes_c::visit(case_statement_c *symbol) {
 	for (unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
-		if ((is_ANY_INT_type(symbol->expression->candidate_datatypes[i]))
+		if ((get_datatype_info_c::is_ANY_INT(symbol->expression->candidate_datatypes[i]))
 				 || (search_base_type.type_is_enumerated(symbol->expression->candidate_datatypes[i])))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
@@ -1287,7 +1287,7 @@
 void *narrow_candidate_datatypes_c::visit(for_statement_c *symbol) {
 	/* Control variable */
 	for(unsigned int i = 0; i < symbol->control_variable->candidate_datatypes.size(); i++) {
-		if (is_ANY_INT_type(symbol->control_variable->candidate_datatypes[i])) {
+		if (get_datatype_info_c::is_ANY_INT(symbol->control_variable->candidate_datatypes[i])) {
 			symbol->control_variable->datatype = symbol->control_variable->candidate_datatypes[i];
 		}
 	}
@@ -1295,7 +1295,7 @@
 	/* BEG expression */
 	for(unsigned int i = 0; i < symbol->beg_expression->candidate_datatypes.size(); i++) {
 		if (is_type_equal(symbol->control_variable->datatype,symbol->beg_expression->candidate_datatypes[i]) &&
-				is_ANY_INT_type(symbol->beg_expression->candidate_datatypes[i])) {
+				get_datatype_info_c::is_ANY_INT(symbol->beg_expression->candidate_datatypes[i])) {
 			symbol->beg_expression->datatype = symbol->beg_expression->candidate_datatypes[i];
 		}
 	}
@@ -1303,7 +1303,7 @@
 	/* END expression */
 	for(unsigned int i = 0; i < symbol->end_expression->candidate_datatypes.size(); i++) {
 		if (is_type_equal(symbol->control_variable->datatype,symbol->end_expression->candidate_datatypes[i]) &&
-				is_ANY_INT_type(symbol->end_expression->candidate_datatypes[i])) {
+				get_datatype_info_c::is_ANY_INT(symbol->end_expression->candidate_datatypes[i])) {
 			symbol->end_expression->datatype = symbol->end_expression->candidate_datatypes[i];
 		}
 	}
@@ -1312,7 +1312,7 @@
 	if (NULL != symbol->by_expression) {
 		for(unsigned int i = 0; i < symbol->by_expression->candidate_datatypes.size(); i++) {
 			if (is_type_equal(symbol->control_variable->datatype,symbol->by_expression->candidate_datatypes[i]) &&
-					is_ANY_INT_type(symbol->by_expression->candidate_datatypes[i])) {
+					get_datatype_info_c::is_ANY_INT(symbol->by_expression->candidate_datatypes[i])) {
 				symbol->by_expression->datatype = symbol->by_expression->candidate_datatypes[i];
 			}
 		}
@@ -1325,7 +1325,7 @@
 
 void *narrow_candidate_datatypes_c::visit(while_statement_c *symbol) {
 	for (unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
-		if(is_BOOL_type(symbol->expression->candidate_datatypes[i]))
+		if(get_datatype_info_c::is_BOOL(symbol->expression->candidate_datatypes[i]))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
 	symbol->expression->accept(*this);
@@ -1336,7 +1336,7 @@
 
 void *narrow_candidate_datatypes_c::visit(repeat_statement_c *symbol) {
 	for (unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
-		if(is_BOOL_type(symbol->expression->candidate_datatypes[i]))
+		if(get_datatype_info_c::is_BOOL(symbol->expression->candidate_datatypes[i]))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
 	symbol->expression->accept(*this);