]> git.mdlowis.com Git - proto/obnc.git/commitdiff
wrapped up initial record support
authormike lowis <mike@mdlowis.com>
Thu, 27 May 2021 01:31:37 +0000 (21:31 -0400)
committermike lowis <mike@mdlowis.com>
Thu, 27 May 2021 01:31:37 +0000 (21:31 -0400)
cerise/backend/c99/codegen.c
cerise/backend/test/codegen.c
cerise/backend/x86_64/codegen.c
cerise/inc/cerise.h
cerise/src/grammar.c
cerise/tests/Module.m

index 4d22b4aae426ec5c38af6b17bf36edac06a6cc20..5e90fd18bdebc4ada95c8399bde39e87332061a4 100644 (file)
@@ -118,7 +118,6 @@ static void declare_var(Parser* p, Symbol* sym, int isref)
     make_var(p, sym, isref);
 }
 
-
 static int declare_temp(Parser* p, Type* type, int isref)
 {
     char name[32];
@@ -227,6 +226,20 @@ static void unary_op(Parser* p, int op, Item* a)
 
 /* Public Interface
  *****************************************************************************/
+
+void codegen_startmod(Parser* p)
+{
+    (void)p;
+    printf("typedef _Bool Bool;\n");
+    printf("typedef long Int;\n");
+    printf("typedef double Real;\n");
+}
+
+void codegen_endmod(Parser* p)
+{
+    (void)p;
+}
+
 void codegen_setint(Item* item, Type* type, long long val)
 {
     item->mode  = ITEM_CONST;
index 91ebd3298b5c3439b321a5672b75580453333728..c57491a4e7729bdf534c7a42e2720b4d00a6c5cc 100644 (file)
@@ -22,6 +22,16 @@ Type StringType = {
     .size = -1
 };
 
+void codegen_startmod(Parser* p)
+{
+    (void)p;
+}
+
+void codegen_endmod(Parser* p)
+{
+    (void)p;
+}
+
 void codegen_setint(Item* item, Type* type, long long val)
 {
     item->mode  = ITEM_CONST;
index 85023cb2110257e742af6f57dd81f77ade2da6a1..c89e47192eac385f61834c6cd8efea8433fcec4d 100644 (file)
@@ -153,6 +153,16 @@ Type StringType = {
     .size = -1
 };
 
+void codegen_startmod(Parser* p)
+{
+    (void)p;
+}
+
+void codegen_endmod(Parser* p)
+{
+    (void)p;
+}
+
 void codegen_setint(Item* item, Type* type, long long val)
 {
     item->mode  = ITEM_CONST;
index 59c1ec67f8e4ca500bcec6266b2b6e67cd50bf9c..f05cf0b4326ea6e025d3ae4c6ef8c8f5c413cf2e 100644 (file)
@@ -203,6 +203,8 @@ void dump_type(Type* a);
  *****************************************************************************/
 extern Type BoolType, IntType, RealType, StringType;
 
+void codegen_startmod(Parser* p);
+void codegen_endmod(Parser* p);
 void codegen_setint(Item* item, Type* type, long long val);
 void codegen_setreal(Item* item, double val);
 void codegen_setstr(Item* item, char* val);
index 595a8092f4a4d1ccf5f49c28f2b89c02596ddc86..b1e38d91a99d426321558e7887cdd0b8c307d2a1 100644 (file)
@@ -655,8 +655,8 @@ RULE(proc_decl)
     }
     expect(p, END);
 
-    symbol_closescope(p);
     codegen_endproc(p);
+    symbol_closescope(p);
 }
 
 RULE(import_list)
@@ -772,8 +772,10 @@ void compile(char* fname)
         },
         .curr_reg = 0
     };
+    codegen_startmod(p);
     module(p, &(Item){0});
     codegen_main(p);
+    codegen_endmod(p);
 }
 
 /* Grammar Unit Tests
index 64f8e5c87c6965fabc19b953ff29ed7c3db8a363..60afadfee027552610a8926181eb06873b7e93ff 100644 (file)
@@ -42,7 +42,7 @@ begin
 end
 
 begin
-  a = true;
+#  a = true;
 #  a = A;
 #  b = 24;
 #  b = B;