[SCM] Lisaac compiler branch, mildred-backend, updated. lisaac-0.12-524-g7710f76
Mildred Ki'Lya
silkensedai at online.fr
Tue Aug 25 21:54:01 UTC 2009
The following commit has been merged in the mildred-backend branch:
commit 10ee4fd23c19fb5622bf66a663b18d7478932cb4
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Tue Aug 25 23:49:56 2009 +0200
bootstrap ok
diff --git a/src/tools/backend.li b/src/tools/backend.li
index 0772688..10c57f5 100644
--- a/src/tools/backend.li
+++ b/src/tools/backend.li
@@ -41,30 +41,35 @@ Section Public
- append_type_struct_name_for t:TYPE in buf:STRING <-
(
+// buf.append "__s_";
buf.append (t.intern_name);
buf.append "_struct";
);
- append_type_name_for t:TYPE in buf:STRING <-
(
+// buf.append "__t_";
buf.append (ALIAS_STR.separate);
buf.append (t.intern_name);
);
- append_type_expanded_proto_name_for t:TYPE in buf:STRING <-
(
+// buf.append "__pe_";
buf.append (t.intern_name);
buf.add_last '_';
);
- append_type_proto_name_for t:TYPE in buf:STRING <-
(
+// buf.append "__p_";
buf.append (t.intern_name);
buf.append (ALIAS_STR.separate);
);
- append_type_typeid_name_for t:TYPE in buf:STRING <-
(
+// buf.append "__id_";
buf.append (ALIAS_STR.separate);
buf.append (t.intern_name);
buf.append (ALIAS_STR.separate);
@@ -74,9 +79,77 @@ Section Public
// 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_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_typeid_for t:TYPE in buf:STRING <- deferred;
+ - generate_type_struct_boolean_for t:TYPE in buf:STRING <- deferred;
+
+ - generate_type_struct_header_for t:TYPE in buf:STRING <-
+ (
+ buf.append "// ";
+ buf.append (t.intern_name);
+ buf.add_last '\n';
+ );
+
+ - generate_type_struct_contents_for t:TYPE in buf:STRING <-
+ ( + slot_data:SLOT_DATA;
+ + tab:FAST_ARRAY(SLOT_DATA);
+ + num_slots :INTEGER;
+
+ //
+ // Generate extra slots before data slots
+ // - for COP
+ // - type_id for late binding
+ //
+ ((t.is_late_binding) && {t.prototype.style != '-'}).if {
+ buf.append " unsigned long __id;\n";
+ num_slots := num_slots + 1;
+ };
+ (t.prototype.style = '-').if {
+ buf.append " lith_object thread;\n";
+ (t.param_count != 0).if {
+ 1.to (t.param_count) do { n:INTEGER;
+ buf.append " int param_";
+ (n-1).append_in buf;
+ buf.append ";\n";
+ num_slots := num_slots + 1;
+ };
+ };
+ };
+
+ //
+ // Generate data slots ordered by size
+ //
+ (t.slot_size.upper).downto (t.slot_size.lower) do { j:INTEGER;
+ tab := t.slot_size.item j;
+ (tab.lower).to (tab.upper) do { i:INTEGER;
+ slot_data := tab.item i;
+ ((t.prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
+ buf.append " volatile ";
+ } else {
+ buf.append " ";
+ };
+ slot_data.genere buf;
+ num_slots := num_slots + 1;
+ };
+ tab.clear;
+ };
+
+ //
+ // Generate extra slots after data slots
+ // - for BLOCK
+ // - dummy slot if no slots were generated
+ //
+ (t = type_block).if {
+ buf.append " void *self;\n";
+ num_slots := num_slots + 1;
+ };
+ (num_slots == 0).if {
+ buf.append " void *Nothing;\n";
+ };
+ );
+
- generate_type_struct_for_generic_in buf:STRING <- deferred;
- generate_type_struct_for_null_in buf:STRING <- deferred;
diff --git a/src/tools/backend_c.li b/src/tools/backend_c.li
index f4e2874..a3f82c3 100644
--- a/src/tools/backend_c.li
+++ b/src/tools/backend_c.li
@@ -90,129 +90,77 @@ Section Public
);
- generate_type_struct_for t:TYPE in buf:STRING <-
- ( + slot_data:SLOT_DATA;
- + tab:FAST_ARRAY(SLOT_DATA);
- + num_slots :INTEGER;
-
+ (
//
- // Type C
+ // Ahead generation of the struct content.
//
-
- (t.type_c != NULL).if {
- // Define TRUE__ and FALSE__ constants
- ((t.shortname = ALIAS_STR.prototype_true) ||
- {t.shortname = ALIAS_STR.prototype_false}).if
- {
- buf.append "#define ";
- 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';
- };
-
-
+ // If not outside the if, the following error is triggered when
+ // bootstrapping:
+ //
+ // --SEMANTIC---------
+ // Slot is not possible with a type C
+ // Line 35 column 21 in LIP_CODE:
+ // + parent_itm_object:Expanded ITM_OBJECT;
+ // ^
+ // This error is strange as for the compiler, the type BOOLEAN contains
+ // slots from LIP_CODE (this error was triggered in BOOLEAN, I checked)
//
- // Lisaac defined type
+ // Possible cause: if the struct content is not generated, some slots stay
+ // in TYPE.slot_size and the next type generated keep the slots from the
+ // previous type (in this case LIP_CALL keep the slots from BOOLEAN)
//
- } else {
+ string_tmp.clear;
+ generate_type_struct_contents_for t in string_tmp;
+
+ (t.alias_slot = NULL).if {
//
- // Comment
+ // Start the struct declaration
//
- buf.append "// ";
- buf.append (t.intern_name);
- buf.add_last '\n';
+ buf.append "struct ";
+ append_type_struct_name_for t in buf;
+ buf.append " {\n";
//
- // Type ID
+ // Struct Contents
//
- 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;
+ buf.append string_tmp;
+
+ //
+ // End structure declaration
+ //
+ (t.prototype.is_mapping).if {
+ buf.append "} __attribute__ ((packed));\n";
} else {
- TYPE.generate_id_without_type.append_in buf;
+ buf.append "};\n";
};
- buf.add_last '\n';
-
- (t.alias_slot = NULL).if {
-
- //
- // Start the struct declaration
- //
- buf.append "struct ";
- append_type_struct_name_for t in buf;
- buf.append " {\n";
-
- //
- // Generate extra slots before data slots
- // - for COP
- // - type_id for late binding
- //
- (t.prototype.style = '-').if {
- buf.append " lith_object thread;\n";
- (t.param_count != 0).if {
- 1.to (t.param_count) do { n:INTEGER;
- buf.append " int param_";
- (n-1).append_in buf;
- buf.append ";\n";
- num_slots := num_slots + 1;
- };
- };
- }.elseif {t.is_late_binding} then {
- string_tmp.append " unsigned long __id;\n";
- num_slots := num_slots + 1;
- };
-
- //
- // Generate data slots ordered by size
- //
- ? { t.slot_size.upper = 4 };
- ? { t.slot_size.lower = 0 };
- (t.slot_size.upper).downto (t.slot_size.lower) do { j:INTEGER;
- tab := t.slot_size.item j;
- (tab.lower).to (tab.upper) do { i:INTEGER;
- slot_data := tab.item i;
- ((t.prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
- buf.append " volatile ";
- } else {
- buf.append " ";
- };
- slot_data.genere buf;
- num_slots := num_slots + 1;
- };
- tab.clear;
- };
+ };
+ );
- //
- // Generate extra slots after data slots
- // - for BLOCK
- // - dummy slot if no slots were generated
- //
- (t = type_block).if {
- buf.append " void *self;\n";
- num_slots := num_slots + 1;
- };
- (num_slots == 0).if {
- buf.append " void *Nothing;\n";
- };
+ - generate_type_struct_boolean_for t:TYPE in buf:STRING <-
+ (
+ buf.append "#define ";
+ 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';
+ );
- //
- // End structure declaration
- //
- (t.prototype.is_mapping).if {
- buf.append "} __attribute__ ((packed));\n";
- } else {
- buf.append "};\n";
- };
- };
+ - generate_type_struct_typeid_for t:TYPE in buf:STRING <-
+ (
+ 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;
+ } else {
+ TYPE.generate_id_without_type.append_in buf;
};
+ buf.add_last '\n';
);
-
- generate_type_globals_for t:TYPE in buf:STRING <-
(
(t.type_c = NULL).if {
diff --git a/src/tools/backend_java.li b/src/tools/backend_java.li
index b249ed1..917f941 100644
--- a/src/tools/backend_java.li
+++ b/src/tools/backend_java.li
@@ -60,175 +60,100 @@ Section Public
- generate_type_struct_for t:TYPE in buf:STRING <-
- ( + slot_data:SLOT_DATA;
- + tab:FAST_ARRAY(SLOT_DATA);
- + count_slot:SLOT_DATA;
+ ( + count_slot:SLOT_DATA;
+ storage_slot:SLOT_DATA;
- + num_slots :INTEGER;
-
//
- // Type C
+ // Start the class declaration
//
+ buf.append "static class ";
+ append_type_name_for t in buf;
+ t.is_late_binding.if {
+ buf.append " extends __OBJ";
+ };
+ buf.append " {\n";
- (t.type_c != NULL).if {
- // Define TRUE__ and FALSE__ constants
- // No need to do that for Java code
//
- // Lisaac defined type
+ // Struct Contents
//
+ generate_type_struct_contents_for t in buf;
- } else {
-
- (t.prototype.is_mapping).if {
- semantic_error (t.position,
- "Mapping is not yet implemented for Java code.");
- };
-
- //
- // Comment
- //
- buf.append "// ";
- buf.append (t.intern_name);
- buf.add_last '\n';
-
- //
- // Type ID
- //
- buf.append "static private int ";
- buf.append (t.intern_name);
- append_type_typeid_name_for t in buf;
- buf.append " = ";
- t.is_late_binding.if {
- TYPE.generate_id_with_type.append_in buf;
- } else {
- TYPE.generate_id_without_type.append_in buf;
- };
- buf.add_last ';';
- buf.add_last '\n';
-
- //
- // Start the class declaration
- //
- buf.append "static class ";
- append_type_name_for t in buf;
- t.is_late_binding.if {
- buf.append " extends __OBJ";
- };
- buf.append " {\n";
-
- //
- // Generate extra slots before data slots
- // - for COP
- // - type_id for late binding
- //
- (t.prototype.style = '-').if {
- buf.append " lith_object thread;\n";
- (t.param_count != 0).if {
- 1.to (t.param_count) do { n:INTEGER;
- buf.append " int param_";
- (n-1).append_in buf;
- buf.append ";\n";
- num_slots := num_slots + 1;
- };
- };
- }.elseif {t.is_late_binding} then {
- buf.append " unsigned long __id;\n";
- num_slots := num_slots + 1;
- };
-
- //
- // Generate data slots ordered by size
- //
- ? { t.slot_size.upper = 4 };
- ? { t.slot_size.lower = 0 };
- (t.slot_size.upper).downto (t.slot_size.lower) do { j:INTEGER;
- tab := t.slot_size.item j;
- (tab.lower).to (tab.upper) do { i:INTEGER;
- slot_data := tab.item i;
- ((t.prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
- buf.append " volatile ";
- } else {
- buf.append " ";
- };
- slot_data.genere buf;
- num_slots := num_slots + 1;
- };
- tab.clear;
- };
-
- //
- // Generate extra slots after data slots
- // - for BLOCK
- // - dummy slot if no slots were generated
- //
- (t = type_block).if {
- buf.append " void *self;\n";
- num_slots := num_slots + 1;
- };
- (num_slots == 0).if {
- buf.append " void *Nothing;\n";
- };
-
- //
- // Handle special case where the type is STRING_CONSTANT
- // We must generate a special constructor
- //
- (t = type_string_constant).if {
- // STRING_CONSTANT constructor.
- buf.append "\n public ";
- append_type_name_for t in buf;
- buf.add_last '(';
- t.is_late_binding.if {
- buf.append "int pid,";
- };
- storage_slot := t.get_local_slot (ALIAS_STR.slot_storage).slot_data_intern;
- count_slot := t.get_local_slot (ALIAS_STR.slot_count).slot_data_intern;
- (count_slot.ensure_count != 0).if {
- buf.append "int pcount,";
- };
- (storage_slot.ensure_count != 0).if {
- buf.append "String pstorage,";
- };
- buf.remove_last 1;
- buf.append ")\n {\n ";
- t.is_late_binding.if {
- buf.append "__id = pid;\n";
- };
- (count_slot.ensure_count != 0).if {
- buf.append (count_slot.intern_name);
- buf.append " = pcount;\n";
- };
- (storage_slot.ensure_count != 0).if {
- buf.append (storage_slot.intern_name);
- buf.append " = pstorage.toCharArray();\n";
- };
- buf.append " };\n";
- };
-
- //
- // Basic Constructor
- //
+ //
+ // Handle special case where the type is STRING_CONSTANT
+ // We must generate a special constructor
+ //
+ (t = type_string_constant).if {
+ // STRING_CONSTANT constructor.
buf.append "\n public ";
append_type_name_for t in buf;
buf.add_last '(';
t.is_late_binding.if {
- buf.append "int pid";
+ buf.append "int pid,";
};
+ storage_slot := t.get_local_slot (ALIAS_STR.slot_storage).slot_data_intern;
+ count_slot := t.get_local_slot (ALIAS_STR.slot_count).slot_data_intern;
+ (count_slot.ensure_count != 0).if {
+ buf.append "int pcount,";
+ };
+ (storage_slot.ensure_count != 0).if {
+ buf.append "String pstorage,";
+ };
+ buf.remove_last 1;
buf.append ")\n {\n ";
t.is_late_binding.if {
- buf.append "__id = pid;\n";
- } else {
- buf.append "super();\n";
+ buf.append "__id = pid;\n";
+ };
+ (count_slot.ensure_count != 0).if {
+ buf.append (count_slot.intern_name);
+ buf.append " = pcount;\n";
+ };
+ (storage_slot.ensure_count != 0).if {
+ buf.append (storage_slot.intern_name);
+ buf.append " = pstorage.toCharArray();\n";
};
buf.append " };\n";
+ };
- //
- // End class declaration
- //
- buf.append "};\n";
+ //
+ // Basic Constructor
+ //
+ buf.append "\n public ";
+ append_type_name_for t in buf;
+ buf.add_last '(';
+ t.is_late_binding.if {
+ buf.append "int pid";
+ };
+ buf.append ")\n {\n ";
+ t.is_late_binding.if {
+ buf.append "__id = pid;\n";
+ } else {
+ buf.append "super();\n";
+ };
+ buf.append " };\n";
+
+ //
+ // End class declaration
+ //
+ buf.append "};\n";
+ );
+
+ - generate_type_struct_boolean_for t:TYPE in buf:STRING <-
+ ();
+
+ - generate_type_struct_typeid_for t:TYPE in buf:STRING <-
+ (
+ buf.append "static private int ";
+ buf.append (t.intern_name);
+ append_type_typeid_name_for t in buf;
+ buf.append " = ";
+ t.is_late_binding.if {
+ TYPE.generate_id_with_type.append_in buf;
+ } else {
+ TYPE.generate_id_without_type.append_in buf;
};
+ buf.add_last ';';
+ buf.add_last '\n';
);
- generate_type_globals_for t:TYPE in buf:STRING <-
diff --git a/src/type/type.li b/src/type/type.li
index a5adcb0..266e66a 100644
--- a/src/type/type.li
+++ b/src/type/type.li
@@ -454,9 +454,10 @@ Section Public
+ tab:FAST_ARRAY(SLOT_DATA);
+ action:{SLOT_DATA; };
+ tg:TYPE_GENERIC;
- + count_slot:SLOT_DATA;
- + storage_slot:SLOT_DATA;
-
+ + buf:STRING;
+
+ buf := output_decl;
+
((slot_run.is_empty) || {slot_run.first != NULL}).if {
//
@@ -576,6 +577,12 @@ Section Public
semantic_error (tab.first.position,"Slot is not possible with a type C");
};
};
+ ( (is_late_binding) &&
+ {shortname != ALIAS_STR.prototype_true} &&
+ {shortname != ALIAS_STR.prototype_false}).if
+ {
+ semantic_error (tab.first.position,"Late binding is not possible with a type C");
+ };
} else {
((is_late_binding) && {prototype.is_mapping}).if {
semantic_error (prototype.position,
@@ -588,184 +595,33 @@ Section Public
//
(type_c != NULL).if {
- (is_java).if_false {
+
+ //
+ // Type C
+ // Special case for BOOLEAN
+ //
+
+ (is_java).if_false {
((shortname = ALIAS_STR.prototype_true) ||
{shortname = ALIAS_STR.prototype_false}).if {
- output_decl.append "#define ";
- output_decl.append intern_name;
- output_decl.append "__ ";
- output_decl.add_last ((shortname = ALIAS_STR.prototype_true).to_character);
- output_decl.add_last '\n';
- }.elseif {is_late_binding} then {
- semantic_error (tab.first.position,"Late binding is not possible with a type C");
- };
- };
- } else {
- output_decl.append "// ";
- output_decl.append intern_name;
- output_decl.add_last '\n';
- (is_java).if {
- output_decl.append "static private int __";
- output_decl.append intern_name;
- output_decl.append "__ = ";
- } else {
- output_decl.append "#define __";
- output_decl.append intern_name;
- output_decl.append "__ ";
- };
- string_tmp.clear;
- (is_late_binding).if {
- id_counter_with_type.append_in output_decl;
- id_counter_with_type := id_counter_with_type + 1;
- (prototype.style != '-').if {
- string_tmp.append " unsigned long __id;\n";
- };
-// (prototype.is_mapping).if {
-// semantic_error (prototype.position,
-// "Late binding is not possible with `mapping' object.");
-// };
- } else {
- id_counter_without_type.append_in output_decl;
- id_counter_without_type := id_counter_without_type + 1;
- };
- (is_java).if {
- output_decl.add_last ';';
- };
- output_decl.add_last '\n';
- (prototype.style = '-').if {
- string_tmp.append " lith_object thread;\n";
- (param_count != 0).if {
- 1.to param_count do { n:INTEGER;
- string_tmp.append " int param_";
- (n-1).append_in string_tmp;
- string_tmp.append ";\n";
- };
- };
- };
- 4.downto 0 do { j:INTEGER;
- tab := slot_size.item j;
- (tab.lower).to (tab.upper) do { i:INTEGER;
- slot_data := tab.item i;
- ((prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
- string_tmp.append " volatile ";
- } else {
- string_tmp.append " ";
- };
- slot_data.genere string_tmp;
- };
- tab.clear;
- };
-
- (Self = type_block).if {
- string_tmp.append " void *self;\n";
- };
-
- (string_tmp.is_empty).if {
- string_tmp.append " void *Nothing;\n";
- };
-
- (is_java).if {
- output_decl.append "static class __";
- output_decl.append intern_name;
- (is_late_binding).if {
- output_decl.append " extends __OBJ";
- };
- output_decl.append " {\n";
- output_decl.append string_tmp;
- (prototype.is_mapping).if {
- semantic_error (position,"Mapping is not yet implemented for Java code.");
- };
- (Self = type_string_constant).if {
- // STRING_CONSTANT constructor.
- output_decl.append "\n public __";
- output_decl.append intern_name;
- output_decl.add_last '(';
- (is_late_binding).if {
- output_decl.append "int pid,";
- };
- storage_slot := get_local_slot (ALIAS_STR.slot_storage).slot_data_intern;
- count_slot := get_local_slot (ALIAS_STR.slot_count).slot_data_intern;
- (count_slot.ensure_count != 0).if {
- output_decl.append "int pcount,";
- };
- (storage_slot.ensure_count != 0).if {
- output_decl.append "String pstorage,";
- };
- output_decl.remove_last 1;
- output_decl.append ")\n {\n ";
- (is_late_binding).if {
- output_decl.append "__id = pid;\n";
- };
- (count_slot.ensure_count != 0).if {
- output_decl.append (count_slot.intern_name);
- output_decl.append " = pcount;\n";
- };
- (storage_slot.ensure_count != 0).if {
- output_decl.append (storage_slot.intern_name);
- output_decl.append " = pstorage.toCharArray();\n";
- };
- output_decl.append " };\n";
- };
- // Basic Constructor.
- output_decl.append "\n public __";
- output_decl.append intern_name;
- output_decl.add_last '(';
- (is_late_binding).if {
- output_decl.append "int pid";
- };
- output_decl.append ")\n {\n ";
- (is_late_binding).if {
- output_decl.append "__id = pid;\n";
- } else {
- output_decl.append "super();\n";
- };
- output_decl.append " };\n};\n";
- }.elseif {alias_slot = NULL} then {
- output_decl.append "struct ";
- output_decl.append intern_name;
- output_decl.append "_struct {\n";
- output_decl.append string_tmp;
- (prototype.is_mapping).if {
- output_decl.append "} __attribute__ ((packed));\n";
- } else {
- output_decl.append "};\n";
+ backend.generate_type_struct_boolean_for Self in output_decl;
};
- };
- // Prototype declaration.
- (is_java).if {
- output_glob.append "private static __";
- output_glob.append intern_name;
- output_glob.add_last ' ';
- output_glob.append intern_name;
- output_glob.append "_=new __";
- output_glob.append intern_name;
- output_glob.add_last '(';
- (is_late_binding).if {
- output_glob.append "__";
- output_glob.append intern_name;
- output_glob.append "__";
- };
- output_glob.append ");\n";
- } else {
- output_glob.append "__";
- output_glob.append intern_name;
- output_glob.add_last ' ';
- output_glob.append intern_name;
- output_glob.add_last '_';
- (is_late_binding).if {
- output_glob.append "={__";
- output_glob.append intern_name;
- output_glob.append "__}";
- };
- output_glob.append ";\n";
- output_glob.append "#define ";
- output_glob.append intern_name;
- output_glob.append "__ (&";
- output_glob.append intern_name;
- output_glob.append "_)\n\n";
};
+
+ } else {
+
+ //
+ // Lisaac defined type
+ //
+
+ backend.generate_type_struct_header_for Self in output_decl;
+ backend.generate_type_struct_typeid_for Self in output_decl;
+ backend.generate_type_struct_for Self in output_decl;
+
};
+ backend.generate_type_globals_for Self in output_glob;
+
};
// Flag on (don't generate twice the code)
--
Lisaac compiler
More information about the Lisaac-commits
mailing list