diff python/testc3.py @ 213:003c8a976fff

Merge of semantics and parser again ..
author Windel Bouwman
date Fri, 05 Jul 2013 11:18:48 +0200
parents d77cb5962cc5
children c1ccb1cb4cef
line wrap: on
line diff
--- a/python/testc3.py	Sun Jun 30 19:00:41 2013 +0200
+++ b/python/testc3.py	Fri Jul 05 11:18:48 2013 +0200
@@ -56,28 +56,6 @@
 
 """
 
-
-def c3compile(src, diag):
-   # Structures:
-   builder = c3.Builder(diag)
-   ir = builder.build(src)
-   # optional optimize here
-   x86gen = x86.X86CodeGenSimple(diag)
-   ok = len(diag.diags) == 0
-   if not ok:
-      return
-   print('generating x86 code')
-   x86gen.genBin(ir)
-   with open('dummydummy.asm', 'w') as f:
-      f.write('bits 64\n')
-      for a in x86gen.asm:
-         print(a)
-         f.write(str(a) + '\n')
-   
-def do():
-   diag = ppci.DiagnosticsManager()
-   c3compile(testsrc, diag)
-
 class testLexer(unittest.TestCase):
     def testUnexpectedCharacter(self):
         snippet = """ var s \u6c34 """
@@ -224,6 +202,57 @@
       if not ircode:
         self.diag.printErrors(snippet)
       self.assertTrue(ircode)
+   
+   @unittest.skip 
+   def testPointerType(self):
+        snippet = """
+         package testpointer;
+         var int* pa;
+         function void t(int a, double b)
+         {
+            *pa = 22;
+         }
+        """
+        self.diag.clear()
+        ircode = self.builder.build(snippet)
+        if not ircode:
+            self.diag.printErrors(snippet)
+        self.assertTrue(ircode)
+
+   @unittest.skip 
+   def testComplexType(self):
+        snippet = """
+         package testpointer;
+         type int my_int;
+
+         type struct {
+          int x, y;
+         } point;
+
+         type struct {
+           int mem1;
+           int memb2;
+           point P1;
+         } my_struct;
+
+         type my_struct* my_sptr;
+
+         function void t(int a, double b, my_sptr x)
+         {
+            var my_struct *msp;
+
+            msp = x;
+            *pa = 22;
+            x->memb2 = *pa + a * b;
+
+            mxp->P1.x = a * x->P1.y;
+         }
+        """
+        self.diag.clear()
+        ircode = self.builder.build(snippet)
+        if not ircode:
+            self.diag.printErrors(snippet)
+        self.assertTrue(ircode)
 
    def test2(self):
         # testsrc2 is valid code:
@@ -254,7 +283,6 @@
         self.assertTrue(ir)
 
 if __name__ == '__main__':
-   do()
    unittest.main()