Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
authoretisserant
Wed, 29 Aug 2007 11:06:13 +0200
changeset 55 8b7a21820737
parent 54 66925599259a
child 56 6e87bbc2abe9
Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
lib/iec_std_lib.h
stage4/generate_cc/generate_cc_base.cc
stage4/generate_cc/generate_location_list.cc
stage4/stage4.cc
stage4/stage4.hh
tests/build.sh
--- a/lib/iec_std_lib.h	Tue Aug 28 08:42:54 2007 +0200
+++ b/lib/iec_std_lib.h	Wed Aug 29 11:06:13 2007 +0200
@@ -95,6 +95,29 @@
 } WSTRING;
 */
 
+#define __BOOL_literal(value) (BOOL)value
+#define __SINT_literal(value) (SINT)value
+#define __INT_literal(value) (INT)value
+#define __DINT_literal(value) (DINT)value
+#define __LINT_literal(value) (LINT)value
+#define __USINT_literal(value) (USINT)value
+#define __UINT_literal(value) (UINT)value
+#define __UDINT_literal(value) (UDINT)value
+#define __ULINT_literal(value) (ULINT)value
+#define __REAL_literal(value) (REAL)value
+#define __LREAL_literal(value) (LREAL)value
+#define __TIME_literal(value) (TIME)value
+#define __DATE_literal(value) (DATE)value
+#define __TOD_literal(value) (TOD)value
+#define __DT_literal(value) (DT)value
+#define __STRING_literal(value) (STRING)value
+#define __BYTE_literal(value) (BYTE)value
+#define __WORD_literal(value) (WORD)value
+#define __DWORD_literal(value) (DWORD)value
+#define __LWORD_literal(value) (LWORD)value
+
+
+
 #define __INIT_REAL 0
 #define __INIT_LREAL 0
 #define __INIT_SINT 0
--- a/stage4/generate_cc/generate_cc_base.cc	Tue Aug 28 08:42:54 2007 +0200
+++ b/stage4/generate_cc/generate_cc_base.cc	Wed Aug 29 11:06:13 2007 +0200
@@ -88,10 +88,11 @@
     }
 
     void *print_literal(symbol_c *type, symbol_c *value) {
-      s4o.print("(");
+      s4o.print("__");
       type->accept(*this);
+      s4o.print("_LITERAL(");
+      value->accept(*this);
       s4o.print(")");
-      value->accept(*this);
       return NULL;
     }
 
--- a/stage4/generate_cc/generate_location_list.cc	Tue Aug 28 08:42:54 2007 +0200
+++ b/stage4/generate_cc/generate_location_list.cc	Wed Aug 29 11:06:13 2007 +0200
@@ -123,6 +123,8 @@
       s4o.print(",");
       /* Do not use print_token() as it will change everything into uppercase */
       s4o.printlocation((symbol->value)+1);
+      s4o.print(",");
+      s4o.printlocation_comasep((symbol->value)+1);
       s4o.print(")\n");
       return NULL;
     }
--- a/stage4/stage4.cc	Tue Aug 28 08:42:54 2007 +0200
+++ b/stage4/stage4.cc	Wed Aug 29 11:06:13 2007 +0200
@@ -123,6 +123,20 @@
   return NULL;
 }
 
+void *stage4out_c::printlocation_comasep(const char *str) {
+  *out << (unsigned char)toupper(str[0]);
+  *out << ',';
+  *out << (unsigned char)toupper(str[1]);
+  *out << ',';
+  for (int i = 2; str[i] != '\0'; i++)
+    if(str[i] == '.')
+      *out << ',';
+    else
+      *out << (unsigned char)toupper(str[i]);
+  return NULL;
+}
+
+
 void *stage4out_c::print(std::string str) {
   *out << str;
   return NULL;
--- a/stage4/stage4.hh	Tue Aug 28 08:42:54 2007 +0200
+++ b/stage4/stage4.hh	Wed Aug 29 11:06:13 2007 +0200
@@ -55,6 +55,8 @@
     void *printlocation(const char *str);
     void *printlocation(std::string str);
 
+    void *printlocation_comasep(const char *str);
+
   protected:
     std::ostream *out;
     std::fstream *m_file;
--- a/tests/build.sh	Tue Aug 28 08:42:54 2007 +0200
+++ b/tests/build.sh	Wed Aug 29 11:06:13 2007 +0200
@@ -6,11 +6,15 @@
 
 CFLAGS=$*
 
+
+CC=gcc
+#CC=i686-mingw32-gcc
+
 ../iec2cc $STFILE -I ../lib 
 #2>/dev/null
 
-gcc -I ../lib -c STD_RESSOURCE.c $CFLAGS
+$CC -I ../lib -c STD_RESSOURCE.c $CFLAGS
 
-gcc -I ../lib -c  STD_CONF.c $CFLAGS
+$CC -I ../lib -c  STD_CONF.c $CFLAGS
 
-gcc -I ../lib main.c STD_CONF.o STD_RESSOURCE.o $CFLAGS -l rt -o test
+$CC -I ../lib main.c STD_CONF.o STD_RESSOURCE.o $CFLAGS -l rt -o test