[SCM] Lisaac compiler branch, mildred-backend, updated. lisaac-0.12-434-g3ee9ebf

Mildred Ki'Lya silkensedai at online.fr
Fri Aug 7 12:08:54 UTC 2009


The following commit has been merged in the mildred-backend branch:
commit 50fde6926251cc9cd8bef2fc6a16ab5c0afb094c
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Thu Aug 6 23:20:18 2009 +0200

    Added slots to generate type names in the backend

diff --git a/src/tools/backend.li b/src/tools/backend.li
index c90a775..5bd39c3 100644
--- a/src/tools/backend.li
+++ b/src/tools/backend.li
@@ -33,6 +33,56 @@ Section Inherit
 
 Section Public
 
+  //
+  // Names
+  //
+
+  - append_type_struct_name_for t:TYPE in buf:STRING <-
+  (
+    buf.append (t.intern_name);
+    buf.append "_struct";
+  );
+
+  - append_type_name_for t:TYPE in buf:STRING <-
+  (
+    buf.append "__";
+    buf.append (t.intern_name);
+  );
+
+  - append_type_expanded_proto_name_for t:TYPE in buf:STRING <-
+  (
+    buf.append (t.intern_name);
+    buf.add_last '_';
+  );
+
+  - append_type_proto_name_for t:TYPE in buf:STRING <-
+  (
+    buf.append (t.intern_name);
+    buf.append "__";
+  );
+
+  - append_type_typeid_name_for t:TYPE in buf:STRING <-
+  (
+    buf.append "__";
+    buf.append (t.intern_name);
+    buf.append "__";
+  );
+
+  //
+  // Type
+  //
+
+  - generate_type_typedef_for t:TYPE in buf:STRING <- deferred;
+  - generate_type_struct_for  t:TYPE in buf:STRING <- deferred;
+  - generate_type_globals_for t:TYPE in buf:STRING <- deferred;
+
+  - generate_type_struct_for_null_in buf:STRING    <- deferred;
+  - generate_type_struct_for_context_in buf:STRING <- deferred;
+
+  //
+  // String Constant
+  //
+
   - append_string str:ABSTRACT_STRING in buf:STRING <-
   (
     buf.add_last '\"';
@@ -47,13 +97,6 @@ Section Public
     buf.add_last '\'';
   );
 
-  - generate_type_typedef_for t:TYPE in buf:STRING <- deferred;
-  - generate_type_struct_for  t:TYPE in buf:STRING <- deferred;
-  - generate_type_globals_for t:TYPE in buf:STRING <- deferred;
-
-  - generate_type_struct_for_null_in buf:STRING    <- deferred;
-  - generate_type_struct_for_context_in buf:STRING <- deferred;
-
   - append_escaped_character c:CHARACTER in buf:STRING <-
     (
       (c = '\0').if {               buf.add_last '\\'; buf.add_last '0';
diff --git a/src/tools/backend_c.li b/src/tools/backend_c.li
index 0716834..ebc3e7f 100644
--- a/src/tools/backend_c.li
+++ b/src/tools/backend_c.li
@@ -35,17 +35,15 @@ Section Public
 
   - generate_type_typedef_for t:TYPE in buf:STRING <-
   (
-    output_decl.append "typedef ";
+    buf.append "typedef ";
     (t.type_c != NULL).if {
-      output_decl.append (t.type_c);
+      buf.append (t.type_c);
     } else {
-      output_decl.append "struct ";
-      output_decl.append (t.intern_name);
-      output_decl.append "_struct";
+      buf.append "struct ";
+      append_type_struct_name_for t in buf;
     };
-    output_decl.append " __";
-    output_decl.append (t.intern_name);
-    output_decl.append ";\n";
+    append_type_name_for t in buf;
+    buf.append ";\n";
   );
 
   - generate_type_struct_for_null_in buf:STRING <-
@@ -80,14 +78,14 @@ Section Public
     //
 
     (t.type_c != NULL).if {
-      // Define __TRUE and __FALSE constants
+      // Define TRUE__ and FALSE__ constants
       (is_java).if_false {
         ((t.shortname = ALIAS_STR.prototype_true) ||
          {t.shortname = ALIAS_STR.prototype_false}).if
         {
           buf.append "#define ";
-          buf.append (t.intern_name);
-          buf.append "__ ";
+          append_type_proto_name_for t in buf;
+          buf.append " ";
           buf.add_last ((t.shortname = ALIAS_STR.prototype_true).to_character);
           buf.add_last '\n';
         };
@@ -111,13 +109,14 @@ Section Public
       // Type ID
       //
       (is_java).if {
-        buf.append "static private int __";
+        buf.append "static private int ";
+        append_type_typeid_name_for t in buf;
         buf.append (t.intern_name);
-        buf.append "__ = ";
+        buf.append " = ";
       } else {
-        buf.append "#define __";
-        buf.append (t.intern_name);
-        buf.append "__ ";
+        buf.append "#define ";
+        append_type_typeid_name_for t in buf;
+        buf.append " ";
       };
       t.is_late_binding.if {
         TYPE.generate_id_with_type.append_in buf;
@@ -133,8 +132,8 @@ Section Public
       // Start the struct declaration
       //
       buf.append "struct ";
-      buf.append (t.intern_name);
-      buf.append "_struct {\n";
+      append_type_struct_name_for t in buf;
+      buf.append " {\n";
 
       //
       // Generate extra slots before data slots
@@ -204,22 +203,21 @@ Section Public
   - generate_type_globals_for t:TYPE in buf:STRING <-
   (
     (t.type_c = NULL).if {
-      buf.append "__";
-      buf.append (t.intern_name);
+      append_type_name_for t in buf;
       buf.add_last ' ';
-      buf.append (t.intern_name);
-      buf.add_last '_';
+      append_type_expanded_proto_name_for t in buf;
       t.is_late_binding.if {
-        buf.append "={__";
+        buf.append "={";
+        append_type_typeid_name_for t in buf;
         buf.append (t.intern_name);
-        buf.append "__}";
+        buf.append "}";
       };
       buf.append ";\n";
       buf.append "#define ";
-      buf.append (t.intern_name);
-      buf.append "__ (&";
-      buf.append (t.intern_name);
-      buf.append "_)\n\n";
+      append_type_proto_name_for t in buf;
+      buf.append " (&";
+      append_type_expanded_proto_name_for t in buf;
+      buf.append ")\n\n";
     };
 
   );
diff --git a/src/tools/backend_java.li b/src/tools/backend_java.li
index 82dc053..148c141 100644
--- a/src/tools/backend_java.li
+++ b/src/tools/backend_java.li
@@ -62,7 +62,7 @@ Section Public
     //
 
     (t.type_c != NULL).if {
-      // Define __TRUE and __FALSE constants
+      // Define TRUE__ and FALSE__ constants
       // No need to do that for Java code
 
     //
@@ -86,9 +86,10 @@ Section Public
       //
       // Type ID
       //
-      buf.append "static private int __";
+      buf.append "static private int ";
       buf.append (t.intern_name);
-      buf.append "__ = ";
+      append_type_typeid_name_for t in buf;
+      buf.append " = ";
       t.is_late_binding.if {
         TYPE.generate_id_with_type.append_in buf;
       } else {
@@ -100,8 +101,8 @@ Section Public
       //
       // Start the class declaration
       //
-      buf.append "static class __";
-      buf.append (t.intern_name);
+      buf.append "static class ";
+      append_type_name_for t in buf;
       t.is_late_binding.if {
         buf.append " extends __OBJ";
       };
@@ -166,8 +167,8 @@ Section Public
       //
       (t = type_string_constant).if {
         // STRING_CONSTANT constructor.
-        buf.append "\n  public __";
-        buf.append (t.intern_name);
+        buf.append "\n  public ";
+        append_type_name_for t in buf;
         buf.add_last '(';
         t.is_late_binding.if {
           buf.append "int pid,";
@@ -199,8 +200,8 @@ Section Public
       //
       // Basic Constructor
       //
-      buf.append "\n  public __";
-      buf.append (t.intern_name);
+      buf.append "\n  public ";
+      append_type_name_for t in buf;
       buf.add_last '(';
       t.is_late_binding.if {
         buf.append "int pid";
@@ -223,17 +224,15 @@ Section Public
   - generate_type_globals_for t:TYPE in buf:STRING <-
   (
     (t.type_c = NULL).if {
-      buf.append "private static __";
-      buf.append (t.intern_name);
+      buf.append "private static ";
+      append_type_name_for t in buf;
       buf.add_last ' ';
-      buf.append (t.intern_name);
-      buf.append "_=new __";
-      buf.append (t.intern_name);
+      append_type_expanded_proto_name_for t in buf;
+      buf.append "=new ";
+      append_type_name_for t in buf;
       buf.add_last '(';
       t.is_late_binding.if {
-        buf.append "__";
-        buf.append (t.intern_name);
-        buf.append "__";
+        append_type_typeid_name_for t in buf;
       };
       buf.append ");\n";
     };

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list