--- a/stage3/datatype_functions.cc Tue Feb 07 17:40:19 2012 +0000
+++ b/stage3/datatype_functions.cc Tue Feb 07 17:45:17 2012 +0000
@@ -25,6 +25,26 @@
#include "datatype_functions.hh"
#include "../absyntax_utils/absyntax_utils.hh"
+
+
+
+
+elementary_type_c *elementary_type_c::singleton = NULL;
+
+const char *elementary_type_c::to_string(symbol_c *symbol) {
+ if (NULL == singleton) singleton = new elementary_type_c;
+ if (NULL == singleton) ERROR;
+ const char *res = (const char *)symbol->accept(*singleton);
+ if (NULL == res) {
+ int i = 1;
+ }
+ return res;
+}
+
+
+
+
+
/*
* 2.5.1.5.6 Functions of time data types
* Table 30 - page 64
--- a/stage3/datatype_functions.hh Tue Feb 07 17:40:19 2012 +0000
+++ b/stage3/datatype_functions.hh Tue Feb 07 17:45:17 2012 +0000
@@ -28,6 +28,79 @@
#include "../absyntax/visitor.hh"
#include <typeinfo>
+
+
+
+/* A small helper class, to transform elementary data type to string.
+ * this allows us to generate more relevant error messages...
+ */
+
+class elementary_type_c: public null_visitor_c {
+ protected:
+ elementary_type_c(void) {};
+ ~elementary_type_c(void) {};
+
+ private:
+ /* singleton class! */
+ static elementary_type_c *singleton;
+
+ public:
+ static const char * to_string(symbol_c *symbol);
+
+
+ /***********************************/
+ /* B 1.3.1 - Elementary Data Types */
+ /***********************************/
+ void *visit(time_type_name_c *symbol) {return (void *)"TIME"; };
+ void *visit(bool_type_name_c *symbol) {return (void *)"BOOL"; };
+ void *visit(sint_type_name_c *symbol) {return (void *)"SINT"; };
+ void *visit(int_type_name_c *symbol) {return (void *)"INT"; };
+ void *visit(dint_type_name_c *symbol) {return (void *)"DINT"; };
+ void *visit(lint_type_name_c *symbol) {return (void *)"LINT"; };
+ void *visit(usint_type_name_c *symbol) {return (void *)"USINT"; };
+ void *visit(uint_type_name_c *symbol) {return (void *)"UINT"; };
+ void *visit(udint_type_name_c *symbol) {return (void *)"UDINT"; };
+ void *visit(ulint_type_name_c *symbol) {return (void *)"ULINT"; };
+ void *visit(real_type_name_c *symbol) {return (void *)"REAL"; };
+ void *visit(lreal_type_name_c *symbol) {return (void *)"LREAL"; };
+ void *visit(date_type_name_c *symbol) {return (void *)"DATE"; };
+ void *visit(tod_type_name_c *symbol) {return (void *)"TOD"; };
+ void *visit(dt_type_name_c *symbol) {return (void *)"DT"; };
+ void *visit(byte_type_name_c *symbol) {return (void *)"BYTE"; };
+ void *visit(word_type_name_c *symbol) {return (void *)"WORD"; };
+ void *visit(lword_type_name_c *symbol) {return (void *)"LWORD"; };
+ void *visit(dword_type_name_c *symbol) {return (void *)"DWORD"; };
+ void *visit(string_type_name_c *symbol) {return (void *)"STRING"; };
+ void *visit(wstring_type_name_c *symbol) {return (void *)"WSTRING"; };
+
+ void *visit(safetime_type_name_c *symbol) {return (void *)"SAFETIME"; };
+ void *visit(safebool_type_name_c *symbol) {return (void *)"SAFEBOOL"; };
+ void *visit(safesint_type_name_c *symbol) {return (void *)"SAFESINT"; };
+ void *visit(safeint_type_name_c *symbol) {return (void *)"SAFEINT"; };
+ void *visit(safedint_type_name_c *symbol) {return (void *)"SAFEDINT"; };
+ void *visit(safelint_type_name_c *symbol) {return (void *)"SAFELINT"; };
+ void *visit(safeusint_type_name_c *symbol) {return (void *)"SAFEUSINT"; };
+ void *visit(safeuint_type_name_c *symbol) {return (void *)"SAFEUINT"; };
+ void *visit(safeudint_type_name_c *symbol) {return (void *)"SAFEUDINT"; };
+ void *visit(safeulint_type_name_c *symbol) {return (void *)"SAFEULINT"; };
+ void *visit(safereal_type_name_c *symbol) {return (void *)"SAFEREAL"; };
+ void *visit(safelreal_type_name_c *symbol) {return (void *)"SAFELREAL"; };
+ void *visit(safedate_type_name_c *symbol) {return (void *)"SAFEDATE"; };
+ void *visit(safetod_type_name_c *symbol) {return (void *)"SAFETOD"; };
+ void *visit(safedt_type_name_c *symbol) {return (void *)"SAFEDT"; };
+ void *visit(safebyte_type_name_c *symbol) {return (void *)"SAFEBYTE"; };
+ void *visit(safeword_type_name_c *symbol) {return (void *)"SAFEWORD"; };
+ void *visit(safelword_type_name_c *symbol) {return (void *)"SAFELWORD"; };
+ void *visit(safedword_type_name_c *symbol) {return (void *)"SAFEDWORD"; };
+ void *visit(safestring_type_name_c *symbol) {return (void *)"SAFESTRING"; };
+ void *visit(safewstring_type_name_c *symbol) {return (void *)"SAFEWSTRING"; };
+};
+extern elementary_type_c *elementary_type;
+
+
+
+
+
#define is_type(type_name_symbol, type_name_class) ((type_name_symbol == NULL) ? false : (typeid(*type_name_symbol) == typeid(type_name_class)))
#define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol)
--- a/stage3/print_datatypes_error.cc Tue Feb 07 17:40:19 2012 +0000
+++ b/stage3/print_datatypes_error.cc Tue Feb 07 17:45:17 2012 +0000
@@ -37,6 +37,8 @@
*/
#include "print_datatypes_error.hh"
+#include "datatype_functions.hh"
+
#include <typeinfo>
#include <list>
#include <string>
@@ -45,79 +47,6 @@
-/* A small helper class, to transform elementary data type to string.
- * this allows us to generate more relevant error messages...
- */
-
-class elementary_type_c: public null_visitor_c {
- elementary_type_c(void) {};
- ~elementary_type_c(void) {};
-
- private:
- /* singleton class! */
- static elementary_type_c *singleton;
-
- public:
- static const char * to_string(symbol_c *symbol) {
- if (NULL == singleton) singleton = new elementary_type_c;
- if (NULL == singleton) ERROR;
- const char *res = (const char *)symbol->accept(*singleton);
- if (NULL == res) ERROR;
- return res;
- }
-
- /***********************************/
- /* B 1.3.1 - Elementary Data Types */
- /***********************************/
- void *visit(time_type_name_c *symbol) {return (void *)"TIME"; };
- void *visit(bool_type_name_c *symbol) {return (void *)"BOOL"; };
- void *visit(sint_type_name_c *symbol) {return (void *)"SINT"; };
- void *visit(int_type_name_c *symbol) {return (void *)"INT"; };
- void *visit(dint_type_name_c *symbol) {return (void *)"DINT"; };
- void *visit(lint_type_name_c *symbol) {return (void *)"LINT"; };
- void *visit(usint_type_name_c *symbol) {return (void *)"USINT"; };
- void *visit(uint_type_name_c *symbol) {return (void *)"UINT"; };
- void *visit(udint_type_name_c *symbol) {return (void *)"UDINT"; };
- void *visit(ulint_type_name_c *symbol) {return (void *)"ULINT"; };
- void *visit(real_type_name_c *symbol) {return (void *)"REAL"; };
- void *visit(lreal_type_name_c *symbol) {return (void *)"LREAL"; };
- void *visit(date_type_name_c *symbol) {return (void *)"DATE"; };
- void *visit(tod_type_name_c *symbol) {return (void *)"TOD"; };
- void *visit(dt_type_name_c *symbol) {return (void *)"DT"; };
- void *visit(byte_type_name_c *symbol) {return (void *)"BYTE"; };
- void *visit(word_type_name_c *symbol) {return (void *)"WORD"; };
- void *visit(lword_type_name_c *symbol) {return (void *)"LWORD"; };
- void *visit(dword_type_name_c *symbol) {return (void *)"DWORD"; };
- void *visit(string_type_name_c *symbol) {return (void *)"STRING"; };
- void *visit(wstring_type_name_c *symbol) {return (void *)"WSTRING"; };
-
- void *visit(safetime_type_name_c *symbol) {return (void *)"SAFETIME"; };
- void *visit(safebool_type_name_c *symbol) {return (void *)"SAFEBOOL"; };
- void *visit(safesint_type_name_c *symbol) {return (void *)"SAFESINT"; };
- void *visit(safeint_type_name_c *symbol) {return (void *)"SAFEINT"; };
- void *visit(safedint_type_name_c *symbol) {return (void *)"SAFEDINT"; };
- void *visit(safelint_type_name_c *symbol) {return (void *)"SAFELINT"; };
- void *visit(safeusint_type_name_c *symbol) {return (void *)"SAFEUSINT"; };
- void *visit(safeuint_type_name_c *symbol) {return (void *)"SAFEUINT"; };
- void *visit(safeudint_type_name_c *symbol) {return (void *)"SAFEUDINT"; };
- void *visit(safeulint_type_name_c *symbol) {return (void *)"SAFEULINT"; };
- void *visit(safereal_type_name_c *symbol) {return (void *)"SAFEREAL"; };
- void *visit(safelreal_type_name_c *symbol) {return (void *)"SAFELREAL"; };
- void *visit(safedate_type_name_c *symbol) {return (void *)"SAFEDATE"; };
- void *visit(safetod_type_name_c *symbol) {return (void *)"SAFETOD"; };
- void *visit(safedt_type_name_c *symbol) {return (void *)"SAFEDT"; };
- void *visit(safebyte_type_name_c *symbol) {return (void *)"SAFEBYTE"; };
- void *visit(safeword_type_name_c *symbol) {return (void *)"SAFEWORD"; };
- void *visit(safelword_type_name_c *symbol) {return (void *)"SAFELWORD"; };
- void *visit(safedword_type_name_c *symbol) {return (void *)"SAFEDWORD"; };
- void *visit(safestring_type_name_c *symbol) {return (void *)"SAFESTRING"; };
- void *visit(safewstring_type_name_c *symbol) {return (void *)"SAFEWSTRING"; };
-};
-
-
-elementary_type_c *elementary_type_c::singleton = NULL;
-
-