[SCM] Lisaac compiler branch, mildred-backend, updated. lisaac-0.12-516-gd4d602b
Mildred Ki'Lya
silkensedai at online.fr
Tue Aug 25 17:27:43 UTC 2009
The following commit has been merged in the mildred-backend branch:
commit 3d4c4963245b31aebe455d849dbcb846c49c94d2
Merge: 28d9d0c75da142a9a424de1ee5f79dd9bfc1d07d adbd386c61091ac6931edf0b9e2a55b1e4fb664f
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Tue Aug 25 17:12:13 2009 +0200
merge with upstream
diff --combined lib_os/java/system/system.li
index 555d65e,555d65e..71c0048
--- a/lib_os/java/system/system.li
+++ b/lib_os/java/system/system.li
@@@ -75,7 -75,7 +75,7 @@@ Section SYSTEM,MEMOR
0
);
--Section ISAAC
++Section Public // ISAAC
- make <-
// Isaac compatibility.
diff --combined src/any.li
index e733e77,fb0d61a..f8adffa
--- a/src/any.li
+++ b/src/any.li
@@@ -91,7 -91,9 +91,9 @@@ Section Publi
- verbose_level:INTEGER;
- is_verbose:BOOLEAN <- (verbose_level != 0);
-
+
+ - is_readable:BOOLEAN;
+
//
// Other flags.
//
@@@ -126,7 -128,7 +128,7 @@@
- seq_or_and :UINTEGER_32; // || or &&
- seq_call_and_loop :UINTEGER_32; // Call or loop (or function).
- seq_call_local_and_loop:UINTEGER_32; // Call sensitive or loop.
- - seq_list:FAST_ARRAY[LIST] := FAST_ARRAY[LIST].create_with_capacity 64;
+ - seq_list:FAST_ARRAY(LIST) := FAST_ARRAY(LIST).create_with_capacity 64;
- is_seq_list l:LIST :BOOLEAN <-
( + result:BOOLEAN;
@@@ -148,8 -150,10 +150,10 @@@
- context_main:LOCAL;
- list_current:LIST;
-
- - stack_local:FAST_ARRAY[LOCAL] := FAST_ARRAY[LOCAL].create_with_capacity 64;
+
+ - current_list_level:INTEGER;
+
+ - stack_local:FAST_ARRAY(LOCAL) := FAST_ARRAY(LOCAL).create_with_capacity 64;
- profil_slot:PROFIL_SLOT; // Principal slot.
- profil_current:PROFIL; // Sub-profil or (profil = profil_slot)
@@@ -167,54 -171,28 +171,13 @@@
//
// Output Buffer and service.
//
-
- - var_size:FAST_ARRAY[FAST_ARRAY[LOCAL]] :=
- ( + result:FAST_ARRAY[FAST_ARRAY[LOCAL]];
-
- result := FAST_ARRAY[FAST_ARRAY[LOCAL]].create_with_capacity 4;
- 0.to 3 do { j:INTEGER;
- result.add_last (FAST_ARRAY[LOCAL].create_with_capacity 32);
- };
- result
- );
-
- - add_var_size v:LOCAL <-
- ( + tab:FAST_ARRAY[LOCAL];
- + j:INTEGER;
- + t:TYPE_FULL;
-
- ? {v.style = '+'};
-
- (v.style != '+').if {
- v.intern_name.print; " style [".print; v.style.print; "] ".print;
- '\n'.print;
- warning_error (v.position,"BUG ANY.add_var_size Error");
- };
- // BSBS: C'est pas top, avec des HASHED_SET ce serait mieux...
- t := v.type;
- tab := var_size.item (v.type.size);
- j := tab.lower;
- {(j <= tab.upper) && {tab.item j.type != t}}.while_do {
- j := j + 1;
- };
- (j > tab.upper).if {
- tab.add_last v;
- } else {
- {(j <= tab.upper) && {tab.item j != v} && {tab.item j.type = t}}.while_do {
- j := j + 1;
- };
- ((j > tab.upper) || {tab.item j != v}).if {
- tab.add v to j;
- };
- };
- );
-
+
- output_decl:STRING := STRING.create 60000;
- output_glob:STRING := STRING.create 10000;
- output_code:STRING := STRING.create 4000000;
- title txt:STRING_CONSTANT in buf:STRING <-
- (
- buf.append "\n//";
- 3.to 28 do { j:INTEGER;
- buf.add_last '=';
- };
- buf.append "//\n// ";
- buf.append txt;
- (txt.count+5).to 28 do { j:INTEGER;
- buf.add_last ' ';
- };
- buf.append " //\n//";
- 3.to 28 do { j:INTEGER;
- buf.add_last '=';
- };
- buf.append "//\n\n";
- );
+ backend.generate_title txt in buf;
- indent:STRING := STRING.create 128;
diff --combined src/code_life/call_slot.li
index f6c134c,6b682ca..efea9e2
--- a/src/code_life/call_slot.li
+++ b/src/code_life/call_slot.li
@@@ -64,15 -64,15 +64,15 @@@ Section Publi
// Argument.
//
- + argument_list:FAST_ARRAY[WRITE];
+ + argument_list:FAST_ARRAY(WRITE);
- + result_list:Expanded SLIM_ARRAY[RESULT];
+ + result_list:Expanded SLIM_ARRAY(RESULT); // BSBS: utiliter de RESULT ? => WRITE_LOCAL
+ cop_argument:EXPR;
+ is_cop_return:BOOLEAN;
- - set_args args:FAST_ARRAY[WRITE] <-
+ - set_args args:FAST_ARRAY(WRITE) <-
(
argument_list := args;
);
@@@ -86,14 -86,14 +86,14 @@@
// Creation.
//
- - create p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY[WRITE] cop arg:EXPR :SELF <-
+ - create p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY(WRITE) cop arg:EXPR :SELF <-
( + result:SELF;
result := clone;
result.make p profil prof with l_arg cop arg;
result
);
- - make p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY[WRITE] cop arg:EXPR <-
+ - make p:POSITION profil prof:PROFIL with l_arg:FAST_ARRAY(WRITE) cop arg:EXPR <-
( + n:INTEGER;
position := p;
cop_argument := arg;
@@@ -113,11 -113,11 +113,11 @@@
- my_copy:SELF <-
( + result:SELF;
+ wrt:WRITE;
- + new_arg:FAST_ARRAY[WRITE];
+ + new_arg:FAST_ARRAY(WRITE);
+ res:RESULT;
result := clone;
- new_arg := FAST_ARRAY[WRITE].create_with_capacity (argument_list.count);
+ new_arg := FAST_ARRAY(WRITE).create_with_capacity (argument_list.count);
(argument_list.lower).to (argument_list.upper) do { j:INTEGER;
(argument_list.item j = NULL).if {
wrt := NULL;
@@@ -183,8 -183,7 +183,7 @@@ Section Privat
+ is_good:BOOLEAN;
+ new_src:LIST;
+ wrt:WRITE;
- + old_val:EXPR;
- //+ rd:READ_LOCAL;
+ + old_val:EXPR;
+ loc:LOCAL;
+ prof_block:PROFIL_BLOCK;
@@@ -198,7 -197,7 +197,7 @@@
(
(! is_interrupt) && {! is_external} &&
{(cop_argument = NULL) || {! profil.result_list.is_empty}}
- ).if {
+ ).if {
(profil.link_count = 1).if {
//
// Inlining simple.
@@@ -234,19 -233,10 +233,10 @@@
//LOCAL.alias_on;
new_src := source.my_copy;
- argument_to_assignment new_src index 1 alias TRUE;
+ argument_to_assignment new_src index 1 alias TRUE;
(result_list.lower).to (result_list.upper) do { j:INTEGER;
wrt := result_list.item j.write;
- old_val := wrt.value;
- /*
- rd ?= old_val;
- loc := rd.local;
- (loc.my_alias = NULL).if {
- profil.slot.name.print; '\n'.print;
- warning_error (position,"CALL_SLOT : Result bizarre!");
- warning_error (profil.slot.position,"CALL_SLOT : Result bizarre!");
- crash_with_message "CALL_SLOT: Result not affect!";
- };*/
+ old_val := wrt.value;
wrt.set_value (old_val.my_copy);
old_val.remove;
new_src.add_last wrt;
@@@ -261,8 -251,7 +251,7 @@@
};
} else {
LOCAL.alias_off;
- };
-
+ };
//LOCAL.alias_off;
result := new_src.execute;
@@@ -363,7 -352,7 +352,7 @@@ Section Publi
//
- display_style buffer:STRING <-
- ( + t:HASHED_SET[TYPE];
+ ( + t:HASHED_SET(TYPE);
buffer.append (profil.name);
buffer.add_last '(';
@@@ -418,27 -407,100 +407,23 @@@
string_tmp.append ")\n";
string_tmp.print;
);
-
- //////////////////////////////////////////////////////////////////////////
- // CODE SLOT
- //////////////////////////////////////////////////////////////////////////
//
// Generation.
//
- genere buffer:STRING <-
- ( + val:WRITE;
- + arg:LOCAL;
- + wrt:WRITE_LOCAL;
- + np:INTEGER;
- + low:INTEGER;
- + back:INTEGER;
-
+ (
(cop_argument != NULL).if {
- (
- (argument_list.count >=1) &&
- {argument_list.first != NULL} &&
- {argument_list.first.variable.name = ALIAS_STR.variable_self}
- ).if {
- low := 1;
- };
- (argument_list.count-low > 0).if {
- back := buffer.count;
- buffer.append "pthread_mutex_lock (&(";
- cop_argument.genere buffer;
- buffer.append "->thread.mutex));\n";
- (low).to (argument_list.upper) do { j:INTEGER;
- val := argument_list.item j;
- (val != NULL).if {
- buffer.append indent;
- cop_argument.genere buffer;
- buffer.append "->param_";
- np.append_in buffer;
- buffer.append "=(int)";
- val.genere_value buffer;
- buffer.append ";\n";
- np := np + 1;
- } else {
- "arg null\n".print;
- };
- };
- buffer.append indent;
- (np = 0).if {
- buffer.keep_head back;
- };
- };
- cop_argument.genere buffer;
- buffer.append "->thread.procedure = COP_";
- buffer.append (profil.name);
- buffer.append ";\n";
- buffer.append indent;
- (is_cop_return).if {
- buffer.append "return";
- } else {
- buffer.append "run_procedure";
- };
- buffer.append "((lith_object *)";
- cop_argument.genere buffer;
- buffer.add_last ')';
- } else {
- (result_list.is_empty).if_false {
- wrt ?= result_list.first.write;
- wrt.genere_first_result buffer;
- };
- buffer.append (profil.name);
- (is_interrupt || {is_external}).if {
+ backend.generate_cop_call_slot Self in buffer;
+ } else {
+ ((is_interrupt) || {is_external}).if {
(argument_list.first != NULL).if {
semantic_error (argument_list.first.position,
"Impossible `Self' argument for External or Interrupt slot.");
};
};
- (! is_interrupt).if {
- buffer.add_last '(';
- (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
- val := argument_list.item j;
- arg := profil.argument_list.item j;
- (val != NULL).if {
- (buffer.last != '(').if {
- buffer.add_last ',';
- };
- val.genere_value buffer;
- };
- };
- (result_list.count > 1).if {
- (result_list.lower+1).to (result_list.upper) do { j:INTEGER;
- (buffer.last != '(').if {
- buffer.add_last ',';
- };
- wrt ?= result_list.item j.write;
- wrt.genere_argument_result buffer;
- };
- };
- buffer.add_last ')';
- };
+ backend.generate_call_slot Self in buffer;
};
);
@@@ -456,6 -518,7 +441,7 @@@ Section Privat
+ new_val:EXPR;
+ new_wrt:INSTR;
+ result:LOOP;
+ + push:PUSH;
result := LOOP.create position name (profil.name) body source;
@@@ -490,12 -553,9 +476,9 @@@
};
(debug_level_option != 0).if {
- ? { + push:PUSH;
- push ?= source.first;
- (push != NULL) && {push.is_first}
- };
- list_current.insert (source.first) to (list_current.index);
- source.put NOP to (source.lower);
+ push ?= source.first;
+ list_current.insert (push.my_copy) to (list_current.index);
+ push.set_first FALSE;
};
// Extract Switch/body:
@@@ -533,7 -593,7 +516,7 @@@
(is_alias).if {
loc ?= val.variable;
new_wrt := loc.write (val.position) value (val.value);
- loc.unwrite val;
+ loc.unwrite val;
} else {
new_wrt := val;
};
diff --combined src/code_life/list.li
index e30e89c,fee4f98..6998cfb
--- a/src/code_life/list.li
+++ b/src/code_life/list.li
@@@ -34,7 -34,7 +34,7 @@@ Section Inheri
Section Private
- + expr_list:FAST_ARRAY[INSTR];
+ + expr_list:FAST_ARRAY(INSTR);
Section Public
@@@ -148,16 -148,7 +148,7 @@@
(
new_depend_pass;
position := p;
- expr_list := FAST_ARRAY[INSTR].create_with_capacity 2;
- /*
- "execute list #".print;
- object_id.print; '\n'.print;
- (object_id = 220500).if {
- // crash_with_message "BUG!!!";
- };
- */
-
-
+ expr_list := FAST_ARRAY(INSTR).create_with_capacity 2;
);
- my_copy:SELF <-
@@@ -214,7 -205,7 +205,7 @@@
- execute_case <-
( + new_expr:INSTR;
+ old_list_current:LIST;
-
+
//
seq_list.add_last Self;
seq_inline := seq_inline + 1;
@@@ -262,10 -253,19 +253,12 @@@ Section Publi
//
- genere buffer:STRING <-
- (
- buffer.append "{\n";
- indent.append " ";
-
+ (
+ backend.generate_function_header_in buffer;
+ current_list_level := current_list_level + 1;
-
genere_body buffer;
-
+ current_list_level := current_list_level - 1;
-
- indent.remove_last 2;
- buffer.append indent;
- buffer.add_last '}';
+ backend.generate_function_footer_in buffer;
);
- genere_extern buffer:STRING <-
@@@ -275,14 -275,16 +268,16 @@@
pos_local := buffer.count+1;
stack_local.clear;
+ ALIASER_LOCAL.reset;
+
genere_body buffer;
// Local.
string_tmp.clear;
- add_local (var_size.item 3) in string_tmp; // 64 bits
- add_local (var_size.item 2) in string_tmp; // 32 bits
- add_local (var_size.item 1) in string_tmp; // 16 bits
- add_local (var_size.item 0) in string_tmp; // 8 bits
+ add_local (ALIASER_LOCAL.var_size.item 3) in string_tmp; // 64 bits
+ add_local (ALIASER_LOCAL.var_size.item 2) in string_tmp; // 32 bits
+ add_local (ALIASER_LOCAL.var_size.item 1) in string_tmp; // 16 bits
+ add_local (ALIASER_LOCAL.var_size.item 0) in string_tmp; // 8 bits
buffer.insert_string string_tmp to pos_local;
);
@@@ -315,30 -317,80 +310,56 @@@
Section Private
- genere_body buffer:STRING <-
- ( + old_count,j:INTEGER;
- j := lower;
- {j <= upper}.while_do {
- buffer.append indent;
- old_count := buffer.count;
- {
- item j.genere buffer;
- j := j + 1;
- }.do_while {(j <= upper) && {old_count = buffer.count}};
- buffer.append ";\n";
- };
- );
+ (
+ lower.to (upper) do { i:INTEGER;
+ backend.generate_function_instruction (item i) in buffer;
+ };
- /*
- + old_count,j:INTEGER;
- j := lower;
- {j <= upper}.while_do {
- buffer.append indent;
- old_count := buffer.count;
- {
- item j.genere buffer;
- j := j + 1;
- }.do_while {(j <= upper) && {old_count = buffer.count}};
- buffer.append ";\n";
- };
- */
+ );
- - add_local tab:FAST_ARRAY[LOCAL] in buf:STRING <-
- (
+ - add_local tab:FAST_ARRAY(LOCAL) in buf:STRING <-
+ ( + loc:LOCAL;
- + t:TYPE_FULL;
- + cur:INTEGER;
- //+ i:INTEGER;
-
(! tab.is_empty).if {
+ (tab.lower).to (tab.upper) do { j:INTEGER;
+ loc := tab.item j;
+ loc.is_result.if_false {
+ (loc.type.raw = TYPE_CONTEXT).if {
+ context_counter := context_counter + 1;
+ } else {
+ local_counter := local_counter + 1;
+ };
++
+ /*
+ (
+ (loc.ensure_count != 0) &&
+ {profil_current != NULL} &&
+ {loc.type.raw != TYPE_CONTEXT}
+ ).if {
+ i := profil_current.result_list.lower;
+ {
+ (i <= profil_current.result_list.upper) &&
+ {profil_current.result_list.item i != loc}
+ }.while_do {
+ i := i + 1;
+ };
+ (i > profil_current.result_list.upper).if {
+
+ loc.intern_name.print;
+ ' '.print;
+ loc.ensure_count.print;
+ '\n'.print;
+
+ };
+ };
+ */
- (((buf.count + loc.intern_name.count - cur) > 70) || {t != loc.type}).if {
- // New line
- (t != NULL).if {
- buf.append ";\n";
- };
- cur := buf.count;
- t := loc.type;
- buf.append indent;
- t.genere_declaration buf;
- buf.add_last ' ';
- } else {
- buf.add_last ',';
- };
- t.genere_star_declaration buf;
- buf.append (loc.intern_name);
+ };
+ };
- buf.append ";\n";
++
+ backend.generate_function_locals tab in buf;
- tab.clear;
};
);
+
+ Section LISAAC
+ - local_counter:INTEGER;
+
+ - context_counter:INTEGER;
diff --combined src/code_life/loop.li
index 484b8d6,1072b73..d60fcd4
--- a/src/code_life/loop.li
+++ b/src/code_life/loop.li
@@@ -177,7 -177,13 +177,8 @@@ Section Publi
- genere buffer:STRING <-
(
(! genere_while buffer).if {
-
+ current_list_level := current_list_level + link_count;
-
- buffer.append name;
- buffer.append ":\n";
- buffer.append indent;
- body.genere buffer;
+ backend.generate_loop Self in buffer;
};
);
@@@ -205,30 -211,45 +206,34 @@@
lst := lst_true;
lst_true := lst_false;
lst_false := lst;
- };
+ };
+
+ current_list_level := current_list_level + 1;
+
(body.count = 1).if {
//
// While (...) do {...}.
//
result := TRUE;
- inverse.if {
- buffer.append "while (!";
- } else {
- buffer.append "while (";
- };
- switch.expr.genere buffer;
- //
- buffer.append ") ";
- lst_true.remove_last;
- lst_true.genere buffer;
+ lst_true.remove_last;
+ backend.generate_loop_while_do Self
+ condition (switch.expr)
+ inverse inverse
+ body lst_true
+ in buffer;
}.elseif {lst_true.count = 1} then {
//
// Do {...} while (...).
//
result := TRUE;
- buffer.append "do ";
- body.remove_last;
- body.genere buffer;
- inverse.if {
- buffer.append " while (!";
- } else {
- buffer.append " while (";
- };
- //
- switch.expr.genere buffer;
- buffer.add_last ')';
- };
-
- current_list_level := current_list_level - 1;
-
+ body.remove_last;
+ backend.generate_loop_do_while Self
+ condition (switch.expr)
+ inverse inverse
+ body body
+ in buffer;
- };
++ };
++ current_list_level := current_list_level - 1;
};
};
result
diff --combined src/code_life/loop_end.li
index 39c94c3,dfd5891..2486cbc
--- a/src/code_life/loop_end.li
+++ b/src/code_life/loop_end.li
@@@ -104,7 -104,10 +104,8 @@@ Section Publi
//
- genere buffer:STRING <-
- (
- buffer.append "goto ";
- buffer.append (loop.name);
-
- current_list_level := current_list_level - 1;
+ (
+ backend.generate_loop_end Self in buffer;
++ current_list_level := current_list_level - 1;
);
diff --combined src/code_life/push.li
index 725b1f9,1621cd4..b8743a8
--- a/src/code_life/push.li
+++ b/src/code_life/push.li
@@@ -32,10 -32,10 +32,10 @@@ Section Inheri
+ parent_instr:Expanded INSTR;
-Section PUSH,LISAAC
+Section PUSH,LISAAC,BACKEND
- - source_line:HASHED_DICTIONARY[STRING,UINTEGER_32] :=
- HASHED_DICTIONARY[STRING,UINTEGER_32].create;
+ - source_line:HASHED_DICTIONARY(STRING,UINTEGER_32) :=
+ HASHED_DICTIONARY(STRING,UINTEGER_32).create;
Section Public
@@@ -122,16 -122,30 +122,14 @@@
- genere buffer:STRING <-
( + id:UINTEGER_32;
-
- add_var_size context;
- + idf:STRING_CONSTANT;
-
- idf := ALIASER_LOCAL.push Self;
- (is_first).if {
- buffer.append "push_first(&";
- } else {
- buffer.append "push(&";
- };
- buffer.append idf;
- buffer.add_last ',';
id := position.code;
(debug_with_code).if {
(! source_line.fast_has id).if {
source_line.fast_put (position.extract_line) to id;
};
- buffer.add_last 'L';
};
- id.append_in buffer;
- buffer.add_last ')';
-
- buffer.append "; // L";
- position.line.append_in buffer;
- buffer.add_last ' ';
- buffer.append (position.prototype.name);
+
+ backend.generate_push Self id id in buffer;
);
//
diff --combined src/code_life/read_slot.li
index 2072706,d425a36..0349f59
--- a/src/code_life/read_slot.li
+++ b/src/code_life/read_slot.li
@@@ -50,7 -50,7 +50,7 @@@ Section Publi
// Comparison.
//
- - '==' Right 60 other:EXPR :BOOLEAN <-
+ - Self:SELF '==' Right 60 other:EXPR :BOOLEAN <-
( + rd:READ_SLOT;
rd ?= other;
@@@ -110,8 -110,67 +110,8 @@@
//
- genere buffer:STRING <-
- ( + tf,tf2:TYPE_FULL;
- + t:TYPE;
- + add_end:BOOLEAN;
- + ptr,ptr2:BOOLEAN;
-
- (is_java).if {
- receiver.genere buffer;
- //not_yet_implemented;
- buffer.add_last '.';
- buffer.append (variable.intern_name);
- } else {
- (slot.intern_name = ALIAS_STR.slot_self).if {
- buffer.append "((";
- tf := slot.type;
- tf.genere_declaration buffer;
- buffer.add_last ' ';
- tf.genere_star_declaration buffer;
- buffer.add_last ')';
- receiver.genere buffer;
- buffer.append ".self)";
- } else {
- tf := receiver.static_type;
- t := slot.receiver_type;
- (t.alias_slot != NULL).if {
- tf2 := slot.type;
- ptr := (! tf .is_expanded) || {tf .is_expanded_ref} || {tf .is_strict};
- ptr2 := (! tf2.is_expanded) || {tf2.is_expanded_ref} || {tf2.is_strict};
- (ptr != ptr2).if {
- add_end := TRUE;
- (ptr).if {
- buffer.append "(*(";
- } else {
- buffer.append "(&(";
- };
- };
- };
- (
- (tf.is_strict) || {tf.is_expanded_ref} || {tf.is_expanded}
- ).if {
- receiver.genere buffer;
- } else {
- buffer.append "((";
- t.put_reference_declaration buffer;
- buffer.add_last ' ';
- t.put_reference_star_declaration buffer;
- buffer.add_last ')';
- receiver.genere buffer;
- buffer.add_last ')';
- };
- (t.alias_slot = NULL).if {
- ((tf.is_expanded) && {! tf.is_expanded_ref} && {! tf.is_strict}).if {
- buffer.add_last '.';
- } else {
- buffer.append "->";
- };
- buffer.append (variable.intern_name);
- }.elseif {add_end} then {
- buffer.append "))";
- };
- };
- };
+ (
+ backend.generate_read_slot_for Self in buffer;
);
//
diff --combined src/code_life/switch.li
index 3065015,07539f0..408ea29
--- a/src/code_life/switch.li
+++ b/src/code_life/switch.li
@@@ -28,7 -28,7 +28,7 @@@ Section Heade
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- comment := "Switch for late binding resolution";
- // BSBS: Optim. : D�tecter les switch identique l'un apr�s l'autre
+ // BSBS: Optim. : Détecter les switch identique l'un après l'autre
// pour les fusionner...
Section Inherit
@@@ -54,7 -54,7 +54,7 @@@ Section Publi
+ expr:EXPR;
- + list:FAST_ARRAY[CASE];
+ + list:FAST_ARRAY(CASE);
- count:INTEGER <- list.count;
@@@ -75,7 -75,7 +75,7 @@@
( + first:CASE;
position := n.position;
expr := e;
- list := FAST_ARRAY[CASE].create_with_capacity s;
+ list := FAST_ARRAY(CASE).create_with_capacity s;
(n.first_code != NULL).if {
first := CASE.create (n.first_type) with (n.first_code);
list.add_last first;
@@@ -86,7 -86,7 +86,7 @@@
// Copy.
//
- - set_expr e:EXPR list l:FAST_ARRAY[CASE] <-
+ - set_expr e:EXPR list l:FAST_ARRAY(CASE) <-
(
expr := e;
list := l;
@@@ -94,9 -94,9 +94,9 @@@
- my_copy:SELF <-
( + result:SELF;
- + new_list:FAST_ARRAY[CASE];
+ + new_list:FAST_ARRAY(CASE);
- new_list := FAST_ARRAY[CASE].create_with_capacity (list.count);
+ new_list := FAST_ARRAY(CASE).create_with_capacity (list.count);
(list.lower).to (list.upper) do { j:INTEGER;
new_list.add_last (list.item j.my_copy);
};
@@@ -225,12 -225,19 +225,19 @@@
list.first .set_code (list.second.code);
list.second.set_code lst;
};
+ /*
+ seq_or_and := seq_or_and + 1;
+ seq_inline := seq_inline + 1;
+ */
expr := expr.execute_link;
CALL_SLOT.reset_count_no_recursive;
((list.first.id = TYPE_NULL) && {list.count = 2}).if {
list.first .code.execute_case;
- list.second.code.execute_case;
+ list.second.code.execute_case;
+ ((list.second.id.is_block) && {debug_level_option != 0}).if {
+ list.second.id.set_late_binding;
+ };
} else {
(list.lower).to (list.upper) do { j:INTEGER;
list.item j.execute;
@@@ -248,59 -255,122 +255,78 @@@
// Genere.
//
+ - bug_count:INTEGER;
+
- genere buffer:STRING <-
- ( + lst:LIST;
- + first_case:INTEGER;
- + typ_first:TYPE;
- + typ_id:TYPE_ID;
- + wrt:WRITE;
- + is_genered:BOOLEAN;
+ ( + first_case:INTEGER;
- + typ_first:TYPE;
- + wrt:WRITE;
- + i:INTEGER;
- + gen_else_end:BOOLEAN;
-
+ + c1,c2:CASE;
- + lst_case:FAST_ARRAY(CASE);
+ + cases:FAST_ARRAY(FAST_ARRAY(CASE));
-
++ + gen_switch:{};
++
++ gen_switch := { is_genered:BOOLEAN;
++ (first_case <= list.upper).if {
++ (is_genered).if {
++ expr := expr.my_copy;
++ };
++ cases := case_fusion first_case;
++ (cases.count = 2).if {
++ (cases.first.count = 1).if {
++ c1 := cases.first.first;
++ c2 := cases.second.first;
++ }.elseif {cases.second.count = 1} then {
++ c1 := cases.second.first;
++ c2 := cases.first.first;
++ };
++ };
++ (c1 != NULL).if {
++ generate_if c1 else c2 in buffer;
++ } else {
++ polymorphic_counter := polymorphic_counter + 1;
++ backend.generate_switch cases for Self first_case first_case in buffer;
++ };
++ free_list_cases cases;
++ };
++ };
++
(
(list.first.id = TYPE_NULL) &&
{debug_level_option = 0} &&
{! list.first.code.is_empty} &&
-- {
++ { + wrt:WRITE;
wrt ?= list.first.code.first; // For ?= with NULL type.
wrt = NULL
}
).if {
list.remove_first;
- };
- typ_first := list.first.id;
- typ_id ?= typ_first;
- ((list.count <= 2) || {typ_first = TYPE_NULL}).if {
- buffer.append "if (";
- //
- ((expr.static_type.raw.is_block) && {typ_first = TYPE_NULL}).if {
- expr.genere buffer;
- is_genered := TRUE;
- buffer.append ".__id==0";
- } else {
- typ_first.put_access_id expr in buffer;
- is_genered := TRUE;
- (expr.static_type.raw != type_boolean).if {
- buffer.append "==";
- typ_first.put_id buffer;
- } else {
- ? {typ_first.shortname = ALIAS_STR.prototype_true};
- };
- };
- buffer.append ") ";
+ };
- i := list.upper;
- {i >= list.lower}.while_do {
- (list.item i.code.is_empty).if {
- list.remove i;
- };
- i := i - 1;
- };
- //
- (list.is_empty).if_false {
- typ_first := list.first.id;
++
++ (list.count <= 2).if {
+
+ //
- // Generate If
- // - when there is a test for NULL
- // - when there are at most two cases
++ // Generate If / Else
+ //
- ((list.count <= 2) || {typ_first = TYPE_NULL}).if {
- first_case := backend.generate_if Self in buffer;
- (list.count > 2).if {
- backend.generate_if_else_begin Self in buffer;
- gen_else_end := TRUE;
- };
- };
++
++ first_case := 2;
++ backend.generate_if_else Self in buffer;
++
++ }.elseif {list.first.id = TYPE_NULL} then {
+
+ //
- // Generate switch
++ // Generate If / Else (switch)
//
- (first_case <= list.upper).if {
- polymorphic_counter := polymorphic_counter + 1;
- backend.generate_switch Self first_case first_case in buffer;
- };
- list.first.genere buffer;
+
- gen_else_end.if {
- backend.generate_if_else_end Self in buffer;
- };
+ first_case := 1;
++ backend.generate_if Self else { gen_switch.value TRUE; } in buffer;
++
++ } else {
++
+ //
- (list.count = 2).if {
- lst := list.second.code;
- (! list.second.code.is_empty).if {
- buffer.append " else ";
- buffer.append "/* ";
- buffer.append (list.second.id.name);
- buffer.append " */ ";
- list.second.genere buffer;
- };
- first_case := 2;
- }.elseif {list.count > 2} then {
- buffer.append " else {\n";
- indent.append " ";
- buffer.append indent;
- };
- };
- (first_case <= list.upper).if {
- (is_genered).if {
- expr := expr.my_copy;
- };
- cases := case_fusion first_case;
- (cases.count = 2).if {
- (cases.first.count = 1).if {
- c1 := cases.first.first;
- c2 := cases.second.first;
- }.elseif {cases.second.count = 1} then {
- c1 := cases.second.first;
- c2 := cases.first.first;
- };
- };
- (c1 != NULL).if {
- buffer.append "if (";
- c1.id.put_access_id expr in buffer;
- buffer.append "==";
- c1.id.put_id buffer;
- buffer.append ") ";
- c1.genere buffer;
- buffer.append " else /* Other types */ ";
- c2.genere buffer;
- } else {
- polymorphic_counter := polymorphic_counter + 1;
- buffer.append "switch (";
- list.item first_case.id.put_access_id expr in buffer;
- buffer.append ") {\n";
- (cases.lower).to (cases.upper) do { j:INTEGER;
- lst_case := cases.item j;
- (! lst_case.first.code.is_empty).if {
- (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
- buffer.append indent;
- buffer.append "case ";
- lst_case.item i.id.put_id buffer;
- buffer.append ": \n";
- };
- buffer.remove_last 1;
- lst_case.first.genere buffer;
- buffer.append " break;\n";
- };
- };
- buffer.append indent;
- buffer.add_last '}';
- };
- free_list_cases cases;
- (first_case != 0).if {
- buffer.add_last '\n';
- indent.remove_last 2;
- buffer.append indent;
- buffer.add_last '}';
- };
++ // Generate Switch
++ //
++
++ first_case := 0;
++ gen_switch.value FALSE;
++
};
);
@@@ -309,7 -379,7 +335,7 @@@
//
- display buffer:STRING <-
- ( + line:BLOCK;
+ ( + line:{INTEGER; };
line :=
{ j:INTEGER;
@@@ -474,7 -544,7 +500,7 @@@ Section Privat
);
- concat_switch other:SWITCH <-
- ( + other_list:FAST_ARRAY[CASE];
+ ( + other_list:FAST_ARRAY(CASE);
+ code:LIST;
other.expr.remove;
@@@ -484,4 -554,75 +510,75 @@@
code.add_last (other_list.item j.code);
};
new_execute_pass;
+ );
+
+ //
+ // Case fusion manager.
+ //
+
+ - store_list_cases:FAST_ARRAY(FAST_ARRAY(FAST_ARRAY(CASE))) :=
+ FAST_ARRAY(FAST_ARRAY(FAST_ARRAY(CASE))).create_with_capacity 32;
+
+ - store_cases:FAST_ARRAY(FAST_ARRAY(CASE)) :=
+ FAST_ARRAY(FAST_ARRAY(CASE)).create_with_capacity 32;
+
+ - new_cases:FAST_ARRAY(CASE) <-
+ ( + result:FAST_ARRAY(CASE);
+ (store_cases.is_empty).if {
+ result := FAST_ARRAY(CASE).create_with_capacity 32;
+ } else {
+ result := store_cases.last;
+ store_cases.remove_last;
+ };
+ result
+ );
+
+ - new_list_cases:FAST_ARRAY(FAST_ARRAY(CASE)) <-
+ ( + result:FAST_ARRAY(FAST_ARRAY(CASE));
+ (store_list_cases.is_empty).if {
+ result := FAST_ARRAY(FAST_ARRAY(CASE)).create_with_capacity 32;
+ } else {
+ result := store_list_cases.last;
+ store_list_cases.remove_last;
+ };
+ result
+ );
+
+ - free_list_cases l:FAST_ARRAY(FAST_ARRAY(CASE)) <-
+ ( + lst:FAST_ARRAY(CASE);
+ (l.lower).to (l.upper) do { i:INTEGER;
+ lst := l.item i;
+ lst.clear;
+ store_cases.add_last lst;
+ };
+ l.clear;
+ store_list_cases.add_last l;
+ );
+
+ - case_fusion low:INTEGER :FAST_ARRAY(FAST_ARRAY(CASE)) <-
+ ( + c1,c2:CASE;
+ + lst:FAST_ARRAY(CASE);
+ + j:INTEGER;
+ + result:FAST_ARRAY(FAST_ARRAY(CASE));
+
+ result := new_list_cases;
+ (low).to (list.upper) do { i:INTEGER;
+ c1 := list.item i;
+ lst := NULL;
+ j := result.lower;
+ {(j <= result.upper) && {lst = NULL}}.while_do {
+ c2 := result.item j.first;
+ (c1 == c2).if {
+ lst := result.item j;
+ c1.code.remove;
+ };
+ j := j + 1;
+ };
+ (lst = NULL).if {
+ lst := new_cases;
+ result.add_last lst;
+ };
+ lst.add_last c1;
+ };
+ result
);
diff --combined src/code_life/write.li
index 5f54233,0c4bfbb..6f73751
--- a/src/code_life/write.li
+++ b/src/code_life/write.li
@@@ -67,7 -67,7 +67,7 @@@ Section Publi
- variable:VARIABLE <-
(
- deferred;
+ deferred;
NULL
);
@@@ -76,7 -76,7 +76,7 @@@
variable.type
);
- + value : EXPR;
+ + value:EXPR;
- set_value new:EXPR <-
(
@@@ -118,7 -118,6 +118,6 @@@
+ read:READ;
+ val:INSTR;
+ slot:SLOT_DATA;
- //+ old_loop_invariant:LOOP;
? { variable != NULL };
? { value != NULL };
@@@ -185,32 -184,37 +184,15 @@@
(
variable.unwrite Self;
value.remove;
- //free_allocation_memory;
);
//
// Genere
//
-
- - genere buffer:STRING <-
- ( + loc:LOCAL;
- + slo:SLOT;
--
- (is_local).if { // BSBS: Pour finir, il faut sp�cialiser les READ, WRITE avec multiheritage
- loc ?= variable;
- add_var_size loc;
- } else {
- slo ?= variable;
- slo.receiver_type.add_genere_list;
- };
- (quiet_generation).if_false {
- backend.generate_write_for Self in buffer;
- };
- );
-
++
- genere_value buffer:STRING <-
- (
- (is_java).if {
- value.genere buffer;
- } else {
- (
- (static_type.is_expanded_ref) &&
- {! value.static_type.is_expanded_ref}
- ).if {
- ? {value.static_type.is_expanded};
- buffer.append "&(";
- value.genere buffer;
- buffer.add_last ')';
- }.elseif {
- (static_type.is_expanded) && {! static_type.is_expanded_ref} &&
- {(! value.static_type.is_expanded) || {value.static_type.is_expanded_ref}} &&
- {value.static_type.raw != TYPE_NULL} // For Pointer := NULL
- } then {
- buffer.append "*(";
- value.genere buffer;
- buffer.add_last ')';
- } else {
- value.genere buffer;
- };
- };
+ (
+ backend.generate_write_value_for Self in buffer;
);
//
diff --combined src/code_life/write_slot.li
index e136b83,594b72f..f34956e
--- a/src/code_life/write_slot.li
+++ b/src/code_life/write_slot.li
@@@ -68,6 -68,9 +68,9 @@@ Section Publi
new_val := value.my_copy;
result ?= variable.write position with (receiver.my_copy) value new_val;
+ (quiet_generation).if {
+ result.set_quiet_generation;
+ };
result
);
@@@ -98,10 -101,49 +101,12 @@@
//
- genere buffer:STRING <-
- (
- slot.receiver_type.add_genere_list;
- (quiet_generation).if_false {
- ( + tf:TYPE_FULL;
- + t:TYPE;
-
++ ( + t :TYPE;
++
+ t := slot.receiver_type;
+ t.add_genere_list;
+ ((! quiet_generation) && {t.alias_slot != variable}).if {
- // Receiver.
- (quiet_generation).if {
- buffer.append "/* WRTOK */";
- } else {
- buffer.append "/* WRTNO */";
- };
- (is_java).if {
- receiver.genere buffer;
- buffer.add_last '.';
- } else {
- tf := receiver.static_type;
- ((tf.is_strict) || {tf.is_expanded_ref}).if {
- receiver.genere buffer;
- buffer.append "->";
- }.elseif {tf.is_expanded} then {
- receiver.genere buffer;
- buffer.add_last '.';
- } else {
- buffer.append "((";
- t := slot.receiver_type;
- t.put_reference_declaration buffer;
- buffer.add_last ' ';
- t.put_reference_star_declaration buffer;
- buffer.add_last ')';
- receiver.genere buffer;
- buffer.append ")->";
- };
- };
- //
- buffer.append (variable.intern_name);
- //
- ((value.static_type.raw = TYPE_NULL) && {variable.type.raw.is_block}).if {
- buffer.append ".__id=0";
- } else {
- buffer.add_last '=';
- genere_value buffer;
- };
+ backend.generate_write_slot_for Self in buffer;
};
);
diff --combined src/constant/string_cst.li
index 5f2bd28,ad01eb0..60f138d
--- a/src/constant/string_cst.li
+++ b/src/constant/string_cst.li
@@@ -34,8 -34,15 +34,8 @@@ Section Inheri
Section Public
- - output:STRING :=
- ( + result:STRING;
-
- result := STRING.create 256;
- title "STRING CONSTANT" in result;
- result
- );
-
- - output_count:INTEGER;
+ - output:STRING <- backend.string_constant_declaration;
+ - output_count:INTEGER <- backend.string_constant_count;
//
// Value.
@@@ -68,7 -75,7 +68,7 @@@
// Comparaison.
//
- - '==' Right 60 other:EXPR :BOOLEAN <-
+ - Self:SELF '==' Right 60 other:EXPR :BOOLEAN <-
( + p:STRING_CST;
p ?= other;
(p != NULL) && {string = p.string}
@@@ -79,8 -86,93 +79,8 @@@
//
- genere buffer:STRING <-
- ( + idx,count,cur:INTEGER;
-// + count_esc:INTEGER;
-// + esc_octal:BOOLEAN;
-// + esc_hexa :BOOLEAN;
- - is_init:BOOLEAN;
- - is_storage:BOOLEAN;
- - is_count:BOOLEAN;
-
- (is_init).if_false {
- is_storage := type_string_constant.get_local_slot (ALIAS_STR.slot_storage)
- .slot_data_intern.ensure_count != 0;
- is_count := type_string_constant.get_local_slot (ALIAS_STR.slot_count)
- .slot_data_intern.ensure_count != 0;
- is_init := TRUE;
- };
-
- count := dico_string.fast_at string;
- (count >= 0).if {
- output_count := output_count + 1;
- idx := output_count;
-
- cur := output.count - 1;
- (is_java).if {
- output.append "private static ";
- };
- output.append "__";
- output.append (type_string_constant.intern_name);
- ((output.count - cur) >= 78).if {
- output.add_last '\n';
- cur := output.count - 1;
- } else {
- output.add_last ' ';
- };
- output.append "__string_";
- idx.append_in output;
- output.add_last '=';
- (is_java).if {
- output.append "new __STRING_CONSTANT(";
- } else {
- output.add_last '{';
- (static_type.is_late_binding).if {
- output.append "__";
- output.append (static_type.raw.intern_name);
- output.append "__,";
- };
- };
- (is_count).if {
- count.append_in output;
- output.add_last ',';
- };
- (is_storage).if {
- ((output.count - cur) >= 78).if {
- output.add_last '\n';
- cur := output.count - 1;
- };
- output.add_last '\"';
-// output.append string;
-// {(output.count - cur) > 78}.while_do {
-// output.insert_string "\\\n" to (cur+78);
-// cur := cur + 78;
-// };
- backend.append_escaped_string string
- in output
- split_every 78
- starting (output.count - cur);
- output.add_last '\"';
- } else {
- output.remove_last 1;
- };
- (is_java).if {
- output.append ");\n";
- } else {
- output.append "};\n";
- };
- dico_string.fast_put (-idx) to string;
- } else {
- idx := -count;
- };
- //
- (is_java).if {
- buffer.append "__string_";
- idx.append_in buffer;
- } else {
- buffer.append "(&__string_";
- idx.append_in buffer;
- buffer.add_last ')';
- };
+ (
+ backend.generate_string_constant Self in buffer;
);
//
@@@ -90,10 -182,10 +90,10 @@@
- display buffer:STRING <- BACKEND_C.append_string string in buffer;
-Section Private
+Section BACKEND
- - dico_string:HASHED_DICTIONARY[INTEGER,STRING_CONSTANT] :=
- HASHED_DICTIONARY[INTEGER,STRING_CONSTANT].create;
+ - dico_string:HASHED_DICTIONARY(INTEGER,STRING_CONSTANT) :=
+ HASHED_DICTIONARY(INTEGER,STRING_CONSTANT).create;
diff --combined src/external/put_to.li
index a736e0b,0baefaf..d6da36b
--- a/src/external/put_to.li
+++ b/src/external/put_to.li
@@@ -26,7 -26,7 +26,7 @@@ Section Heade
- author := "Sonntag Benoit (bsonntag at loria.fr)";
- - comment := "Put for NATIVE_ARRAY[E] (see ITEM)";
+ - comment := "Put for NATIVE_ARRAY(E) (see ITEM)";
Section Inherit
@@@ -130,15 -130,13 +130,15 @@@ Section Publi
- genere buffer:STRING <-
( + type_generic:TYPE_GENERIC;
+ first_type:TYPE_FULL;
-
+ type_generic ?= receiver.static_type.raw;
+ first_type := type_generic.generic_list.first;
+
+ backend.generate_put_to Self for_type first_type in buffer;
+ /*
receiver.genere buffer;
buffer.add_last '[';
index.genere buffer;
buffer.append "]=";
- type_generic ?= receiver.static_type.raw;
- first_type := type_generic.generic_list.first;
((first_type.is_expanded) && {! first_type.is_expanded_c}).if {
(value.static_type.is_expanded_ref).if {
buffer.append "*(";
@@@ -150,7 -148,6 +150,7 @@@
} else {
value.genere buffer;
};
+ */
);
//
diff --combined src/lisaac.li
index 39da519,b846a16..efc374e
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@@ -32,7 -32,7 +32,7 @@@ Section Heade
// Top 5 memory record :
// 1 - LOCAL (>20MB) (il fo Aliaser les tmp !)
// 2 - READ_LOCAL (15MB)
- // 3 - LIST (13MB) (En baisse => a retester)
+ // 3 - LIST (13MB) (En baisse => a retester.)
// 4 - PROTOTYPE_CST (10MB)
// 5 - WRITE_LOCAL (10MB)
@@@ -43,7 -43,7 +43,7 @@@ Section Inheri
Section Public
- path_lisaac:STRING_CONSTANT <-
- ( + path:NATIVE_ARRAY[CHARACTER];
+ ( + path:NATIVE_ARRAY(CHARACTER);
+ path_str :STRING;
+ j:INTEGER;
//COMMAND_LINE.executable_name.print; '\n'.print;
@@@ -52,7 -52,7 +52,7 @@@
(path_str != NULL).if {
string_tmp.copy path_str;
} else {
- path := `LISAAC_DIRECTORY`:NATIVE_ARRAY[CHARACTER];
+ path := `LISAAC_DIRECTORY`:NATIVE_ARRAY(CHARACTER);
string_tmp.clear;
j := 0;
{path.item j != '\0'}.while_do {
@@@ -98,8 -98,8 +98,8 @@@ Section Privat
- end_usage:STRING_CONSTANT :=
" \n\
\Bug report: \n\
- \\t post in : https://gna.org/bugs/?group=isaac \n\
- \\t mail to : sonntag at icps.u-strasbg.fr \n";
+ \\t post in : https://alioth.debian.org/projects/lisaac/ \n\
+ \\t mail to : sonntag at icps.u-strasbg.fr \n";
- display_usage <-
(
@@@ -115,7 -115,8 +115,8 @@@
- read_options <-
( + cmd:STRING;
- + j,i,f:INTEGER;
+ + j,i:INTEGER;
+ + f:POINTER;
+ lip_ok:BOOLEAN;
+ s:LIP_SLOT_CODE;
+ t:STRING_CONSTANT;
@@@ -140,6 -141,9 +141,9 @@@
.when 'p' then {
is_path_list := TRUE;
}
+ .when 'r' then {
+ is_readable := TRUE;
+ };
} else {
(lip_ok).if_false {
load_lip (ALIAS_STR.make_lip) fuzzy TRUE;
@@@ -286,9 -290,12 +290,9 @@@
display_usage;
};
string_tmp.copy input_name;
- (is_java).if {
- string_tmp.append ".java";
- } else {
- string_tmp.append ".c";
- };
- output_name := ALIAS_STR.get string_tmp;
+ string_tmp.append (backend.source_extension);
+ output_name := ALIAS_STR.get string_tmp;
+ // TODO: Mildred: get output_name from lip
);
- last_index (n:STRING,c:CHARACTER) :INTEGER <-
@@@ -362,9 -369,202 +366,9 @@@
project.put_string path_lisaac to (ALIAS_STR.variable_lisaac);
project.call_init NULL;
);
-
- - put_trace_code buf:STRING <-
- ( + proto:PROTOTYPE;
-
- ((debug_level_option != 0) || {CALL_NULL.is_necessary}).if {
- title "DEBUG MANAGER" in buf;
-
- (is_java).if {
- buf.append
- "private static void print_string(String str) \n\
- \{ \n\
- \ System.out.print(str);\n\
- \}\n\
- \\n";
- } else {
- buf.append
- "int print_string(char *str) \n\
- \{ \n\
- \ while (*str!=0) {\n\
- \ print_char(*str); \n\
- \ str++; \n\
- \ };\n\
- \ return(0);\n\
- \}\n\
- \\n";
- };
- };
-
- (debug_level_option != 0).if {
- buf.append "char *trace[";
- buf.append (PROTOTYPE.prototype_list.count.to_string);
- buf.append "]={\n";
- (PROTOTYPE.prototype_list.lower).to (PROTOTYPE.prototype_list.upper-1) do {
- j:INTEGER;
- proto := PROTOTYPE.prototype_list.item j;
- buf.append " \"";
- buf.append (proto.name);
- buf.append " (";
- buf.append (proto.filename);
- buf.append ")\",\n";
- };
- proto := PROTOTYPE.prototype_list.last;
- buf.append " \"";
- buf.append (proto.name);
- buf.append " (";
- buf.append (proto.filename);
- buf.append ")\"\n};\n\n";
-
- //
- // Source Code.
- //
-
- (debug_with_code).if {
- + src:HASHED_DICTIONARY(STRING,UINTEGER_32);
- + key:UINTEGER_32;
-
- output_decl.append
- "\n//==========================//\n\
- \// SOURCE LINE REFERENCE //\n\
- \//==========================//\n";
-
- buf.append
- "struct __source {\n\
- \ unsigned int pos;\n\
- \ char *line;\n\
- \} __src[";
- src := PUSH.source_line;
- src.count.append_in buf;
- buf.append "]={\n";
- (src.lower).to (src.upper) do { j:INTEGER;
- key := src.key j;
- output_decl.append "#define L";
- key.append_in output_decl;
- output_decl.add_last ' ';
- (j-1).append_in output_decl;
- output_decl.add_last '\n';
- //
- buf.append " {";
- key.append_in buf;
- buf.append ",\"";
- buf.append (src.item j);
- buf.append "\"},\n";
- };
- buf.remove (buf.upper - 1);
- buf.append "};\n\n";
- };
-
- //
- // Signal manager.
- //
-
- (is_ansi).if {
- buf.append
- "// Unix Signal manager:\n\
- \void interrupt_signal(int sig) \n\
- \{ \n\
- \ stack_print(top_context); \n\
- \ print_string(\"User interrupt.\\n\"); \n\
- \ die_with_code(1); \n\
- \} \n\n";
- };
-
- //
- // Stack manager.
- //
-
- buf.append
- "void push_first(_____CONTEXT *path,unsigned long code)\n\
- \{ \n";
- (debug_level_option = 20).if {
- buf.append
- " _____CONTEXT *cur,loop;\n\
- \ cur = top_context; \n\
- \ while ((cur != (void *)0) && (cur != path)) cur = cur->back; \n\
- \ if (cur == path) {\n\
- \ loop.back = top_context;\n\
- \ loop.code = code; \n\
- \ stack_print(&loop);\n\
- \ print_string(\"COMPILER : Debug context looping detected !\\n\");\n\
- \ die_with_code(1);\n\
- \ };\n";
- };
- buf.append
- " path->back = top_context;\n\
- \ path->code = code;\n\
- \ top_context = path;\n\
- \} \n\
- \ \n\
- \void push(_____CONTEXT *path,unsigned long code)\n\
- \{ \n\
- \ path->code = code;\n\
- \ top_context = path;\n\
- \} \n\
- \ \n\
- \void stack_print(_____CONTEXT *up) \n\
- \{ _____CONTEXT *back,*next; \n\
- \ int j; \n\
- \ next = (void *)0; \n\
- \ while (up != (void *)0) { \n\
- \ back = up -> back; \n\
- \ up -> back = next; \n\
- \ next = up; \n\
- \ up = back; \n\
- \ }; \n\
- \ print_string(\"\\n============== BOTTOM ==============\\n\"); \n\
- \ while (next != (void *)0) { \n";
- (debug_with_code).if {
- buf.append
- " print_string(\"Line #\"); \n\
- \ print_integer(__src[next->code].pos >> 17); \n\
- \ print_string(\" Column #\"); \n\
- \ print_integer((__src[next->code].pos >> 9) & 0xFF); \n\
- \ print_string(\" in \"); \n\
- \ print_string(trace[__src[next->code].pos & 0x1FF]); \n\
- \ print_string(\".\\n\"); \n\
-\ if ((__src[next->code].pos & 0x1FF) != 0) { \n\
- \ print_string(__src[next->code].line); \n\
- \ print_char('\\n'); \n\
- \ for (j=0;j < ((__src[next->code].pos >> 9) & 0xFF);j++) {\n\
- \ if (__src[next->code].line[j]=='\\t') print_char('\\t');\n\
- \ else print_char(' ');\n\
- \ }; \n\
- \ print_char('^'); \n\
- \ print_char('\\n'); \n\
-\ }; \n";
-
- } else {
- buf.append
- " print_string(\"Line #\"); \n\
- \ print_integer(next->code >> 17); \n\
- \ print_string(\" Column #\"); \n\
- \ print_integer((next->code >> 9) & 0xFF); \n\
- \ print_string(\" in \"); \n\
- \ print_string(trace[next->code & 0x1FF]); \n\
- \ print_string(\".\\n\"); \n";
- };
- buf.append
- " next = next -> back; \n\
- \ }; \n\
- \ print_string(\"================ TOP ===============\\n\"); \n\
- \ top_context = (void *)0; \n\
- \} \n\
- \ \n\
- \void print_integer(unsigned short n) \n\
- \{ unsigned short val; \n\
- \ char car; \n\
- \ car = (n % 10) + '0'; \n\
- \ val = n / 10; \n\
- \ if (val != 0) print_integer(val); \n\
- \ print_char(car); \n\
- \} \n\n";
- };
- );
- load_main_object <-
- ( + type_gen:FAST_ARRAY[ITM_TYPE_MONO];
+ ( + type_gen:FAST_ARRAY(ITM_TYPE_MONO);
+ itm_type_character:ITM_TYPE_MONO;
+ itm_type_n_a_character:ITM_TYPE_MONO;
@@@ -401,17 -601,17 +405,17 @@@
//
type_pointer := ITM_TYPE_SIMPLE.get (ALIAS_STR.prototype_pointer)
project project.to_run_for NULL.raw;
- // NATIVE_ARRAY[CHARACTER]
- type_gen := ALIAS_ARRAY[ITM_TYPE_MONO].new;
+ // NATIVE_ARRAY(CHARACTER)
+ type_gen := ALIAS_ARRAY(ITM_TYPE_MONO).new;
type_gen.add_last itm_type_character;
- type_gen := ALIAS_ARRAY[ITM_TYPE_MONO].alias type_gen;
+ type_gen := ALIAS_ARRAY(ITM_TYPE_MONO).alias type_gen;
itm_type_n_a_character := ITM_TYPE_GENERIC.get (ALIAS_STR.prototype_native_array)
project project style NULL with type_gen;
type_n_a_character := itm_type_n_a_character.to_run_for NULL.raw;
- // NATIVE_ARRAY[NATIVE_ARRAY[CHARACTER]]
- type_gen := ALIAS_ARRAY[ITM_TYPE_MONO].new;
+ // NATIVE_ARRAY[NATIVE_ARRAY(CHARACTER)]
+ type_gen := ALIAS_ARRAY(ITM_TYPE_MONO).new;
type_gen.add_last itm_type_n_a_character;
- type_gen := ALIAS_ARRAY[ITM_TYPE_MONO].alias type_gen;
+ type_gen := ALIAS_ARRAY(ITM_TYPE_MONO).alias type_gen;
type_n_a_n_a_character := ITM_TYPE_GENERIC.get (ALIAS_STR.prototype_native_array)
project project style NULL with type_gen.to_run_for NULL.raw;
//
@@@ -434,86 -634,7 +438,86 @@@
STD_ERROR.put_string ")\n";
};
);
-
+
+ - put_trace_code buf:STRING <-
+ (
+ ((debug_level_option != 0) || {CALL_NULL.is_necessary}).if {
+ title "DEBUG MANAGER" in buf;
+ backend.generate_debug_manager_in buf;
+ };
+ (debug_level_option != 0).if {
+ backend.generate_trace_declarations_in buf;
+ (debug_with_code).if {
+ backend.generate_trace_codedata_in buf declarations_in output_decl;
+ };
+ backend.generate_trace_code_in buf;
+ };
+ );
+
+ - compile <-
+ (
+ //
+ // File Header
+ //
+
+ output_decl.clear;
+ backend.append_init_code_in output_decl input_name input_name;
+ title "EXTERNAL" in output_decl;
+
+ //
+ // Load prototype and start compilation
+ //
+
+ load_main_object;
+ type_input.prototype.depend;
+
+ //
+ // Continue declarations
+ //
+
+ title "TYPE" in output_decl;
+ backend.generate_type_struct_for_generic_in output_decl;
+ title "GLOBAL" in output_glob;
+
+ //
+ // Declare functions ahead
+ //
+
+ title "FUNCTION HEADER" in output_code; // Function header.
+ backend.append_debug_code_in output_code; // Debug source code.
+ PROFIL_LIST.genere_handler output_code; // Extern source code.
+
+ //
+ // Source Code: Main Function
+ //
+
+ title "SOURCE CODE" in output_code; // Source code.
+ backend.append_main_function_in output_code;
+ indent.append " ";
+ list_main.genere_extern output_code;
+ backend.append_main_return_code_in output_code;
+
+ //
+ // Other Functions
+ //
+
+ PROFIL_LIST.genere output_code;
+
+ //
+ // Finish type declaration
+ //
+
+ TYPE.genere_all_struct;
+ backend.generate_table_type_in output_decl;
+
+ //
+ // End of File
+ //
+
+ put_trace_code output_code; // Trace code
+ backend.append_end_of_file_in output_code;
+ );
+
Section Public
//
@@@ -524,16 -645,17 +528,16 @@@
( + file_output:POINTER;
//+ entry:ENTRY;
+ begin_time,end_time:UINTEGER_64;
- + time:INTEGER;
- + txt:STRING;
+ + time:INTEGER;
+ s:LIP_SLOT_CODE;
ALIAS_STR.make;
-
begin_time := SYSTEM.get_universal_time;
-
+
//
// Load Environment.
//
+
read_options;
is_verbose.if {
string_tmp.copy "\ninput file : ";
@@@ -548,48 -670,136 +552,48 @@@
};
string_tmp.print;
};
-
- //
- // Header C
- //
- (is_java).if {
- output_decl.copy "// Java code generated by Lisaac compiler (www.isaacOS.com) //\n";
- output_decl.append "class ";
- output_decl.append input_name;
- output_decl.append " {\n";
- output_decl.append "private static String arg[];\n";
- } else {
- output_decl.copy "// C code generated by Lisaac compiler (www.isaacOS.com) //\n";
- // ANSI argument command.
- (debug_level_option != 0).if {
- output_decl.append "#include <signal.h>\n";
- };
- output_decl.append
- "int arg_count;\n\
- \char **arg_vector;\n";
- };
-
- // External.
- title "EXTERNAL" in output_decl;
+
//
- // Load prototype constant.
+ // Compile and generate buffers
//
- load_main_object;
-
- // Compilation.
- type_input.prototype.depend;
-
- // Type / Struct.
- title "TYPE" in output_decl;
-
- (is_java).if {
- output_decl.append
- "// Generic Object\n\
- \class ___OBJ {\n\
- \ long __id;\n\
- \};\n\n";
- } else {
- output_decl.append
- "// Generic Object\n\
- \struct ___OBJ {\n\
- \ unsigned long __id;\n\
- \};\n\n";
- };
- title "GLOBAL" in output_glob;
-
- // Function header.
- title "FUNCTION HEADER" in output_code;
-
- // Debug source code.
- (is_java).if_false {
- (debug_level_option != 0).if {
- output_code.append "// Debug Manager\n";
- (is_ansi).if {
- output_code.append "void interrupt_signal(int sig);\n";
- };
- output_code.append
- "void stack_print(_____CONTEXT *up);\n\
- \void push_first(_____CONTEXT *path,unsigned long code);\n\
- \void push(_____CONTEXT *path,unsigned long code);\n\
- \void print_integer(unsigned short n);\n";
- };
- };
-
- // Extern source code.
- output_code.append "// Source code\n";
- PROFIL_LIST.genere_handler output_code;
-
- // Source code.
- title "SOURCE CODE" in output_code;
-
- (is_java).if {
- output_code.append "public static void main(String parg[])\n";
- } else {
- output_code.append "int main(int argc,char **argv)\n";
- };
- output_code.append "{\n";
- indent.append " ";
-
- list_main.genere_extern output_code;
-
- (is_java).if_false {
- output_code.append " return(0);\n";
- };
- indent.remove_last 2;
- output_code.append indent;
- output_code.append "}\n\n";
-
- PROFIL_LIST.genere output_code;
-
- TYPE.genere_all_struct;
- (is_java).if_false {
- output_decl.append "\nvoid *table_type[";
- TYPE.id_counter_without_type.append_in output_decl;
- output_decl.append "];\n";
- };
-
- // String Constant.
- // Trace code.
- put_trace_code output_code;
-
- (is_java).if {
- output_code.append "\n} // End class MAIN\n";
- };
-
+
+ compile;
+
+
//
- // Saving File Output.
- //
+ // Saving File Output (create file)
+ //
+
(! FS_MIN.make_file output_name).if {
STD_ERROR.put_string "Error: File ";
STD_ERROR.put_string output_name;
STD_ERROR.put_string " is not created !\n";
die_with_code exit_failure_code;
};
+ file_output := FS_MIN.open_write output_name;
- file_output := FS_MIN.open_write output_name;
- FS_MIN.write file_output with output_decl size (output_decl.count);
+ //
+ // Write Buffers
+ // - output_decl
+ // - output_glob
+ // - output_STRING_CONSTANT
+ // - output_code
+ //
+
+ FS_MIN.write file_output with output_decl size (output_decl.count);
FS_MIN.write file_output with output_glob size (output_glob.count);
(STRING_CST.output_count != 0).if {
- txt := STRING_CST.output;
- FS_MIN.write file_output with txt size (txt.count);
- };
+ FS_MIN.write file_output with (STRING_CST.output) size (STRING_CST.output.count);
+ };
FS_MIN.write file_output with output_code size (output_code.count);
FS_MIN.close file_output;
+
+ //
+ // Compute time spent
//
+
end_time := SYSTEM.get_universal_time;
(is_quiet).if_false {
STD_ERROR.put_string " => ";
@@@ -608,29 -818,31 +612,35 @@@
STD_ERROR.put_string " warning(s).\n";
};
};
-
+
+ //
+ // Statistics
+ //
+
(is_statistic).if {
+ STD_ERROR.put_string " Local counter : ";
+ STD_ERROR.put_integer (LIST.local_counter);
+ STD_ERROR.put_string "\n";
+ STD_ERROR.put_string " Context counter : ";
+ STD_ERROR.put_integer (LIST.context_counter);
+ STD_ERROR.put_string "\n";
print " Null call score : " stat null_counter for late_binding_counter;
print " Polymorphic call : " stat polymorphic_counter for late_binding_counter;
(is_optimization).if {
" Invariant loop score : ".print; count_invariant.print; '\n'.print;
};
};
-
+
//
- // Execute finality command (front end).
+ // Executing `back_end'
//
- // Executing `front_end':
+
project.put_boolean is_cop to (ALIAS_STR.slot_is_cop);
s := project.get_method (ALIAS_STR.slot_back_end);
(s = NULL).if {
"Warning: Slot `back_end' not found in *.lip file.\n".print;
} else {
s.run_with NULL;
- };
+ };
);
diff --combined src/parser.li
index 754b799,f79bcf4..4b511c8
--- a/src/parser.li
+++ b/src/parser.li
@@@ -43,8 -43,8 +43,8 @@@ Section Publi
- is_active_short:BOOLEAN;
- - short_dico:HASHED_DICTIONARY[LINKED_LIST[STRING_CONSTANT],STRING_CONSTANT] :=
- HASHED_DICTIONARY[LINKED_LIST[STRING_CONSTANT],STRING_CONSTANT].create;
+ - short_dico:HASHED_DICTIONARY(LINKED_LIST(STRING_CONSTANT),STRING_CONSTANT) :=
+ HASHED_DICTIONARY(LINKED_LIST(STRING_CONSTANT),STRING_CONSTANT).create;
- short_derive:INTEGER;
@@@ -53,7 -53,7 +53,7 @@@
- short key:STRING_CONSTANT token beg:INTEGER to end:INTEGER <-
( + pos:INTEGER;
+ add_text:ABSTRACT_STRING;
- + fmt:LINKED_LIST[STRING_CONSTANT];
+ + fmt:LINKED_LIST(STRING_CONSTANT);
(is_shorter).if {
(is_active_short).if {
@@@ -93,7 -93,7 +93,7 @@@
short_derive := short_derive - (end - begin + 1);
);
- - short_local:HASHED_SET[STRING_CONSTANT];
+ - short_local:HASHED_SET(STRING_CONSTANT);
Section Private
@@@ -211,12 -211,36 +211,36 @@@
- last_comment_extern:STRING_CONSTANT;
- last_comment_slot :STRING_CONSTANT;
- skip_comment:BOOLEAN;
-
+
+ - put_new_line_comment str:STRING with cmt:STRING_CONSTANT <-
+ ( + lst:LINKED_LIST(STRING_CONSTANT);
+ + idx,idx_beg:INTEGER;
+ lst := PARSER.short_dico.fast_reference_at cmt;
+ (lst != NULL).if {
+ {(idx := str.index_of '\n' since (idx+1)) < str.upper}.while_do {
+ idx_beg := idx;
+ idx := idx + 1;
+ {
+ (idx <= str.upper) &&
+ {str.item idx <= ' ' } &&
+ {str.item idx != '\n'}
+ }.while_do {
+ idx := idx + 1;
+ };
+ (str.item idx = '\n').if {
+ str.replace_substring (lst.first) from idx_beg to (idx-1);
+ idx := idx_beg + (lst.first.count)-1;
+ };
+ };
+ };
+ );
+
- read_space:BOOLEAN <-
( + posold,pos,pos2:INTEGER;
+ level_comment:INTEGER;
+ stat:INTEGER;
+
pos := position;
posold := -1;
(is_shorter2).if {
@@@ -328,9 -352,11 +352,11 @@@
(string_tmp3.is_empty).if {
last_comment_slot := NULL;
} else {
+ put_new_line_comment string_tmp3 with (ALIAS_STR.short_comment_new_line_slot);
last_comment_slot := ALIAS_STR.get string_tmp3;
};
(string_tmp4.is_empty).if_false {
+ put_new_line_comment string_tmp4 with (ALIAS_STR.short_comment_new_line_extern);
last_comment_extern := ALIAS_STR.get string_tmp4;
};
};
@@@ -593,10 -619,10 +619,10 @@@
(last_character='d').if {
position := position+1;
};
- (! string_tmp.is_integer).if {
+ (! string_tmp.is_integer_64).if {
syntax_error (current_position,"Incorrect decimal number.");
};
- last_integer := string_tmp.to_integer;
+ last_integer := string_tmp.to_integer_64;
};
};
};
@@@ -690,73 -716,60 +716,60 @@@
string_tmp.remove_last 1;
position := position+1;
}.elseif {last_character != 0.to_character} then {
- syntax_error (current_position,"Unknown escape sequence.");
- };
- }.elseif {last_character != 0.to_character} then {
- ( (last_character = 'a') ||
- {last_character = 'b'} ||
- {last_character = 'f'} ||
- {last_character = 'n'} ||
- {last_character = 'r'} ||
- {last_character = 't'} ||
- {last_character = 'v'} ||
- {last_character = '\\'} ||
- {last_character = '?'} ||
- {last_character = '\''} ||
- {last_character = '\"'}
+ syntax_error (current_position,"Malformed spacing escape sequence.");
+ };
+ }.elseif { "abfnrtv?\\\'\"".has last_character } then {
+ // Read named escape sequence
+ string_tmp.remove_last 1; // remove '\\'
+ last_character
+ .when 'a' then { string_tmp.add_last '\a'; }
+ .when 'b' then { string_tmp.add_last '\b'; }
+ .when 'f' then { string_tmp.add_last '\f'; }
+ .when 'n' then { string_tmp.add_last '\n'; }
+ .when 'r' then { string_tmp.add_last '\r'; }
+ .when 't' then { string_tmp.add_last '\t'; }
+ .when 'v' then { string_tmp.add_last '\v'; }
+ .when '?' then { string_tmp.add_last '\?'; }
+ .when '\\' then { string_tmp.add_last '\\'; }
+ .when '\'' then { string_tmp.add_last '\''; }
+ .when '\"' then { string_tmp.add_last '\"'; };
+ //string_tmp.add_last last_character;
+ position := position+1;
+ }.elseif {last_character.in_range '0' to '9'} then {
+ (
+ (last_character='0') &&
+ {position<source.upper} &&
+ {! source.item(position+1).is_hexadecimal_digit}
).if {
- // Read named escape sequence
- string_tmp.remove_last 1; // remove '\\'
- last_character
- .when 'a' then { string_tmp.add_last '\a'; }
- .when 'b' then { string_tmp.add_last '\b'; }
- .when 'f' then { string_tmp.add_last '\f'; }
- .when 'n' then { string_tmp.add_last '\n'; }
- .when 'r' then { string_tmp.add_last '\r'; }
- .when 't' then { string_tmp.add_last '\t'; }
- .when 'v' then { string_tmp.add_last '\v'; }
- .when '\\' then { string_tmp.add_last '\\'; }
- .when '?' then { string_tmp.add_last '\?'; }
- .when '\'' then { string_tmp.add_last '\''; }
- .when '\"' then { string_tmp.add_last '\"'; };
- //string_tmp.add_last last_character;
+ // Read \0
+ string_tmp.remove_last 1; // remove '\\'
+ string_tmp.add_last '\0';
+ //string_tmp.add_last last_character;
position := position+1;
- }.elseif {last_character.in_range '0' to '9'} then {
- (
- (last_character='0') &&
- {position<source.upper} &&
- {! source.item(position+1).is_hexadecimal_digit}
- ).if {
- // Read \0
- string_tmp.remove_last 1; // remove '\\'
- string_tmp.add_last '\0';
- //string_tmp.add_last last_character;
- position := position+1;
+ } else {
+ // Read '\' integer '\'
+ string_tmp2.copy string_tmp;
+ nothing := read_integer; // result is Always TRUE.
+ string_tmp.copy string_tmp2;
+ ((last_integer > 255) || {last_integer < 0}).if {
+ syntax_error (current_position,
+ "Invalid range character number [0,255].");
+ };
+ string_tmp.remove_last 1; // remove '\\'
+ string_tmp.add_last (last_integer.to_character);
+ //string_tmp.println; last_integer.to_character.code.print; " ".print; last_integer.print; "\n".print;
+ // Save 3 octal digits
+ //string_tmp.add_last ((val / 64).decimal_digit);
+ //string_tmp.add_last (((val % 64) / 8).decimal_digit);
+ //string_tmp.add_last ((val % 8).decimal_digit);
+ (last_character='\\').if {
+ position := position + 1;
} else {
- // Read '\' integer '\'
- string_tmp2.copy string_tmp;
- nothing := read_integer; // result is Always TRUE.
- string_tmp.copy string_tmp2;
- ((last_integer > 255) || {last_integer < 0}).if {
- syntax_error (current_position,
- "Invalid range character number [0,255].");
- };
- string_tmp.remove_last 1; // remove '\\'
- string_tmp.add_last (last_integer.to_character);
- string_tmp.println; last_integer.to_character.code.print; " ".print; last_integer.print; "\n".print;
- // Save 3 octal digits
- //string_tmp.add_last ((val / 64).decimal_digit);
- //string_tmp.add_last (((val % 64) / 8).decimal_digit);
- //string_tmp.add_last ((val % 8).decimal_digit);
- (last_character='\\').if {
- position := position + 1;
- } else {
- syntax_error (current_position,"Character '\' is needed.");
- };
+ syntax_error (current_position,"Character '\' is needed.");
};
- } else {
- syntax_error (current_position,"Unknown escape sequence.");
- };
+ };
+ } else {
+ syntax_error (current_position,"Unknown escape sequence.");
};
);
@@@ -881,9 -894,27 +894,27 @@@
+ old_pos:INTEGER;
// On passe les espaces :
(read_space).if {
- };
+ };
+
old_pos:=position;
string_tmp.clear;
+ /*is_all_warning.if {
+ "123".print;
+ last_character.print;
+ "456".print;
+ " ('\\".print;
+ last_character.code.print;
+ "' == (0.to_character || ! \"!@#$%^&<|*-+=~/?\\>\".has '".print;
+ last_character.to_string.print;
+ "') == (".print;
+ (last_character = 0.to_character).if { "TRUE".print; } else { "FALSE".print; };
+ " || ! ".print;
+ "!@#$%^&<|*-+=~/?\\>".has last_character.if { "TRUE".print; } else { "FALSE".print; };
+ " ) = ".print;
+ ((last_character = 0.to_character) ||
+ {! "!@#$%^&<|*-+=~/?\\>".has last_character}).if { "TRUE".print; } else { "FALSE".print; };
+ "\n".print;
+ };*/
{(last_character = 0.to_character) ||
{! "!@#$%^&<|*-+=~/?\\>".has last_character}}.until_do {
string_tmp.add_last last_character;
@@@ -898,7 -929,7 +929,7 @@@
).if {
syntax_error (current_position,"Incorrect operator.");
};
- short (ALIAS_STR.short_operator) token old_pos to position;
+ short (ALIAS_STR.short_operator) token old_pos to position;
result := TRUE;
};
result
@@@ -922,7 -953,7 +953,7 @@@
- read_program:BOOLEAN <-
( + result:BOOLEAN;
+ pos_sec,old_derive:INTEGER;
- + t:FAST_ARRAY[ITM_TYPE_MONO];
+ + t:FAST_ARRAY(ITM_TYPE_MONO);
result := TRUE;
@@@ -1028,7 -1059,7 +1059,7 @@@
- read_slot:BOOLEAN <-
( + result:BOOLEAN;
+ t:ITM_TYPE;
- + lt:FAST_ARRAY[ITM_TYPE_MONO];
+ + lt:FAST_ARRAY(ITM_TYPE_MONO);
+ style:CHARACTER;
+ affect:CHARACTER;
+ old_pos,old_derive:INTEGER;
@@@ -1154,9 -1185,9 +1185,9 @@@
- read_type_slot:ITM_SLOT <-
( + arg:ITM_ARGUMENT;
+ result:ITM_SLOT;
- + list_arg:FAST_ARRAY[ITM_ARGUMENT];
+ + list_arg:FAST_ARRAY(ITM_ARGUMENT);
- list_arg := ALIAS_ARRAY[ITM_ARGUMENT].new;
+ list_arg := ALIAS_ARRAY(ITM_ARGUMENT).new;
arg := read_loc_arg FALSE with_self TRUE;
(arg = NULL).if {
@@@ -1177,13 -1208,13 +1208,13 @@@
};
};
(result != NULL).if {
- list_arg := ALIAS_ARRAY[ITM_ARGUMENT].copy list_arg;
+ list_arg := ALIAS_ARRAY(ITM_ARGUMENT).copy list_arg;
result.set_argument_list list_arg;
};
result
);
- - read_slot_keyword list_arg:FAST_ARRAY[ITM_ARGUMENT] :ITM_SLOT <-
+ - read_slot_keyword list_arg:FAST_ARRAY(ITM_ARGUMENT) :ITM_SLOT <-
( + n:STRING;
+ arg:ITM_ARGUMENT;
+ result:ITM_SLOT;
@@@ -1219,7 -1250,7 +1250,7 @@@
result
);
- - read_slot_operator list_arg:FAST_ARRAY[ITM_ARGUMENT] :ITM_SLOT <-
+ - read_slot_operator list_arg:FAST_ARRAY(ITM_ARGUMENT) :ITM_SLOT <-
( + name,pretty_name:STRING_CONSTANT;
+ associativity:STRING_CONSTANT;
+ priority:INTEGER;
@@@ -1356,16 -1387,16 +1387,16 @@@
);
//++ LOCAL -> { identifier [ ':' TYPE ] ',' } identifier ':' TYPE
- - read_local m:BOOLEAN :FAST_ARRAY[ITM_LOCAL] <-
+ - read_local m:BOOLEAN :FAST_ARRAY(ITM_LOCAL) <-
( + t:ITM_TYPE_MONO;
+ loc:ITM_LOCAL;
- + result:FAST_ARRAY[ITM_LOCAL];
+ + result:FAST_ARRAY(ITM_LOCAL);
+ beg:INTEGER;
+ mute:BOOLEAN;
mute := m;
(read_identifier).if {
- result := ALIAS_ARRAY[ITM_LOCAL].new;
+ result := ALIAS_ARRAY(ITM_LOCAL).new;
beg := result.lower;
{
((result.count != 0) && {! read_identifier} && {! mute}).if {
@@@ -1387,13 -1418,13 +1418,13 @@@
}.do_while {read_character ','};
(beg != result.upper + 1).if {
(mute).if {
- ALIAS_ARRAY[ITM_LOCAL].free result;
+ ALIAS_ARRAY(ITM_LOCAL).free result;
result := NULL;
} else {
syntax_error (current_position,"Incorrect local type.");
};
} else {
- result := ALIAS_ARRAY[ITM_LOCAL].copy result;
+ result := ALIAS_ARRAY(ITM_LOCAL).copy result;
(is_shorter).if {
(result.lower).to (result.upper) do { j:INTEGER;
@@@ -1409,8 -1440,8 +1440,8 @@@
- read_local_arg m:BOOLEAN with_self s:BOOLEAN :ITM_ARGUMENT <-
( + t:ITM_TYPE_MONO;
+ tm:ITM_TYPE_MULTI;
- + type:FAST_ARRAY[ITM_TYPE_MONO];
- + name:FAST_ARRAY[STRING_CONSTANT];
+ + type:FAST_ARRAY(ITM_TYPE_MONO);
+ + name:FAST_ARRAY(STRING_CONSTANT);
+ beg:INTEGER;
+ mute:BOOLEAN;
+ result:ITM_ARGUMENT;
@@@ -1421,8 -1452,8 +1452,8 @@@
((s) && {read_this_keyword (ALIAS_STR.variable_self)}) ||
{read_identifier}
).if {
- name := ALIAS_ARRAY[STRING_CONSTANT].new;
- type := ALIAS_ARRAY[ITM_TYPE_MONO].new;
+ name := ALIAS_ARRAY(STRING_CONSTANT).new;
+ type := ALIAS_ARRAY(ITM_TYPE_MONO).new;
beg := name.lower;
{
((name.count != 0) && {! read_identifier} && {! mute}).if {
@@@ -1445,8 -1476,8 +1476,8 @@@
(mute).if_false {
syntax_error (current_position,"Incorrect argument type.");
};
- ALIAS_ARRAY[STRING_CONSTANT].free name;
- ALIAS_ARRAY[ITM_TYPE_MONO].free type;
+ ALIAS_ARRAY(STRING_CONSTANT).free name;
+ ALIAS_ARRAY(ITM_TYPE_MONO).free type;
} else {
(
(s) && {
@@@ -1456,19 -1487,19 +1487,19 @@@
}
}
).if {
- syntax_error (current_position,"Type `SELF' is needed. (local_arg)");
+ syntax_error (current_position,"Type `SELF' is needed.");
};
(name.count = 1).if {
// Single Argument.
result := ITM_ARG.create current_position
name (name.first)
type (type.first);
- ALIAS_ARRAY[STRING_CONSTANT].free name;
- ALIAS_ARRAY[ITM_TYPE_MONO].free type;
+ ALIAS_ARRAY(STRING_CONSTANT).free name;
+ ALIAS_ARRAY(ITM_TYPE_MONO).free type;
} else {
// Vector Arguments.
- name := ALIAS_ARRAY[STRING_CONSTANT].alias name;
- type := ALIAS_ARRAY[ITM_TYPE_MONO].alias type;
+ name := ALIAS_ARRAY(STRING_CONSTANT).alias name;
+ type := ALIAS_ARRAY(ITM_TYPE_MONO).alias type;
tm := ITM_TYPE_MULTI.get type;
result := ITM_ARGS.create current_position name name type tm;
};
@@@ -1485,8 -1516,8 +1516,8 @@@
); // read_local
//++ TYPE_LIST -> TYPE { ',' TYPE }
- - read_type_list is_section:BOOLEAN :FAST_ARRAY[ITM_TYPE_MONO] <-
- ( + lst:FAST_ARRAY[ITM_TYPE_MONO];
+ - read_type_list is_section:BOOLEAN :FAST_ARRAY(ITM_TYPE_MONO) <-
+ ( + lst:FAST_ARRAY(ITM_TYPE_MONO);
+ t:ITM_TYPE_MONO;
+ ts:ITM_TYPE_SIMPLE;
@@@ -1499,7 -1530,7 +1530,7 @@@
"For a section, the prototype name only (without '['...']').");
};
};
- lst := ALIAS_ARRAY[ITM_TYPE_MONO].new;
+ lst := ALIAS_ARRAY(ITM_TYPE_MONO).new;
lst.add_last t;
{read_character ','}.while_do {
t := read_type FALSE;
@@@ -1515,7 -1546,7 +1546,7 @@@
};
lst.add_last t;
};
- lst := ALIAS_ARRAY[ITM_TYPE_MONO].alias lst;
+ lst := ALIAS_ARRAY(ITM_TYPE_MONO).alias lst;
};
lst
);
@@@ -1525,7 -1556,7 +1556,7 @@@
- read_type is_local:BOOLEAN :ITM_TYPE_MONO <-
( + style:STRING_CONSTANT;
+ result:ITM_TYPE_MONO;
- + lst:FAST_ARRAY[ITM_TYPE_MONO];
+ + lst:FAST_ARRAY(ITM_TYPE_MONO);
+ typ_arg,typ_res:ITM_TYPE;
+ contract:ITM_LIST;
@@@ -1601,7 -1632,7 +1632,7 @@@
//++ PROTOTYPE -> cap_identifier{('.'|'...')cap_identifier}['('PARAM_TYPE{','PARAM_TYPE}')']
- read_prototype styl:STRING_CONSTANT :ITM_TYPE_MONO <-
( + nam:STRING_CONSTANT;
- + genericity:FAST_ARRAY[ITM_TYPE_MONO];
+ + genericity:FAST_ARRAY(ITM_TYPE_MONO);
+ result,t:ITM_TYPE_MONO;
+ old_pos,old_derive,sav_derive,pos_before:INTEGER;
+ continue:BOOLEAN;
@@@ -1636,7 -1667,7 +1667,7 @@@
//
// Genericity.
//
- genericity := ALIAS_ARRAY[ITM_TYPE_MONO].new;
+ genericity := ALIAS_ARRAY(ITM_TYPE_MONO).new;
{
t := read_param_type;
(t = NULL).if {
@@@ -1644,7 -1675,7 +1675,7 @@@
};
genericity.add_last t;
}.do_while {read_character ','};
- genericity := ALIAS_ARRAY[ITM_TYPE_MONO].alias genericity;
+ genericity := ALIAS_ARRAY(ITM_TYPE_MONO).alias genericity;
result := ITM_TYPE_GENERIC.get nam
from (find_prototype nam)
style styl
@@@ -1666,7 -1697,7 +1697,7 @@@
(styl != NULL).if {
string_tmp.copy "Style `";
string_tmp.append styl;
- string_tmp.append "' ignored.";
+ string_tmp.append "' ignored for SELF.";
warning_error (current_position,string_tmp);
};
result := ITM_TYPE_SIMPLE.type_self;
@@@ -1674,7 -1705,7 +1705,7 @@@
(styl != NULL).if {
string_tmp.copy "Style `";
string_tmp.append styl;
- string_tmp.append "' ignored.";
+ string_tmp.append "' ignored for NULL.";
warning_error (current_position,string_tmp);
};
result := ITM_TYPE_SIMPLE.type_null;
@@@ -1734,7 -1765,7 +1765,7 @@@
( + result,value:ITM_CODE;
+ affect:CHARACTER;
+ again:BOOLEAN;
- + l_assignment:FAST_ARRAY[STRING_CONSTANT];
+ + l_assignment:FAST_ARRAY(STRING_CONSTANT);
+ p:INTEGER;
+ name:STRING_CONSTANT;
+ old_pos :POSITION;
@@@ -1742,7 -1773,7 +1773,7 @@@
// !! AMBIGU resolution !!
save_context;
(read_character '(').if {
- l_assignment := ALIAS_ARRAY[STRING_CONSTANT].new;
+ l_assignment := ALIAS_ARRAY(STRING_CONSTANT).new;
{
again := FALSE;
(read_identifier).if {
@@@ -1767,10 -1798,10 +1798,10 @@@
};
}.do_while {again};
((! l_assignment.is_empty) && {read_character ')'} && {read_affect}).if {
- l_assignment := ALIAS_ARRAY[STRING_CONSTANT].copy l_assignment;
+ l_assignment := ALIAS_ARRAY(STRING_CONSTANT).copy l_assignment;
result := ITM_LIST_IDF.create current_position with l_assignment;
- affect := last_string.first;
- old_pos:= current_position;
+ affect := last_string.first;
+ old_pos:= current_position;
value := read_expr;
(value = NULL).if {
//syntax_error (current_position,"Incorrect expression.");
@@@ -1791,7 -1822,7 +1822,7 @@@
result := ITM_WRITE_CAST.create (result.position) assign result with value;
};
} else {
- ALIAS_ARRAY[STRING_CONSTANT].free l_assignment;
+ ALIAS_ARRAY(STRING_CONSTANT).free l_assignment;
};
}.elseif {read_identifier} then {
p := position - last_string.count;
@@@ -1811,7 -1842,7 +1842,7 @@@
(read_affect).if {
result := ITM_READ.create current_position name name;
affect := last_string.first;
- old_pos:= current_position;
+ old_pos:= current_position;
value := read_expr;
(value = NULL).if {
//syntax_error (current_position,"Incorrect expression.");
@@@ -1848,39 -1879,54 +1879,54 @@@
- read_expr_operator:ITM_CODE <-
( + result:ITM_CODE;
+ expr :ITM_CODE;
- + l_expr:FAST_ARRAY[ITM_CODE];
+ + l_expr:FAST_ARRAY(ITM_CODE);
+ itm_op:ITM_OPERATOR;
+ last_msg,first_msg:INTEGER;
-
- l_expr := ALIAS_ARRAY[ITM_CODE].new;
+
+ // is_all_warning.if { warning_error (current_position, "-> Begin read EXPR_OPERATOR"); };
+
+ l_expr := ALIAS_ARRAY(ITM_CODE).new;
{read_operator}.while_do {
+ // is_all_warning.if { warning_error (current_position, " EXPR_OPERATOR: Read operator"); };
expr := ITM_OPERATOR.create current_position name last_string;
l_expr.add_last expr;
};
+ // is_all_warning.if { warning_error (current_position, " EXPR_OPERATOR: Read EXPR_MESSAGE"); };
expr := read_expr_message;
(expr = NULL).if {
// Error.
(! l_expr.is_empty).if {
syntax_error (current_position,"Incorrect message expression.");
};
- ALIAS_ARRAY[ITM_CODE].free l_expr;
+ ALIAS_ARRAY(ITM_CODE).free l_expr;
} else {
// { operator {operator} EXPR_MESSAGE } {operator}
first_msg := l_expr.count;
{
last_msg := l_expr.count;
- l_expr.add_last expr;
+ l_expr.add_last expr;
+ // read_space;
+ // string_tmp4.copy " EXPR_OPERATOR: Prepare to read an operator ";
+ // string_tmp4.add_last last_character;
+ // string_tmp4.add_last ' ';
+ // string_tmp4.append (last_character.code.to_string);
+ is_all_warning.if { warning_error (current_position, string_tmp4); };
(read_operator).if {
{
+ // is_all_warning.if { warning_error (current_position, " EXPR_OPERATOR: Read operator"); };
expr := ITM_OPERATOR.create current_position name last_string;
l_expr.add_last expr;
- }.do_while {read_operator};
+ }.do_while {read_operator};
+ // is_all_warning.if { warning_error (current_position, " EXPR_OPERATOR: Read EXPR_MESSAGE"); };
expr := read_expr_message;
- } else {
+ } else {
+ // is_all_warning.if { warning_error (current_position, " EXPR_OPERATOR: Fail to read an operator"); };
expr := NULL;
};
}.do_while {expr != NULL};
-
+
+ // is_all_warning.if { warning_error (current_position, "-> End read EXPR_OPERATOR"); };
+
// Last Post-fix operator.
{last_msg < l_expr.upper}.while_do {
itm_op ?= l_expr.item (last_msg + 1);
@@@ -1904,7 -1950,7 +1950,7 @@@
};
(l_expr.count = 1).if {
result := l_expr.first;
- ALIAS_ARRAY[ITM_CODE].free l_expr;
+ ALIAS_ARRAY(ITM_CODE).free l_expr;
}.elseif {l_expr.count = 3} then {
// Simple binary message.
itm_op ?= l_expr.second;
@@@ -1912,13 -1958,14 +1958,14 @@@
name (operator (ALIAS_STR.slot_infix) name (itm_op.name))
args (l_expr.first,l_expr.item 2);
//
- ALIAS_ARRAY[ITM_CODE].free l_expr;
+ ALIAS_ARRAY(ITM_CODE).free l_expr;
} else {
// Complex expression.
- l_expr := ALIAS_ARRAY[ITM_CODE].copy l_expr;
+ l_expr := ALIAS_ARRAY(ITM_CODE).copy l_expr;
result := ITM_EXPRESSION.create l_expr;
};
};
+
result
); // read_expr_operator
@@@ -1969,7 -2016,7 +2016,7 @@@
- read_expr_primary:ITM_CODE <-
( + result:ITM_CODE;
+ type :ITM_TYPE_MONO;
- + ltype:FAST_ARRAY[ITM_TYPE_MONO];
+ + ltype:FAST_ARRAY(ITM_TYPE_MONO);
+ ext :ITM_EXTERNAL_TYPE;
+ group_sav:ITM_LIST;
+ arg:ITM_ARGUMENT;
@@@ -2089,13 -2136,13 +2136,13 @@@
);
//++ GROUP -> DEF_LOCAL {EXPR ';'} [ EXPR {',' {EXPR ';'} EXPR } ]
- - read_group:FAST_ARRAY[ITM_CODE] <-
+ - read_group:FAST_ARRAY(ITM_CODE) <-
( + e:ITM_CODE;
- + result:FAST_ARRAY[ITM_CODE];
+ + result:FAST_ARRAY(ITM_CODE);
read_def_local;
- result := ALIAS_ARRAY[ITM_CODE].new;
+ result := ALIAS_ARRAY(ITM_CODE).new;
e := read_expr;
{(e != NULL) && {read_character ';'}}.while_do {
result.add_last e;
@@@ -2119,7 -2166,7 +2166,7 @@@
e := ITM_RESULT.create e;
result.add_last e;
};
- ALIAS_ARRAY[ITM_CODE].copy result
+ ALIAS_ARRAY(ITM_CODE).copy result
);
- read_invariant:BOOLEAN <-
@@@ -2158,13 -2205,13 +2205,13 @@@
( + continue:BOOLEAN;
+ e:ITM_CODE;
+ result:ITM_LIST;
- + lst:FAST_ARRAY[ITM_CODE];
+ + lst:FAST_ARRAY(ITM_CODE);
(read_character '[').if {
result := last_group := ITM_LIST.create current_position;
read_def_local;
- lst := ALIAS_ARRAY[ITM_CODE].new;
+ lst := ALIAS_ARRAY(ITM_CODE).new;
{
e := read_expr;
(e = NULL).if {
@@@ -2187,22 -2234,22 +2234,22 @@@
e := ITM_PROTOTYPE.create current_position type (ITM_TYPE_SIMPLE.type_void);
lst.add_last e;
//
- result.set_code (ALIAS_ARRAY[ITM_CODE].copy lst);
+ result.set_code (ALIAS_ARRAY(ITM_CODE).copy lst);
};
result
);
//++ DEF_LOCAL -> { style LOCAL ';' } !! AMBIGU !!
- read_def_local <-
- ( + loc_lst:FAST_ARRAY[ITM_LOCAL];
- + local_list,static_list:FAST_ARRAY[ITM_LOCAL];
+ ( + loc_lst:FAST_ARRAY(ITM_LOCAL);
+ + local_list,static_list:FAST_ARRAY(ITM_LOCAL);
+ styl:CHARACTER;
save_context; // !! SAVE CONTEXT !!
styl := read_style;
- local_list := ALIAS_ARRAY[ITM_LOCAL].new;
- static_list := ALIAS_ARRAY[ITM_LOCAL].new;
+ local_list := ALIAS_ARRAY(ITM_LOCAL).new;
+ static_list := ALIAS_ARRAY(ITM_LOCAL).new;
{styl != ' '}.while_do {
loc_lst := read_local TRUE;
(loc_lst != NULL).if {
@@@ -2226,14 -2273,14 +2273,14 @@@
};
};
(local_list.is_empty).if {
- ALIAS_ARRAY[ITM_LOCAL].free local_list;
+ ALIAS_ARRAY(ITM_LOCAL).free local_list;
} else {
- last_group.set_local_list (ALIAS_ARRAY[ITM_LOCAL].copy local_list);
+ last_group.set_local_list (ALIAS_ARRAY(ITM_LOCAL).copy local_list);
};
(static_list.is_empty).if {
- ALIAS_ARRAY[ITM_LOCAL].free static_list;
+ ALIAS_ARRAY(ITM_LOCAL).free static_list;
} else {
- last_group.set_static_list (ALIAS_ARRAY[ITM_LOCAL].copy static_list);
+ last_group.set_static_list (ALIAS_ARRAY(ITM_LOCAL).copy static_list);
};
);
@@@ -2242,7 -2289,7 +2289,7 @@@
( + result:ITM_CODE;
+ name :STRING_CONSTANT;
+ n:STRING;
- + l_arg:FAST_ARRAY[ITM_CODE];
+ + l_arg:FAST_ARRAY(ITM_CODE);
+ arg:ITM_CODE;
+ p1,p2,old_derive,sav_derive:INTEGER;
@@@ -2257,7 -2304,7 +2304,7 @@@
n := ALIAS_STR.new;
n.copy last_string;
// Argument list.
- l_arg := ALIAS_ARRAY[ITM_CODE].new;
+ l_arg := ALIAS_ARRAY(ITM_CODE).new;
arg := read_argument;
(arg != NULL).if {
l_arg.add_last arg;
@@@ -2297,14 -2344,14 +2344,14 @@@
} else {
result := ITM_READ_ARG1.create current_position name name arg first_arg;
};
- ALIAS_ARRAY[ITM_CODE].free l_arg;
+ ALIAS_ARRAY(ITM_CODE).free l_arg;
}.elseif {l_arg.count=1} then {
result := ITM_READ_ARG2.create current_position name
name args (first_arg,(l_arg.first));
- ALIAS_ARRAY[ITM_CODE].free l_arg;
+ ALIAS_ARRAY(ITM_CODE).free l_arg;
} else {
l_arg.add_first first_arg;
- l_arg := ALIAS_ARRAY[ITM_CODE].copy l_arg;
+ l_arg := ALIAS_ARRAY(ITM_CODE).copy l_arg;
result := ITM_READ_ARGS.create current_position name name args l_arg;
};
}; // if
@@@ -2334,12 -2381,12 +2381,12 @@@
- read_slot_header first:BOOLEAN :BOOLEAN <-
( + result:BOOLEAN;
+ v:ITM_CODE;
- + cast:FAST_ARRAY[ITM_TYPE_MONO];
+ + cast:FAST_ARRAY(ITM_TYPE_MONO);
+ style:CHARACTER;
+ is_export:BOOLEAN;
+ parameter_type:ITM_TYPE_PARAMETER;
+ instr:LIP_CODE;
- + param:BLOCK;
+ + param:{ITM_TYPE_PARAMETER};
style := read_style;
(style != ' ').if {
@@@ -2358,7 -2405,101 +2405,7 @@@
(is_java).if {
semantic_error (current_position,"COP not yet implemented.");
} else {
- output_decl.append
- "#include <pthread.h>\n\
- \#include <limits.h>\n\n\
- \void print_char(char car);\n\
- \int die_with_code(int code);\n\n\
- \static pthread_key_t current_thread;\n\
- \static pthread_attr_t thread_attr;\n\
- \pthread_t c_thread;\n\
- \int thread_counter;\n\n\
- \static char thread_stack[512][PTHREAD_STACK_MIN];\n\n\
- \typedef struct lith_object_struct lith_object;\n\
- \typedef struct lith_node_struct lith_node;\n\
- \struct lith_node_struct {\n\
- \ pthread_mutex_t mutex;\n\
- \ lith_node *next;\n\
- \ lith_object *object;\n\
- \};\n\
- \struct lith_object_struct {\n\
- \ unsigned long __id; // Just for late binding.\n\
- \ lith_node *first;\n\
- \ lith_node *last;\n\
- \ lith_object *(*procedure)(lith_object *obj,pthread_mutex_t *mutex);\n\
- \ pthread_mutex_t mutex;\n\
- \};\n\
- \struct {\n\
- \ lith_node *first;\n\
- \ pthread_mutex_t mutex;\n\
- \} pool;\n\n\
- \void *thread_life(void *ptr)\n\
- \{ lith_node node,*n;\n\
- \ lith_object *obj,*new_obj;\n\n\
- \ pthread_mutex_init(&node.mutex,NULL);\n\
- \ pthread_mutex_lock(&node.mutex);\n\
- \ node.object = (lith_object *)ptr;\n\
- \ do {\n\
- \ // Append fifo object.\n\
- \ obj = node.object;\n\
- \ node.next = NULL;\n\
- \ n = obj->last;\n\
- \ if (n == NULL) {\n\
- \ obj->first = &node;\n\
- \ pthread_mutex_unlock(&node.mutex);\n\
- \ } else {\n\
- \ n->next = &node;\n\
- \ };\n\
- \ obj->last = &node;\n\
- \ pthread_setspecific(current_thread,(void *)obj);\n\
- \ // Run procedure.\n\
- \ new_obj = obj->procedure(obj,&node.mutex);\n\
- \ // Remove fifo object.\n\
- \ pthread_mutex_lock(&obj->mutex);\n\
- \ n = obj->first->next;\n\
- \ if (n != NULL) {\n\
- \ pthread_mutex_unlock(&n->mutex);\n\
- \ } else {\n\
- \ obj->last = NULL;\n\
- \ };\n\
- \ obj->first = n;\n\
- \ pthread_mutex_unlock(&obj->mutex);\n\
- \ if (new_obj != NULL) {\n\
- \ node.object = new_obj;\n\
- \ } else {\n\
- \ // Add in pool.\n\
- \ pthread_mutex_lock(&pool.mutex);\n\
- \ node.next = pool.first;\n\
- \ pool.first = &node;\n\
- \ pthread_mutex_unlock(&pool.mutex);\n\
- \ // Sleep.\n\
- \ pthread_mutex_lock(&node.mutex);\n\
- \ };\n\
- \ } while (1);\n\
- \ return NULL;\n\
- \};\n\n\
- \void run_procedure(lith_object *obj)\n\
- \{ lith_node *node;\n\
- \ char *msg=\"COP Error!\\n\";\n\
- \ // Pool manager.\n\
- \ pthread_mutex_lock(&pool.mutex);\n\
- \ node = pool.first;\n\
- \ if (node != NULL) {\n\
- \ pool.first = node->next;\n\
- \ };\n\
- \ pthread_mutex_unlock(&pool.mutex);\n\
- \ // Run thread.\n\
- \ if (node == NULL) {\n\
- \ pthread_attr_setstack(&thread_attr, thread_stack[thread_counter++],PTHREAD_STACK_MIN);\n\
- \ if ((thread_counter>512) || pthread_create(&c_thread,&thread_attr, thread_life, (void *)obj)) {\n\
- \ while (*msg != 0) print_char(*(msg++));\n\
- \ die_with_code(1);\n\
- \ };\n\
- \ } else {\n\
- \ node->object = obj;\n\
- \ pthread_mutex_unlock(&node->mutex);\n\
- \ };\n\
- \};\n\n";
+ backend.append_cop_init_code_in output_decl;
};
};
@@@ -2689,7 -2830,7 +2736,7 @@@
+ data:LIP_SLOT_DATA;
+ slot_code:LIP_SLOT_CODE;
+ cst:LIP_CONSTANT;
- + cod:FAST_ARRAY[LIP_CODE];
+ + cod:FAST_ARRAY(LIP_CODE);
+ instr:LIP_CODE;
+ pos:POSITION;
@@@ -2752,7 -2893,7 +2799,7 @@@
warning_error (current_position,"Added '(' is needed.");
};
is_shorter2 := FALSE;
- cod := ALIAS_ARRAY[LIP_CODE].new;
+ cod := ALIAS_ARRAY(LIP_CODE).new;
{(instr := readlip_expr) != NULL}.while_do {
cod.add_last instr;
(read_character ';').if_false {
@@@ -2762,7 -2903,7 +2809,7 @@@
(read_character ')').if_false {
warning_error (current_position,"Added ')' is needed.");
};
- cod := ALIAS_ARRAY[LIP_CODE].copy cod;
+ cod := ALIAS_ARRAY(LIP_CODE).copy cod;
slot_code := LIP_SLOT_CODE.create pos in lip_prj dir lip_dir section sec
name n argument data code cod;
(sec = ALIAS_STR.section_public).if {
@@@ -2831,13 -2972,13 +2878,13 @@@
//// FUNCTION -> 'if' '{' { EXPR ';' } '}' [ 'else' '{' { EXPR ';' } '}' ]
//// | identifier [ EXPR_ARGUMENT ]
( + result:LIP_CODE;
- + the,els:FAST_ARRAY[LIP_CODE];
+ + the,els:FAST_ARRAY(LIP_CODE);
+ val:LIP_CODE;
+ nam:STRING_CONSTANT;
+ arg:LIP_CODE;
(read_word (ALIAS_STR.slot_if)).if {
- the := ALIAS_ARRAY[LIP_CODE].new;
+ the := ALIAS_ARRAY(LIP_CODE).new;
(read_character '{').if_false {
warning_error (current_position,"Added '(' is needed.");
};
@@@ -2850,9 -2991,9 +2897,9 @@@
(read_character '}').if_false {
warning_error (current_position,"Added '(' is needed.");
};
- the := ALIAS_ARRAY[LIP_CODE].copy the;
+ the := ALIAS_ARRAY(LIP_CODE).copy the;
(read_word (ALIAS_STR.slot_else)).if {
- els := ALIAS_ARRAY[LIP_CODE].new;
+ els := ALIAS_ARRAY(LIP_CODE).new;
(read_character '{').if_false {
warning_error (current_position,"Added '(' is needed.");
};
@@@ -2865,7 -3006,7 +2912,7 @@@
(read_character '}').if_false {
warning_error (current_position,"Added '(' is needed.");
};
- els := ALIAS_ARRAY[LIP_CODE].copy els;
+ els := ALIAS_ARRAY(LIP_CODE).copy els;
};
result := LIP_IF.create current_position if rec then the else els;
//}.elseif {read_word (ALIAS_STR.slot_print)} then {
@@@ -3066,13 -3207,13 +3113,13 @@@
//|| FORMAT -> { '-' identifier ':=' SHORT_DEF ';' }
- read_format <-
- ( + def:LINKED_LIST[STRING_CONSTANT];
+ ( + def:LINKED_LIST(STRING_CONSTANT);
{read_character '-'}.while_do {
(read_identifier).if_false {
syntax_error (current_position,"Incorrect slot identifier.");
};
- def := LINKED_LIST[STRING_CONSTANT].create;
+ def := LINKED_LIST(STRING_CONSTANT).create;
(short_dico.fast_has last_string).if {
syntax_error (current_position,"Double definition slot.");
};
@@@ -3096,7 -3237,7 +3143,7 @@@
);
//|| SHORT_DEF -> { SHORT_ELT '+' } SHORT_ELT
- - read_short_def def:LINKED_LIST[STRING_CONSTANT] :BOOLEAN <-
+ - read_short_def def:LINKED_LIST(STRING_CONSTANT) :BOOLEAN <-
( + result:BOOLEAN;
read_short_elt.if {
@@@ -3174,7 -3315,7 +3221,7 @@@ Section Publi
is_active_short := TRUE;
short_derive := 0;
output_code.copy source;
- short_local := HASHED_SET[STRING_CONSTANT].create;
+ short_local := HASHED_SET(STRING_CONSTANT).create;
short (ALIAS_STR.short_begin) token 1 to 1;
};
diff --combined src/tools/alias_str.li
index 2d08764,6240795..57c5870
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@@ -34,9 -34,9 +34,9 @@@ Section Inheri
Section Private
- - list:HASHED_SET[ABSTRACT_STRING];
+ - list:HASHED_SET(ABSTRACT_STRING);
- - free:FAST_ARRAY[STRING] := FAST_ARRAY[STRING].create_with_capacity 5;
+ - free:FAST_ARRAY(STRING) := FAST_ARRAY(STRING).create_with_capacity 5;
Section Public
@@@ -188,8 -188,6 +188,8 @@@
- path_lisaac :STRING_CONSTANT := "__PATH_LISAAC_SYSTEM__";
- short_format :STRING_CONSTANT := "__SHORT_LISAAC_FORMAT__";
+ - ext_c :STRING_CONSTANT := ".c";
+ - ext_java :STRING_CONSTANT := ".java";
- path_current :STRING_CONSTANT := ".";
- make_lip :STRING_CONSTANT := "make.lip";
@@@ -214,6 -212,8 +214,8 @@@
- short_comment_line :STRING_CONSTANT := "comment_line";
- short_comment_slot_line :STRING_CONSTANT := "comment_slot_line";
- short_comment_header_line:STRING_CONSTANT := "comment_header_line";
+ - short_comment_new_line_slot :STRING_CONSTANT := "comment_new_line_slot";
+ - short_comment_new_line_extern:STRING_CONSTANT := "comment_new_line_extern";
- short_comment :STRING_CONSTANT := "comment";
- short_slot :STRING_CONSTANT := "slot";
- short_slot_call :STRING_CONSTANT := "slot_call";
@@@ -295,8 -295,12 +297,12 @@@
( + result:STRING_CONSTANT;
+ v,m:INTEGER;
- tmp_name.copy str;
- tmp_name.append "__";
+ (is_readable).if {
+ tmp_name.copy str;
+ tmp_name.append "__";
+ } else {
+ tmp_name.copy "__";
+ };
count_variable := count_variable + 1;
v:=count_variable;
{ v = 0 }.until_do {
@@@ -338,7 -342,7 +344,7 @@@
(
tmp_name := STRING.create 255;
- list := HASHED_SET[ABSTRACT_STRING].create;
+ list := HASHED_SET(ABSTRACT_STRING).create;
// Keyword list :
list.add keyword_section;
@@@ -490,8 -494,6 +496,8 @@@
list.add path_lisaac;
list.add short_format;
+ list.add ext_c;
+ list.add ext_java;
list.add path_current;
list.add make_lip;
@@@ -511,6 -513,8 +517,8 @@@
list.add short_comment_line;
list.add short_comment_slot_line;
list.add short_comment_header_line;
+ list.add short_comment_new_line_slot;
+ list.add short_comment_new_line_extern;
list.add short_comment;
list.add short_slot;
list.add short_slot_call;
diff --combined src/tools/backend.li
index d8508f5,de03dba..26ab106
--- a/src/tools/backend.li
+++ b/src/tools/backend.li
@@@ -33,684 -33,6 +33,740 @@@ Section Inheri
Section Public
+ - source_extension :STRING_CONSTANT <- (deferred; NULL);
+
+ //
+ // 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 (ALIAS_STR.separate);
+ 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 (ALIAS_STR.separate);
+ );
+
+ - append_type_typeid_name_for t:TYPE in buf:STRING <-
+ (
+ buf.append (ALIAS_STR.separate);
+ buf.append (t.intern_name);
+ buf.append (ALIAS_STR.separate);
+ );
+
+ //
+ // 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_generic_in buf:STRING <- deferred;
+ - generate_type_struct_for_null_in buf:STRING <- deferred;
+ - generate_type_struct_for_context_in buf:STRING <- deferred;
+
+ - generate_type_reference_star_declaration_in buf:STRING <- deferred;
+ - generate_type_expanded_declaration_for t:TYPE in buf:STRING <- deferred;
+ - generate_type_generic_declaration_in buf:STRING <- deferred;
+ - generate_type_access_id_for_expr e:EXPR in buf:STRING <- deferred;
+ - generate_type_access_id_for_block e:EXPR in buf:STRING <-
+ (
+ e.genere buf;
+ //buf.append ".__id";
+ );
+
+ //
+ // Functions
+ //
+
+ - generate_function_header_in buffer:STRING <-
+ (
+ buffer.append "{\n";
+ indent.append " ";
+ );
+
- - generate_function_locals tab:FAST_ARRAY[LOCAL] in buf:STRING <-
++ - generate_function_locals tab:FAST_ARRAY(LOCAL) in buf:STRING <-
+ [
+ -? { ! tab.is_empty };
+ ]
+ ( + loc:LOCAL;
+ + t:TYPE_FULL;
+ + cur:INTEGER;
+
+ (tab.lower).to (tab.upper) do { j:INTEGER;
+ loc := tab.item j;
+ loc.is_result.if_false {
+ (((buf.count + loc.intern_name.count - cur) > 70) || {t != loc.type}).if {
+ // New line
+ (t != NULL).if {
+ buf.append ";\n";
+ };
+ cur := buf.count;
+ t := loc.type;
+ buf.append indent;
+ t.genere_declaration buf;
+ buf.add_last ' ';
+ } else {
+ buf.add_last ',';
+ };
+ t.genere_star_declaration buf;
+ buf.append (loc.intern_name);
+ };
+ };
+ buf.append ";\n";
+ );
+
+ - generate_function_instruction i:INSTR in buffer:STRING <-
+ ( + count:INTEGER;
+ buffer.append indent;
+ count := buffer.count;
+ i.genere buffer;
+ (buffer.count = count).if {
+ buffer.remove_last (indent.count);
+ } else {
+ buffer.append ";\n";
+ };
+ );
+
+ - generate_function_footer_in buffer:STRING <-
+ (
+ indent.remove_last 2;
+ buffer.append indent;
+ buffer.add_last '}';
+ );
+
+ //
+ // Read and Write
+ //
+
+ - generate_read_slot_for read: READ_SLOT in buf:STRING <- deferred;
+ - generate_write_slot_for write:WRITE_SLOT in buf:STRING <- deferred;
+ - generate_write_for write:WRITE in buf:STRING <-
+ (
+ write.genere_access buf;
+ buf.add_last '=';
+ write.genere_value buf;
+ );
+ - generate_write_value_for write:WRITE in buf:STRING <-
+ (
+ write.value.genere buf;
+ );
+
+ //
+ // Other instructions
+ //
+
+ - generate_instruction_deferred i:INSTR in buf:STRING <-
+ (
+ buf.append "#error \"";
+ buf.append "INSTR: can't generate instruction: ";
+ i.display buf;
+ buf.add_last '"';
+ );
+
+ - generate_call_on_null_in buffer:STRING <-
+ (
+ (debug_level_option != 0).if {
+ buffer.append
+ "stack_print(top_context); \
+ \print_string(\"Call on NULL\\n\"); \
+ \die_with_code(1)";
+ } else {
+ buffer.append
+ "print_string(\"Call on NULL\\n\
+ \(Use `debug' option)\\n\"); \
+ \die_with_code(1)";
+ };
+ );
+
+ - generate_put_to put_to:PUT_TO for_type t:TYPE_FULL in buffer:STRING <-
+ (
+ put_to.receiver.genere buffer;
+ buffer.add_last '[';
+ put_to.index.genere buffer;
+ buffer.append "]=";
+
+ ((t.is_expanded) && {! t.is_expanded_c} &&
+ {put_to.value.static_type.is_expanded_ref}).if
+ {
+ buffer.append "*(";
+ put_to.value.genere buffer;
+ buffer.add_last ')';
+ } else {
+ put_to.value.genere buffer;
+ };
+ );
+
+ - generate_loop_while_do l:LOOP
+ condition e:EXPR
+ inverse inverse:BOOLEAN
+ body lst:LIST
+ in buffer:STRING <-
+ (
+ buffer.append "while (";
+ inverse.if { buffer.add_last '!'; };
+ e.genere buffer;
+ buffer.append ") ";
+ lst.genere buffer;
+ );
+
+ - generate_loop_do_while l:LOOP
+ condition e:EXPR
+ inverse inverse:BOOLEAN
+ body lst:LIST
+ in buffer:STRING <-
+ (
+ buffer.append "do ";
+ lst.genere buffer;
+ buffer.append " while (";
+ inverse.if { buffer.add_last '!'; };
+ e.genere buffer;
+ buffer.add_last ')';
+ );
+
+ - generate_loop l:LOOP in buffer:STRING <-
+ (
+ buffer.append (l.name);
+ buffer.append ":\n";
+ buffer.append indent;
+ l.body.genere buffer;
+ );
+
+ - generate_loop_end l:LOOP_END in buffer:STRING <-
+ (
+ buffer.append "goto ";
+ buffer.append (l.loop.name);
+ );
+
- - generate_if sw:SWITCH in buffer:STRING :INTEGER <-
- ( + first_case:INTEGER;
- + typ_first:TYPE;
- + typ_id:TYPE_ID;
- typ_first := sw.list.first.id;
- typ_id ?= typ_first;
++Section Private
+
- //
- // If Condition
- //
- buffer.append "if (";
- ((sw.expr.static_type.raw.is_block) && {typ_first = TYPE_NULL}).if {
- sw.expr.genere buffer;
++ - generate_if_test (expr:EXPR, type:TYPE) in buffer:STRING <-
++ (
++ // TODO: Mildred: Improve. There should be no special case.
++ ((expr.static_type.raw.is_block) && {type = TYPE_NULL}).if {
++ expr.genere buffer;
+ buffer.append ".__id==0";
+ } else {
- typ_first.put_access_id (sw.expr) in buffer;
- (sw.expr.static_type.raw != type_boolean).if {
++ type.put_access_id expr in buffer;
++ (expr.static_type.raw != type_boolean).if {
+ buffer.append "==";
- typ_first.put_id buffer;
++ type.put_id buffer;
+ } else {
- ? {typ_first.shortname = ALIAS_STR.prototype_true};
++ ? {type.shortname = ALIAS_STR.prototype_true};
+ };
+ };
++ );
++
++Section Public
++
++ - generate_if sw:SWITCH in buffer:STRING <-
++ [
++ -? {sw.list.count > 1};
++ ]
++ (
++ // If Condition
++ buffer.append "if (";
++ generate_if_test (sw.expr, sw.list.first.id) in buffer;
+ buffer.append ") ";
+
- //
+ // If Block
- //
+ sw.list.first.genere buffer;
- first_case := 1;
++ );
++
++ - generate_if_else sw:SWITCH in buffer:STRING <-
++ [
++ -? {sw.list.count > 1};
++ -? {sw.list.count <= 2};
++ ]
++ (
++ generate_if sw in buffer;
+
- //
+ // Else
- //
+ (sw.list.count = 2).if {
+ buffer.append " else ";
+ buffer.append "/* ";
+ buffer.append (sw.list.second.id.name);
+ buffer.append " */ ";
+ sw.list.second.genere buffer;
- first_case := 2;
+ };
-
- first_case
+ );
+
- - generate_if_else_begin sw:SWITCH in buffer:STRING <-
++ - generate_if sw:SWITCH else blc:{} in buffer:STRING <-
++ [
++ -? {sw.list.count > 1};
++ ]
+ (
++ generate_if sw in buffer;
++
++ // Else
+ buffer.append " else {\n";
+ indent.append " ";
+ buffer.append indent;
++ blc.value;
++ buffer.add_last '\n';
++ indent.remove_last 2;
++ buffer.append indent;
++ buffer.add_last '}';
+ );
+
- - generate_if_else_end sw:SWITCH in buffer:STRING <-
++ - generate_if c1:CASE else c2:CASE in buffer:STRING <-
+ (
- buffer.add_last '\n';
- indent.remove_last 2;
++ buffer.append "if (";
++ c1.id.put_access_id (sw.expr) in buffer;
++ buffer.append "==";
++ c1.id.put_id buffer;
++ buffer.append ") ";
++ c1.genere buffer;
++ buffer.append " else /* Other types */ ";
++ c2.genere buffer;
++ );
++
++ - generate_switch cases:FAST_ARRAY(FAST_ARRAY(CASE)) for sw:SWITCH first_case first_case:INTEGER in buffer:STRING <-
++ [
++ -? { switch_can_fusion };
++ -? { case != NULL };
++ ]
++ ( + lst_case:FAST_ARRAY(CASE);
++
++ buffer.append "switch (";
++ sw.list.item first_case.id.put_access_id expr in buffer;
++ buffer.append ") {\n";
++
++ (cases.lower).to (cases.upper) do { j:INTEGER;
++ lst_case := cases.item j;
++ (! lst_case.first.code.is_empty).if {
++ (lst_case.lower).to (lst_case.upper) do { i:INTEGER;
++ buffer.append indent;
++ buffer.append "case ";
++ lst_case.item i.id.put_id buffer;
++ buffer.append ": \n";
++ };
++ buffer.remove_last 1;
++ lst_case.first.genere buffer;
++ buffer.append " break;\n";
++ };
++ };
++
+ buffer.append indent;
+ buffer.add_last '}';
+ );
+
++/*
+ - generate_switch sw:SWITCH first_case first_case:INTEGER in buffer:STRING <-
+ (
+ //
+ // Switch
+ //
+ buffer.append "switch (";
+ sw.list.item first_case.id.put_access_id (sw.expr) in buffer;
+ buffer.append ") {\n";
+
+ //
+ // Each case
+ //
+ (first_case).to (sw.list.upper) do { j:INTEGER;
+ buffer.append indent;
+ buffer.append "case ";
+ sw.list.item j.id.put_id buffer;
+ buffer.append ": ";
+ sw.list.item j.genere buffer;
+ buffer.add_last ' ';
+ buffer.append "break;\n";
+ };
+
+ //
+ // Twilight Zone (default)
+ //
+ buffer.append indent;
+ buffer.append "default: ";
+ (debug_level_option != 0).if {
+ buffer.append
+ "stack_print(top_context); \
+ \print_string(\"Call on Twilight Zone\\n\"); \
+ \die_with_code(1);";
+ } else {
+ buffer.append
+ "print_string(\"Call on Twilight Zone\\n\
+ \(Use `debug' option)\\n\"); \
+ \die_with_code(1);";
+ };
+
+ buffer.append indent;
+ buffer.add_last '}';
+ );
++*/
+
+
+ - generate_cop_lock l:COP_LOCK in buffer:STRING <-
+ (
+ buffer.append "// Pre thread.\n";
+ // buffer.append "print_char('(');\n";
+ // buffer.append "print_char('\\n');\n";
+ buffer.append indent;
+ buffer.append "{ lith_node node,*n;\n";
+ indent.append " ";
+ buffer.append indent;
+ buffer.append "lith_object *obj;\n";
+ buffer.append indent;
+ buffer.append "void *thread_save;\n";
+ buffer.append indent;
+ buffer.append "obj = &((";
+ l.data.genere buffer;
+ buffer.append ")->thread);\n";
+ buffer.append indent;
+ buffer.append "node.next = NULL;\n";
+ buffer.append indent;
+ buffer.append "pthread_mutex_init(&node.mutex,NULL);\n";
+ buffer.append indent;
+ buffer.append "pthread_mutex_lock(&obj->mutex);\n";
+ buffer.append indent;
+ buffer.append "n = obj->last;\n";
+ buffer.append indent;
+ buffer.append "if (n == NULL) {\n";
+ buffer.append indent;
+ buffer.append " obj->first = &node;\n";
+ buffer.append indent;
+ buffer.append "} else {\n";
+ buffer.append indent;
+ buffer.append " n->next = &node;\n";
+ buffer.append indent;
+ buffer.append " pthread_mutex_lock(&node.mutex);\n";
+ buffer.append indent;
+ buffer.append "};\n";
+ buffer.append indent;
+ buffer.append "obj->last = &node;\n";
+ buffer.append indent;
+ buffer.append "pthread_mutex_unlock(&obj->mutex);\n";
+ //
+ buffer.append indent;
+ buffer.append "pthread_mutex_lock (&node.mutex);\n";
+ buffer.append indent;
+ buffer.append "thread_save=pthread_getspecific(current_thread);\n";
+ buffer.append indent;
+ buffer.append "pthread_setspecific(current_thread,";
+ l.data.genere buffer;
+ buffer.add_last ')';
+ );
+
+ - generate_cop_unlock l:COP_UNLOCK in buffer:STRING <-
+ (
+ buffer.append "pthread_mutex_lock(&(obj->mutex));\n";
+ buffer.append indent;
+ buffer.append "n = obj->first->next;\n";
+ buffer.append indent;
+ buffer.append "if (n != NULL) {\n";
+ buffer.append indent;
+ buffer.append " pthread_mutex_unlock(&n->mutex);\n";
+ buffer.append indent;
+ buffer.append "} else {\n";
+ buffer.append indent;
+ buffer.append " obj->last = NULL;\n";
+ buffer.append indent;
+ buffer.append "};\n";
+ buffer.append indent;
+ buffer.append "obj->first = n;\n";
+ buffer.append indent;
+ buffer.append "pthread_mutex_unlock(&obj->mutex);\n";
+ buffer.append indent;
+ buffer.append "pthread_setspecific(current_thread,thread_save);\n";
+ indent.remove_last 2;
+ buffer.append indent;
+ buffer.add_last '}';
+ );
+
+ - generate_cop_call_slot call:CALL_SLOT in buffer:STRING <-
+ ( + val:WRITE;
+ + np:INTEGER;
+ + low:INTEGER;
+ + back:INTEGER;
+
+ (
+ (call.argument_list.count >=1) &&
+ {call.argument_list.first != NULL} &&
+ {call.argument_list.first.variable.name = ALIAS_STR.variable_self}
+ ).if {
+ low := 1;
+ };
+ (call.argument_list.count-low > 0).if {
+ back := buffer.count;
+ buffer.append "pthread_mutex_lock (&(";
+ call.cop_argument.genere buffer;
+ buffer.append "->thread.mutex));\n";
+ (low).to (call.argument_list.upper) do { j:INTEGER;
+ val := call.argument_list.item j;
+ (val != NULL).if {
+ buffer.append indent;
+ call.cop_argument.genere buffer;
+ buffer.append "->param_";
+ np.append_in buffer;
+ buffer.append "=(int)";
+ val.genere_value buffer;
+ buffer.append ";\n";
+ np := np + 1;
+ } else {
+ "arg null\n".print;
+ };
+ };
+ buffer.append indent;
+ (np = 0).if {
+ buffer.keep_head back;
+ };
+ };
+ call.cop_argument.genere buffer;
+ buffer.append "->thread.procedure = COP_";
+ buffer.append (call.profil.name);
+ buffer.append ";\n";
+ buffer.append indent;
+ (call.is_cop_return).if {
+ buffer.append "return";
+ } else {
+ buffer.append "run_procedure";
+ };
+ buffer.append "((lith_object *)";
+ call.cop_argument.genere buffer;
+ buffer.add_last ')';
+ );
+
+ - generate_call_slot call:CALL_SLOT in buffer:STRING <-
+ ( + val:WRITE;
+ + arg:LOCAL;
+ + wrt:WRITE_LOCAL;
+
+ //
+ // Get the return value
+ //
+ (call.result_list.is_empty).if_false {
+ wrt ?= call.result_list.first.write;
+ wrt.genere_first_result buffer;
+ };
+
+ //
+ // Function Call
+ //
+ buffer.append (call.profil.name);
+ (! call.is_interrupt).if {
+ buffer.add_last '(';
+
+ //
+ // Argument List
+ //
+ (call.argument_list.lower).to (call.argument_list.upper) do { j:INTEGER;
+ val := call.argument_list.item j;
+ arg := call.profil.argument_list.item j;
+ (val != NULL).if {
+ (buffer.last != '(').if {
+ buffer.add_last ',';
+ };
+ val.genere_value buffer;
+ };
+ };
+
+ //
+ // Result List
+ //
+ (call.result_list.count > 1).if {
+ (call.result_list.lower+1).to (call.result_list.upper) do { j:INTEGER;
+ (buffer.last != '(').if {
+ buffer.add_last ',';
+ };
+ wrt ?= call.result_list.item j.write;
+ wrt.genere_argument_result buffer;
+ };
+ };
+
+ //
+ // End
+ //
+ buffer.add_last ')';
+ };
+ );
+
+ - generate_push p:PUSH id id:UINTEGER_32 in buffer:STRING <-
- (
++ ( + idf:STRING_CONSTANT;
++
++ idf := ALIASER_LOCAL.push Self;
+ p.is_first.if {
+ buffer.append "push_first(&";
+ } else {
+ buffer.append "push(&";
+ };
- buffer.append (p.context.intern_name);
++ buffer.append idf;
+ buffer.add_last ',';
+ (debug_with_code).if {
+ buffer.add_last 'L';
+ };
+ id.append_in buffer;
+ buffer.add_last ')';
+ buffer.append "; // L";
+ p.position.line.append_in buffer;
+ buffer.add_last ' ';
+ buffer.append (p.position.prototype.name);
+ );
+
+ //
+ // Misc Code
+ //
+
+ - append_null_value_in buf:STRING <- deferred;
+ - append_cop_init_code_in buf:STRING <- deferred;
+ - append_init_code_in buf:STRING input_name input_name:STRING_CONSTANT <- deferred;
+ - append_debug_code_in buf:STRING <- deferred;
+ - append_main_function_in buf:STRING <- deferred;
+ - append_main_init_code_in buf:STRING <- deferred;
+ - append_main_return_code_in buf:STRING <- deferred;
+ - append_end_of_file_in buf:STRING;
+
+ - generate_table_type_in buf:STRING <- deferred;
+ - generate_debug_manager_in buf:STRING <- deferred;
+ - generate_trace_declarations_in buf:STRING <- deferred;
+ - generate_trace_codedata_in buf:STRING declarations_in decl:STRING <- deferred;
+ - generate_trace_code_in buf:STRING <- deferred;
+
+ - generate_title txt:STRING_CONSTANT in buf:STRING <-
+ (
+ buf.append "\n//";
+ 3.to 28 do { j:INTEGER;
+ buf.add_last '=';
+ };
+ buf.append "//\n// ";
+ buf.append txt;
+ (txt.count+5).to 28 do { j:INTEGER;
+ buf.add_last ' ';
+ };
+ buf.append " //\n//";
+ 3.to 28 do { j:INTEGER;
+ buf.add_last '=';
+ };
+ buf.append "//\n\n";
+ );
+
+
+Section STRING_CST
+
+ //
+ // STRING_CONSTANT
+ //
+
+ - string_constant_declaration :STRING :=
+ ( + result:STRING;
+
+ result := STRING.create 256;
+ title "STRING CONSTANT" in result;
+ result
+ );
+
+ - string_constant_count :INTEGER;
+
+Section Public
+
+ - generate_string_constant s:STRING_CST in buffer:STRING <-
+ ( + idx,count,cur:INTEGER;
+ + output :STRING;
+ - is_init:BOOLEAN;
+ - is_storage:BOOLEAN;
+ - is_count:BOOLEAN;
+
+ output := string_constant_declaration;
+ // use a shorter name
+
+ (is_init).if_false {
+ is_storage := type_string_constant.get_local_slot (ALIAS_STR.slot_storage)
+ .slot_data_intern
+ .ensure_count != 0;
+ is_count := type_string_constant.get_local_slot (ALIAS_STR.slot_count)
+ .slot_data_intern
+ .ensure_count != 0;
+ is_init := TRUE;
+ };
+
+ count := s.dico_string.fast_at (s.string);
+ (count >= 0).if {
+ string_constant_count := string_constant_count + 1;
+ idx := string_constant_count;
+
+ cur := output.count - 1;
+ (is_java).if {
+ output.append "private static ";
+ };
+ append_type_name_for type_string_constant in output;
+ ((output.count - cur) >= 78).if {
+ output.add_last '\n';
+ cur := output.count - 1;
+ } else {
+ output.add_last ' ';
+ };
+ output.append "__string_";
+ idx.append_in output;
+ output.add_last '=';
+ (is_java).if {
+ output.append "new ";
+ append_type_name_for type_string_constant in output;
+ output.add_last '(';
+ } else {
+ output.add_last '{';
+ (s.static_type.is_late_binding).if {
+ append_type_typeid_name_for (s.static_type.raw) in output;
+ };
+ };
+ (is_count).if {
+ count.append_in output;
+ output.add_last ',';
+ };
+ (is_storage).if {
+ ((output.count - cur) >= 78).if {
+ output.add_last '\n';
+ cur := output.count - 1;
+ };
+ output.add_last '\"';
+ append_escaped_string (s.string)
+ in output
+ split_every 78
+ starting (output.count - cur);
+ output.add_last '\"';
+ } else {
+ output.remove_last 1;
+ };
+ (is_java).if {
+ output.append ");\n";
+ } else {
+ output.append "};\n";
+ };
+ s.dico_string.fast_put (-idx) to (s.string);
+ } else {
+ idx := -count;
+ };
+ //
+ (is_java).if {
+ buffer.append "__string_";
+ idx.append_in buffer;
+ } else {
+ buffer.append "(&__string_";
+ idx.append_in buffer;
+ buffer.add_last ')';
+ };
+ );
+
+ //
+ // String Constant
+ //
+
- append_string str:ABSTRACT_STRING in buf:STRING <-
(
buf.add_last '\"';
@@@ -725,6 -47,10 +781,6 @@@
buf.add_last '\'';
);
-
-
-
-
- append_escaped_character c:CHARACTER in buf:STRING <-
(
(c = '\0').if { buf.add_last '\\'; buf.add_last '0';
@@@ -736,7 -62,7 +792,7 @@@
}.elseif {c = '\t'} then { buf.add_last '\\'; buf.add_last 't';
}.elseif {c = '\v'} then { buf.add_last '\\'; buf.add_last 'v';
}.elseif {c = '\\'} then { buf.add_last '\\'; buf.add_last '\\';
- }.elseif {c = '\?'} then { buf.add_last '\\'; buf.add_last '?';
+ //}.elseif {c = '\?'} then { buf.add_last '\\'; buf.add_last '?';
}.elseif {c = '\v'} then { buf.add_last '\\'; buf.add_last 'v';
}.elseif {c = '\''} then { buf.add_last '\\'; buf.add_last '\'';
}.elseif {c = '\"'} then { buf.add_last '\\'; buf.add_last '\"';
diff --combined src/tools/backend_c.li
index 7f13a9f,bab552a..0f67964
--- a/src/tools/backend_c.li
+++ b/src/tools/backend_c.li
@@@ -33,667 -33,4 +33,703 @@@ Section Inheri
Section Public
+ - source_extension :STRING_CONSTANT := ALIAS_STR.ext_c;
+
+ - generate_type_typedef_for t:TYPE in buf:STRING <-
- (
++ ( + alias:TYPE;
++
+ buf.append "typedef ";
+ (t.type_c != NULL).if {
+ buf.append (t.type_c);
+ } else {
++ alias := t;
++ {alias.alias_slot = NULL}.until_do {
++ alias := alias.alias_type;
++ };
+ buf.append "struct ";
- append_type_struct_name_for t in buf;
++ append_type_struct_name_for alias in buf;
+ };
+ append_type_name_for t in buf;
- buf.append ";\n";
++ buf.add_last ';';
++ ((t.type_c = NULL) && {t.alias_slot != NULL}).if {
++ output_decl.append " // ALIAS with ";
++ output_decl.append (alias_type.intern_name);
++ };
++ buf.add_last '\n';
+ );
+
+ - generate_type_struct_for_generic_in buf:STRING <-
+ (
+ buf.append
+ "// Generic Object\n\
+ \struct ___OBJ {\n\
+ \ unsigned long __id;\n\
+ \};\n\n";
+ );
+
+ - generate_type_struct_for_null_in buf:STRING <-
+ (
+ buf.append
+ "// NULL\n\
+ \#ifndef NULL\n\
+ \#define NULL ((void *)0)\n\
+ \#endif\n\n";
+ );
+
+ - generate_type_struct_for_context_in buf:STRING <-
+ (
+ buf.append
+ "// ___CONTEXT\n\
+ \typedef struct ___CONTEXT_struct _____CONTEXT; \n\
+ \struct ___CONTEXT_struct {\n\
+ \ unsigned long code; \n\
+ \ _____CONTEXT *back; \n\
+ \};\n\
+ \_____CONTEXT *top_context; \n\n";
+ );
+
+ - generate_type_struct_for t:TYPE in buf:STRING <-
+ ( + slot_data:SLOT_DATA;
- + tab:FAST_ARRAY[SLOT_DATA];
++ + tab:FAST_ARRAY(SLOT_DATA);
+ + num_slots :INTEGER;
+
+
+ //
+ // Type C
+ //
+
+ (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';
+ };
+
+
+ //
+ // Lisaac defined type
+ //
+
+ } else {
+
+ //
+ // Comment
+ //
+ buf.append "// ";
+ buf.append (t.intern_name);
+ buf.add_last '\n';
+
+ //
+ // Type ID
+ //
+ 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';
+
- //
- // 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";
- };
-
- //
- // End structure declaration
- //
- (t.prototype.is_mapping).if {
- buf.append "} __attribute__ ((packed));\n";
- } else {
- buf.append "};\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";
++ };
++
++ //
++ // End structure declaration
++ //
++ (t.prototype.is_mapping).if {
++ buf.append "} __attribute__ ((packed));\n";
++ } else {
++ buf.append "};\n";
++ };
+ };
+ };
+ );
+
+
+ - generate_type_globals_for t:TYPE in buf:STRING <-
+ (
+ (t.type_c = NULL).if {
+ append_type_name_for t in buf;
+ buf.add_last ' ';
+ append_type_expanded_proto_name_for t in buf;
+ t.is_late_binding.if {
+ buf.append "={";
+ append_type_typeid_name_for t in buf;
+ buf.append (t.intern_name);
+ buf.append "}";
+ };
+ buf.append ";\n";
+ buf.append "#define ";
+ append_type_proto_name_for t in buf;
+ buf.append " (&";
+ append_type_expanded_proto_name_for t in buf;
+ buf.append ")\n\n";
+ };
+
+ );
+
+ - generate_type_reference_star_declaration_in buf:STRING <-
+ (
+ buf.add_last '*';
+ );
+
+ - generate_type_expanded_declaration_for t:TYPE in buf:STRING <-
+ (
+ append_type_name_for t in buf;
+ );
+
+ - generate_type_generic_declaration_in buf:STRING <-
+ (
+ buf.append (ALIAS_STR.c_void);
+ );
+
+
+ - generate_type_access_id_for_expr e:EXPR in buf:STRING <-
+ (
+ buf.append "((struct ___OBJ *)";
+ e.genere buf;
+ buf.append ")->__id";
+ );
+
+ - generate_read_slot_for read:READ_SLOT in buf:STRING <-
- ( + tf:TYPE_FULL;
++ ( + tf,tf2:TYPE_FULL;
+ + t:TYPE;
++ + add_end:BOOLEAN;
++ + ptr,ptr2:BOOLEAN;
+
+ (read.slot.intern_name = ALIAS_STR.slot_self).if {
+ // TODO: Mildred: WHAT IS THAT?
+ // If it's for BLOCKs only, why not test the type ?
+ buf.append "((";
+ tf := read.slot.type;
+ tf.genere_declaration buf;
+ buf.add_last ' ';
+ tf.genere_star_declaration buf;
+ buf.add_last ')';
+ read.receiver.genere buf;
+ buf.append ".self)";
+ } else {
+ tf := read.receiver.static_type;
- ((tf.is_strict) || {tf.is_expanded_ref}).if {
- read.receiver.genere buf;
- buf.append "->";
- }.elseif {tf.is_expanded} then {
++
++ t := read.slot.receiver_type;
++ (t.alias_slot != NULL).if {
++ tf2 := slot.type;
++ ptr := (! tf .is_expanded) || {tf .is_expanded_ref} || {tf .is_strict};
++ ptr2 := (! tf2.is_expanded) || {tf2.is_expanded_ref} || {tf2.is_strict};
++ (ptr != ptr2).if {
++ add_end := TRUE;
++ (ptr).if {
++ buffer.append "(*(";
++ } else {
++ buffer.append "(&(";
++ };
++ };
++ };
++ ((tf.is_strict) || {tf.is_expanded_ref} || {tf.is_expanded}).if {
+ read.receiver.genere buf;
- buf.add_last '.';
+ } else {
+ buf.append "((";
- t := read.slot.receiver_type;
+ t.put_reference_declaration buf;
+ buf.add_last ' ';
+ t.put_reference_star_declaration buf;
+ buf.add_last ')';
+ read.receiver.genere buf;
- buf.append ")->";
++ buf.append ")";
++ };
++ (t.alias_slot = NULL).if {
++ ((tf.is_expanded) && {! tf.is_expanded_ref} && {! tf.is_strict}).if {
++ buffer.add_last '.';
++ } else {
++ buffer.append "->";
++ };
++ buffer.append (read.variable.intern_name);
++ }.elseif {add_end} then {
++ buffer.append "))";
+ };
- buf.append (read.variable.intern_name);
+ };
+ );
+
+ - generate_write_slot_for write:WRITE_SLOT in buf:STRING <-
+ ( + tf:TYPE_FULL;
+ + t:TYPE;
+
+ // Receiver.
++ (quiet_generation).if {
++ buffer.append "/* WRTOK */";
++ } else {
++ buffer.append "/* WRTNO */";
++ };
+ tf := write.receiver.static_type;
+ ((tf.is_strict) || {tf.is_expanded_ref}).if {
+ write.receiver.genere buf;
+ buf.append "->";
+ }.elseif {tf.is_expanded} then {
+ write.receiver.genere buf;
+ buf.add_last '.';
+ } else {
+ buf.append "((";
+ t := write.slot.receiver_type;
+ t.put_reference_declaration buf;
+ buf.add_last ' ';
+ t.put_reference_star_declaration buf;
+ buf.add_last ')';
+ write.receiver.genere buf;
+ buf.append ")->";
+ };
+ //
+ buf.append (write.variable.intern_name);
+ //
+ ((write.value.static_type.raw = TYPE_NULL) &&
+ {write.variable.type.raw.is_block}).if
+ {
+ buf.append ".__id=0";
+ } else {
+ buf.add_last '=';
+ write.genere_value buf;
+ };
+ );
+
+ - generate_write_value_for write:WRITE in buf:STRING <-
+ (
+ (
+ (write.static_type.is_expanded_ref) &&
+ {! write.value.static_type.is_expanded_ref}
+ ).if {
+ ? {write.value.static_type.is_expanded};
+ buf.append "&(";
+ write.value.genere buf;
+ buf.add_last ')';
+ }.elseif {
+ ( write.static_type.is_expanded ) &&
+ {! write.static_type.is_expanded_ref } &&
+ { (! write.value.static_type.is_expanded) ||
+ { write.value.static_type.is_expanded_ref} } &&
+ { write.value.static_type.raw != TYPE_NULL } // For Pointer := NULL
+ } then {
+ buf.append "*(";
+ write.value.genere buf;
+ buf.add_last ')';
+ } else {
+ write.value.genere buf;
+ };
+ );
+
+
+ - append_null_value_in buf:STRING <-
+ (
+ buf.append "NULL";
+ );
+
+
+ - append_cop_init_code_in buf:STRING <-
+ (
+ buf.append
+ "#include <pthread.h>\n\
+ \#include <limits.h>\n\n\
+ \void print_char(char car);\n\
+ \int die_with_code(int code);\n\n\
+ \static pthread_key_t current_thread;\n\
+ \static pthread_attr_t thread_attr;\n\
+ \pthread_t c_thread;\n\
+ \int thread_counter;\n\n\
+ \static char thread_stack[512][PTHREAD_STACK_MIN];\n\n\
+ \typedef struct lith_object_struct lith_object;\n\
+ \typedef struct lith_node_struct lith_node;\n\
+ \struct lith_node_struct {\n\
+ \ pthread_mutex_t mutex;\n\
+ \ lith_node *next;\n\
+ \ lith_object *object;\n\
+ \};\n\
+ \struct lith_object_struct {\n\
+ \ unsigned long __id; // Just for late binding.\n\
+ \ lith_node *first;\n\
+ \ lith_node *last;\n\
+ \ lith_object *(*procedure)(lith_object *obj,pthread_mutex_t *mutex);\n\
+ \ pthread_mutex_t mutex;\n\
+ \};\n\
+ \struct {\n\
+ \ lith_node *first;\n\
+ \ pthread_mutex_t mutex;\n\
+ \} pool;\n\n\
+ \void *thread_life(void *ptr)\n\
+ \{ lith_node node,*n;\n\
+ \ lith_object *obj,*new_obj;\n\n\
+ \ pthread_mutex_init(&node.mutex,NULL);\n\
+ \ pthread_mutex_lock(&node.mutex);\n\
+ \ node.object = (lith_object *)ptr;\n\
+ \ do {\n\
+ \ // Append fifo object.\n\
+ \ obj = node.object;\n\
+ \ node.next = NULL;\n\
+ \ n = obj->last;\n\
+ \ if (n == NULL) {\n\
+ \ obj->first = &node;\n\
+ \ pthread_mutex_unlock(&node.mutex);\n\
+ \ } else {\n\
+ \ n->next = &node;\n\
+ \ };\n\
+ \ obj->last = &node;\n\
+ \ pthread_setspecific(current_thread,(void *)obj);\n\
+ \ // Run procedure.\n\
+ \ new_obj = obj->procedure(obj,&node.mutex);\n\
+ \ // Remove fifo object.\n\
+ \ pthread_mutex_lock(&obj->mutex);\n\
+ \ n = obj->first->next;\n\
+ \ if (n != NULL) {\n\
+ \ pthread_mutex_unlock(&n->mutex);\n\
+ \ } else {\n\
+ \ obj->last = NULL;\n\
+ \ };\n\
+ \ obj->first = n;\n\
+ \ pthread_mutex_unlock(&obj->mutex);\n\
+ \ if (new_obj != NULL) {\n\
+ \ node.object = new_obj;\n\
+ \ } else {\n\
+ \ // Add in pool.\n\
+ \ pthread_mutex_lock(&pool.mutex);\n\
+ \ node.next = pool.first;\n\
+ \ pool.first = &node;\n\
+ \ pthread_mutex_unlock(&pool.mutex);\n\
+ \ // Sleep.\n\
+ \ pthread_mutex_lock(&node.mutex);\n\
+ \ };\n\
+ \ } while (1);\n\
+ \ return NULL;\n\
+ \};\n\n\
+ \void run_procedure(lith_object *obj)\n\
+ \{ lith_node *node;\n\
+ \ char *msg=\"COP Error!\\n\";\n\
+ \ // Pool manager.\n\
+ \ pthread_mutex_lock(&pool.mutex);\n\
+ \ node = pool.first;\n\
+ \ if (node != NULL) {\n\
+ \ pool.first = node->next;\n\
+ \ };\n\
+ \ pthread_mutex_unlock(&pool.mutex);\n\
+ \ // Run thread.\n\
+ \ if (node == NULL) {\n\
+ \ pthread_attr_setstack(&thread_attr, thread_stack[thread_counter++],PTHREAD_STACK_MIN);\n\
+ \ if ((thread_counter>512) || pthread_create(&c_thread,&thread_attr, thread_life, (void *)obj)) {\n\
+ \ while (*msg != 0) print_char(*(msg++));\n\
+ \ die_with_code(1);\n\
+ \ };\n\
+ \ } else {\n\
+ \ node->object = obj;\n\
+ \ pthread_mutex_unlock(&node->mutex);\n\
+ \ };\n\
+ \};\n\n";
+ );
+
+ - append_init_code_in buf:STRING input_name input_name:STRING_CONSTANT <-
+ (
+ buf.append "// C code generated by Lisaac compiler (www.isaacOS.com) //\n";
+ // ANSI argument command.
+ (debug_level_option != 0).if {
+ buf.append "#include <signal.h>\n";
+ };
+ buf.append
+ "int arg_count;\n\
+ \char **arg_vector;\n";
+ );
+
+ - append_debug_code_in buf:STRING <-
+ (
+ (debug_level_option != 0).if {
+ buf.append "// Debug Manager\n";
+ (is_ansi).if {
+ buf.append "void interrupt_signal(int sig);\n";
+ };
+ buf.append
+ "void stack_print(_____CONTEXT *up);\n\
+ \void push_first(_____CONTEXT *path,unsigned long code);\n\
+ \void push(_____CONTEXT *path,unsigned long code);\n\
+ \void print_integer(unsigned short n);\n";
+ };
+ );
+
+ - append_main_function_in buf:STRING <-
+ (
+ buf.append "int main(int argc,char **argv)\n";
+ buf.append "{\n";
+ );
+
+ - append_main_init_code_in buf:STRING <-
+ (
+ (debug_level_option != 0).if {
+ buf.append "signal(SIGINT,interrupt_signal);\n ";
+ };
+ buf.append
+ "arg_count = argc;\n\
+ \ arg_vector = argv;\n\
+ \#ifdef _PTHREAD_H\n\
+ \ pthread_key_create(¤t_thread, NULL);\n\
+ \ pthread_attr_init(&thread_attr);\n\
+ \ /*pthread_attr_setdetachstate(&thread_attr,PTHREAD_CREATE_DETACHED);*/\n\
+ \#endif\n ";
+ );
+
+ - append_main_return_code_in buf:STRING <-
+ (
+ buf.append " return 0;\n";
+ indent.remove_last 2;
+ buf.append indent;
+ buf.append "}\n\n";
+ );
+
+ - generate_table_type_in buf:STRING <-
+ (
+ buf.append "\nvoid *table_type[";
+ TYPE.id_counter_without_type.append_in buf;
+ buf.append "];\n";
+ );
+
+ - generate_debug_manager_in buf:STRING <-
+ (
+ buf.append
+ "int print_string(char *str) \n\
+ \{ \n\
+ \ while (*str!=0) {\n\
+ \ print_char(*str); \n\
+ \ str++; \n\
+ \ };\n\
++ \ return(0);\n\
+ \}\n\
+ \\n";
+ );
+
+ - generate_trace_declarations_in buf:STRING <-
+ ( + proto:PROTOTYPE;
+
+ buf.append "char *trace[";
+ buf.append (PROTOTYPE.prototype_list.count.to_string);
+ buf.append "]={\n";
+ (PROTOTYPE.prototype_list.lower).to (PROTOTYPE.prototype_list.upper-1) do {
+ j:INTEGER;
+ proto := PROTOTYPE.prototype_list.item j;
+ buf.append " \"";
+ append_escaped_string (proto.name) in buf;
+ buf.append " (";
+ append_escaped_string (proto.filename) in buf;
+ buf.append ")\",\n";
+ };
+ proto := PROTOTYPE.prototype_list.last;
+ buf.append " \"";
+ append_escaped_string (proto.name) in buf;
+ buf.append " (";
+ append_escaped_string (proto.filename) in buf;
+ buf.append ")\"\n};\n\n";
+ );
+
+ - generate_trace_codedata_in buf:STRING declarations_in decl:STRING <-
- ( + src:HASHED_DICTIONARY[STRING,UINTEGER_32];
++ ( + src:HASHED_DICTIONARY(STRING,UINTEGER_32);
+ + key:UINTEGER_32;
+
+ //
+ // Source Code.
+ //
+
+ title "SOURCE LINE REFERENCE" in decl;
+
+ buf.append
+ "struct __source {\n\
+ \ unsigned int pos;\n\
+ \ char *line;\n\
+ \} __src[";
+ src := PUSH.source_line;
+ src.count.append_in buf;
+ buf.append "]={\n";
+ (src.lower).to (src.upper) do { j:INTEGER;
+ key := src.key j;
+ decl.append "#define L";
+ key.append_in decl;
+ decl.add_last ' ';
+ (j-1).append_in decl;
+ decl.add_last '\n';
+ //
+ buf.append " {";
+ key.append_in buf;
+ buf.append ",\"";
+ buf.append (src.item j);
+ buf.append "\"},\n";
+ };
+ buf.remove (buf.upper - 1);
+ buf.append "};\n\n";
+ );
+
+ - generate_trace_code_in buf:STRING <-
+ (
+
+ //
+ // Signal Manager
+ //
+
+ (is_ansi).if {
+ buf.append
+ "// Unix Signal manager:\n\
+ \void interrupt_signal(int sig) \n\
+ \{ \n\
+ \ stack_print(top_context); \n\
+ \ print_string(\"User interrupt.\\n\"); \n\
+ \ die_with_code(1); \n\
+ \} \n\n";
+ };
+
+ //
+ // Stack Manager
+ //
+
+ buf.append
+ "void push_first(_____CONTEXT *path,unsigned long code)\n\
- \{ int n; _____CONTEXT *c; static int mx=0;\n";
++ \{ \n";
+ (debug_level_option = 20).if {
+ buf.append
+ " _____CONTEXT *cur,loop;\n\
+ \ cur = top_context; \n\
+ \ while ((cur != (void *)0) && (cur != path)) cur = cur->back; \n\
+ \ if (cur == path) {\n\
+ \ loop.back = top_context;\n\
+ \ loop.code = code; \n\
+ \ stack_print(&loop);\n\
+ \ print_string(\"COMPILER : Debug context looping detected !\\n\");\n\
+ \ die_with_code(1);\n\
+ \ };\n";
+ };
+ buf.append
+ " path->back = top_context;\n\
+ \ path->code = code;\n\
+ \ top_context = path;\n\
- \ \n\
- \ /*c = path; n=0;\n\
- \ while (c != NULL) { n++; c = c->back; };\n\
- \ if ((n > mx) ) { print_integer(n); print_string(\"\\n\"); mx = n; };*/ \n\
+ \} \n\
+ \ \n\
+ \void push(_____CONTEXT *path,unsigned long code)\n\
+ \{ \n\
+ \ path->code = code;\n\
+ \ top_context = path;\n\
+ \} \n\
+ \ \n\
+ \void stack_print(_____CONTEXT *up) \n\
+ \{ _____CONTEXT *back,*next; \n\
+ \ int j; \n\
+ \ next = (void *)0; \n\
+ \ while (up != (void *)0) { \n\
+ \ back = up -> back; \n\
+ \ up -> back = next; \n\
+ \ next = up; \n\
+ \ up = back; \n\
+ \ }; \n\
+ \ print_string(\"\\n============== BOTTOM ==============\\n\"); \n\
+ \ while (next != (void *)0) { \n";
+ (debug_with_code).if {
+ buf.append
+ " print_string(\"Line #\"); \n\
+ \ print_integer(__src[next->code].pos >> 17); \n\
+ \ print_string(\" Column #\"); \n\
+ \ print_integer((__src[next->code].pos >> 9) & 0xFF); \n\
+ \ print_string(\" in \"); \n\
+ \ print_string(trace[__src[next->code].pos & 0x1FF]); \n\
+ \ print_string(\".\\n\"); \n\
+ \ if ((__src[next->code].pos & 0x1FF) != 0) { \n\
+ \ print_string(__src[next->code].line); \n\
+ \ print_char('\\n'); \n\
+ \ for (j=0;j < ((__src[next->code].pos >> 9) & 0xFF);j++) {\n\
+ \ if (__src[next->code].line[j]=='\\t') print_char('\\t');\n\
+ \ else print_char(' ');\n\
+ \ }; \n\
+ \ print_char('^'); \n\
+ \ print_char('\\n'); \n\
+ \ }; \n";
+
+ } else {
+ buf.append
+ " print_string(\"Line #\"); \n\
+ \ print_integer(next->code >> 17); \n\
+ \ print_string(\" Column #\"); \n\
+ \ print_integer((next->code >> 9) & 0xFF); \n\
+ \ print_string(\" in \"); \n\
+ \ print_string(trace[next->code & 0x1FF]); \n\
+ \ print_string(\".\\n\"); \n";
+ };
+ buf.append
+ " next = next -> back; \n\
+ \ }; \n\
+ \ print_string(\"================ TOP ===============\\n\"); \n\
+ \ top_context = (void *)0; \n\
+ \} \n\
+ \ \n\
+ \void print_integer(unsigned short n) \n\
+ \{ unsigned short val; \n\
+ \ char car; \n\
+ \ car = (n % 10) + '0'; \n\
+ \ val = n / 10; \n\
+ \ if (val != 0) print_integer(val); \n\
+ \ print_char(car); \n\
+ \} \n\n";
+
+ );
+
diff --combined src/tools/backend_java.li
index dda615e,ac4c7ea..8465ced
--- a/src/tools/backend_java.li
+++ b/src/tools/backend_java.li
@@@ -33,332 -33,5 +33,338 @@@ Section Inheri
Section Public
+ - source_extension :STRING_CONSTANT := ALIAS_STR.ext_java;
+ - generate_type_typedef_for t:TYPE in buf:STRING <-
+ (
+ BACKEND_C.generate_type_typedef_for t in buf;
+ );
+ - generate_type_struct_for_generic_in buf:STRING <-
+ (
+ buf.append
+ "// Generic Object\n\
+ \class ___OBJ {\n\
+ \ long __id;\n\
+ \};\n\n";
+ );
+
+ - generate_type_struct_for_null_in buf:STRING <-
+ (
+ );
+
+ - generate_type_struct_for_context_in buf:STRING <-
+ (
+ BACKEND_C.generate_type_struct_for_context_in buf;
+ );
+
+
+ - generate_type_struct_for t:TYPE in buf:STRING <-
+ ( + slot_data:SLOT_DATA;
+ + tab:FAST_ARRAY[SLOT_DATA];
+ + count_slot:SLOT_DATA;
+ + storage_slot:SLOT_DATA;
+ + num_slots :INTEGER;
+
+
+ //
+ // Type C
+ //
+
+ (t.type_c != NULL).if {
+ // Define TRUE__ and FALSE__ constants
+ // No need to do that for Java code
+
+ //
+ // Lisaac defined type
+ //
+
+ } 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
+ //
+ 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_globals_for t:TYPE in buf:STRING <-
+ (
+ (t.type_c = NULL).if {
+ buf.append "private static ";
+ append_type_name_for t in buf;
+ buf.add_last ' ';
+ 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 {
+ append_type_typeid_name_for t in buf;
+ };
+ buf.append ");\n";
+ };
+
+ );
+
+ - generate_type_reference_star_declaration_in buf:STRING <-
+ (
+ buf.append "[]";
+ );
+
+ - generate_type_expanded_declaration_for t:TYPE in buf:STRING <-
+ (
+ (t.type_c != NULL).if {
+ buf.append (t.type_c);
+ } else {
+ append_type_name_for t in buf;
+ };
+ );
+
+ - generate_type_generic_declaration_in buf:STRING <-
+ (
+ buf.append "__OBJ ";
+ );
+
+ - generate_type_access_id_for_expr e:EXPR in buf:STRING <-
+ (
+ e.genere buf;
+ buf.append ".__id";
+ );
+
+
+ - append_null_value_in buf:STRING <-
+ (
+ buf.append "null";
+ );
+
+ - generate_read_slot_for read:READ_SLOT in buf:STRING <-
+ (
+ read.receiver.genere buf;
++ //not_yet_implemented;
+ buf.add_last '.';
+ buf.append (read.variable.intern_name);
+ );
+
+ - generate_write_slot_for write:WRITE_SLOT in buf:STRING <-
+ (
+ // Receiver.
++ (quiet_generation).if {
++ buffer.append "/* WRTOK */";
++ } else {
++ buffer.append "/* WRTNO */";
++ };
+ write.receiver.genere buf;
+ buf.add_last '.';
+ //
+ buf.append (write.variable.intern_name);
+ //
+ ((write.value.static_type.raw = TYPE_NULL) &&
+ {write.variable.type.raw.is_block}).if
+ {
+ buf.append ".__id=0";
+ } else {
+ buf.add_last '=';
+ write.genere_value buf;
+ };
+ );
+
+
+
+ - append_cop_init_code_in buf:STRING <-
+ (
+ not_yet_implemented;
+ );
+
+ - append_init_code_in buf:STRING input_name input_name:STRING_CONSTANT <-
+ (
+ buf.append "// Java code generated by Lisaac compiler (www.isaacOS.com) //\n";
+ buf.append "class ";
+ buf.append input_name;
+ buf.append " {\n";
+ buf.append "private static String arg[];\n";
+ );
+
+ - append_debug_code_in buf:STRING <- ();
+
+ - append_main_function_in buf:STRING <-
+ (
+ buf.append "public static void main(String parg[])\n";
+ buf.append "{\n";
+ );
+
+ - append_main_init_code_in buf:STRING <-
+ (
+ buf.append "arg = parg";
+ );
+
+ - append_main_return_code_in buf:STRING <-
+ (
+ indent.remove_last 2;
+ buf.append indent;
+ buf.append "}\n\n";
+ );
+
+ - append_end_of_file_in buf:STRING <-
+ (
+ buf.append "\n} // End class MAIN\n";
+ );
+
+ - generate_table_type_in buf:STRING <- ();
+
+
+ - generate_debug_manager_in buf:STRING <-
+ (
+ buf.append
+ "private static void print_string(String str) \n\
+ \{ \n\
+ \ System.out.print(str);\n\
+ \}\n\
+ \\n";
+ );
+
+ - generate_trace_declarations_in buf:STRING <- not_yet_implemented;
+ - generate_trace_codedata_in buf:STRING declarations_in decl:STRING <- not_yet_implemented;
+ - generate_trace_code_in buf:STRING <- not_yet_implemented;
diff --combined src/type/prototype.li
index 3720a91,4c34b04..19e9c5d
--- a/src/type/prototype.li
+++ b/src/type/prototype.li
@@@ -34,19 -34,19 +34,19 @@@ Section Inheri
Section Public
- - prototype_list:FAST_ARRAY[PROTOTYPE] :=
- FAST_ARRAY[PROTOTYPE].create_with_capacity 512;
+ - prototype_list:FAST_ARRAY(PROTOTYPE) :=
+ FAST_ARRAY(PROTOTYPE).create_with_capacity 512;
// BSBS: Voir si il faut le conserver !
- - prototype_dico:HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT] :=
- HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT].create;
+ - prototype_dico:HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT) :=
+ HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT).create;
Section Public
+ index:INTEGER; // in `prototype_list', for POSITION.
- + itm_source :FAST_ARRAY[PRJ_ITEM] :=
- FAST_ARRAY[PRJ_ITEM].create_with_capacity 1;
+ + itm_source :FAST_ARRAY(PRJ_ITEM) :=
+ FAST_ARRAY(PRJ_ITEM).create_with_capacity 1;
+ shortname:STRING_CONSTANT;
@@@ -57,7 -57,7 +57,7 @@@
// Slots
//
- + slot_list:HASHED_DICTIONARY[ITM_SLOT,STRING_CONSTANT];
+ + slot_list:HASHED_DICTIONARY(ITM_SLOT,STRING_CONSTANT);
+ first_slot:ITM_SLOT;
@@@ -135,15 -135,15 +135,15 @@@
// Cast information.
//
- + export_list:FAST_ARRAY[ITM_TYPE_MONO];
- + import_list:FAST_ARRAY[ITM_TYPE_MONO];
+ + export_list:FAST_ARRAY(ITM_TYPE_MONO);
+ + import_list:FAST_ARRAY(ITM_TYPE_MONO);
- - set_export_list s:FAST_ARRAY[ITM_TYPE_MONO] <-
+ - set_export_list s:FAST_ARRAY(ITM_TYPE_MONO) <-
(
export_list := s;
);
- - set_import_list s:FAST_ARRAY[ITM_TYPE_MONO] <-
+ - set_import_list s:FAST_ARRAY(ITM_TYPE_MONO) <-
(
import_list := s;
);
@@@ -158,7 -158,7 +158,7 @@@
+ generic_count:INTEGER;
- + idf_generic_list:FAST_ARRAY[ITM_TYPE_PARAMETER];
+ + idf_generic_list:FAST_ARRAY(ITM_TYPE_PARAMETER);
//
// Default value.
@@@ -192,7 -192,7 +192,7 @@@
filename := f;
longname := n;
- itm_source := FAST_ARRAY[PRJ_ITEM].create_with_capacity 1;
+ itm_source := FAST_ARRAY(PRJ_ITEM).create_with_capacity 1;
itm_source.add_last s;
idx := n.fast_last_index_of '.';
(idx != 0).if {
@@@ -203,7 -203,7 +203,7 @@@
shortname := n;
};
generic_count := c;
- idf_generic_list := FAST_ARRAY[ITM_TYPE_PARAMETER].create_with_capacity c;
+ idf_generic_list := FAST_ARRAY(ITM_TYPE_PARAMETER).create_with_capacity c;
// Collection.
index := prototype_list.count;
@@@ -224,7 -224,7 +224,7 @@@
FS_MIN.close file;
// Init.
- slot_list := HASHED_DICTIONARY[ITM_SLOT,STRING_CONSTANT].create;
+ slot_list := HASHED_DICTIONARY(ITM_SLOT,STRING_CONSTANT).create;
position := POSITION.create Self line 1 column 0;
//
);
@@@ -256,10 -256,24 +256,10 @@@
};
// Command argument.
- (is_ansi).if {
- (is_java).if {
- cmd := "arg = parg";
- } else {
- string_tmp.clear;
- (debug_level_option != 0).if {
- string_tmp.copy "signal(SIGINT,interrupt_signal);\n ";
- };
- string_tmp.append
- "arg_count = argc;\n\
- \ arg_vector = argv;\n\
- \#ifdef _PTHREAD_H\n\
- \ pthread_key_create(¤t_thread, NULL);\n\
- \ pthread_attr_init(&thread_attr);\n\
- \ /*pthread_attr_setdetachstate(&thread_attr,PTHREAD_CREATE_DETACHED);*/\n\
- \#endif\n ";
- cmd := ALIAS_STR.get string_tmp;
- };
+ (is_ansi).if {
+ string_tmp.clear;
+ backend.append_main_init_code_in string_tmp;
+ cmd := ALIAS_STR.get string_tmp;
i := EXTERNAL_C.create position text cmd
access NULL persistant TRUE type (TYPE_VOID.default);
list_current.add_last i;
@@@ -447,10 -461,10 +447,10 @@@ Section PROTOTYP
{
((s.id_section.is_public) && {s.name = ALIAS_STR.slot_main}).if {
(s.result_type != ITM_TYPE_SIMPLE.type_void).if {
- semantic_error ((s.position),"Unix mode: Not value return.");
+ semantic_error (s.position,"Unix mode: Not value return.");
};
(s.argument_count != 1).if {
- semantic_error ((s.position),"Unix mode: Not argument list.");
+ semantic_error (s.position,"Unix mode: Not argument list.");
};
result := type_input.get_slot (s.name);
};
@@@ -463,7 -477,7 +463,7 @@@
result
);
- - shorter_get_all_slot_in lst:FAST_ARRAY[ITM_SLOT] <-
+ - shorter_get_all_slot_in lst:FAST_ARRAY(ITM_SLOT) <-
( + s:ITM_SLOT;
+ ps:ITM_TYPE_SIMPLE;
+ p:PROTOTYPE;
@@@ -507,7 -521,7 +507,7 @@@
};
);
- - shorter_table lst:FAST_ARRAY[ITM_SLOT] select sel:BLOCK
+ - shorter_table lst:FAST_ARRAY(ITM_SLOT) select sel:{ITM_SLOT; BOOLEAN}
title t:STRING_CONSTANT in buf:STRING <-
( + is_first_cur:BOOLEAN;
+ s:ITM_SLOT;
@@@ -558,7 -572,7 +558,7 @@@
};
);
- - shorter_detail lst:FAST_ARRAY[ITM_SLOT] select sel:BLOCK
+ - shorter_detail lst:FAST_ARRAY(ITM_SLOT) select sel:{ITM_SLOT; BOOLEAN}
title t:STRING_CONSTANT in buf:STRING <-
( + is_first:BOOLEAN;
+ s:ITM_SLOT;
@@@ -631,7 -645,7 +631,7 @@@
};
);
- - list_tmp:FAST_ARRAY[ITM_SLOT] := FAST_ARRAY[ITM_SLOT].create_with_capacity 256;
+ - list_tmp:FAST_ARRAY(ITM_SLOT) := FAST_ARRAY(ITM_SLOT).create_with_capacity 256;
- str_tmp:STRING := STRING.create 512;
- str_tmp2:STRING := STRING.create 64;
@@@ -642,7 -656,7 +642,7 @@@
+ stat,old_stat:INTEGER;
+ car:CHARACTER;
+ i:INTEGER;
- + lst:LINKED_LIST[STRING_CONSTANT];
+ + lst:LINKED_LIST(STRING_CONSTANT);
+ code_balise:STRING_CONSTANT;
cur := str.lower;
diff --combined src/type/type.li
index 1c4e13c,e45fa02..0d28185
--- a/src/type/type.li
+++ b/src/type/type.li
@@@ -36,10 -36,14 +36,14 @@@ Section Inheri
- parent_parameter_to_type:Expanded PARAMETER_TO_TYPE;
- Section TYPE
+ Section PROFIL_LIST
+
+ - is_alias_struct:BOOLEAN := TRUE;
- - dico_type:HASHED_DICTIONARY[TYPE,STRING_CONSTANT] :=
- HASHED_DICTIONARY[TYPE,STRING_CONSTANT].create;
+ Section Private
+
+ - dico_type:HASHED_DICTIONARY(TYPE,STRING_CONSTANT) :=
+ HASHED_DICTIONARY(TYPE,STRING_CONSTANT).create;
- index_count:INTEGER;
@@@ -52,7 -56,7 +56,7 @@@ Section Publi
param_count := param_count.max n;
);
- + subtype_list:HASHED_SET[TYPE];
+ + subtype_list:HASHED_SET(TYPE);
+ default:TYPE_FULL;
@@@ -88,7 -92,7 +92,7 @@@
- type_c:STRING_CONSTANT <- prototype.type_c;
- + slot_run:FAST_ARRAY[SLOT];
+ + slot_run:FAST_ARRAY(SLOT);
+ index:INTEGER;
@@@ -111,17 -115,19 +115,19 @@@
+ base:TYPE;
+ styl:STRING_CONSTANT;
+ proto:PROTOTYPE;
-
- proto := load_prototype itm_typ generic_count 0;
+
+ + r:TYPE;
+
+ proto := load_prototype itm_typ generic_count 0;
base := dico_type.fast_reference_at (proto.filename);
- (base = NULL).if {
+ (base = NULL).if {
base := TYPE.clone;
dico_type.fast_put base to (proto.filename);
- base.make itm_typ with proto;
+ base.make itm_typ with proto;
};
- //
+ //
styl := itm_typ.style;
- (styl = NULL).if {
+ (styl = NULL).if {
result := base.default;
} else {
(styl = ALIAS_STR.keyword_expanded).if {
@@@ -130,6 -136,8 +136,8 @@@
result := base.default + TYPE_FULL.strict_bit;
};
};
+
+ r := result.the_parent_type;
result
);
@@@ -151,8 -159,17 +159,17 @@@
{slot_run.item j.id_section.is_inherit_or_insert} &&
{result = NULL}
}.while_do {
- ts ?= slot_run.item j.result_type;
- typ := ts.to_run_for Self.raw;
+ ts ?= slot_run.item j.result_type;
+ typ := ts.to_run_for Self.raw;
+
+ /*
+ (typ.prototype = NULL).if {
+
+ typ.print; '\n'.print;
- `/* ICI BEN FIN */`;
++ `// ICI BEN FIN `;
+ crash_with_message "TYPE: BUG Compiler : search_require";
+ };
+ */
result := typ.prototype.slot_list.fast_reference_at n;
((result = NULL) || {result.require = NULL}).if {
result := typ.search_require n;
@@@ -291,7 -308,7 +308,7 @@@
Section Private
- - is_cast t:TYPE_FULL with msg:STRING_CONSTANT on lst:FAST_ARRAY[ITM_TYPE_MONO] :BOOLEAN <-
+ - is_cast t:TYPE_FULL with msg:STRING_CONSTANT on lst:FAST_ARRAY(ITM_TYPE_MONO) :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
@@@ -315,7 -332,7 +332,7 @@@ Section Publi
// Genere.
//
- - genere_list:FAST_ARRAY[TYPE] := FAST_ARRAY[TYPE].create_with_capacity 128;
+ - genere_list:FAST_ARRAY(TYPE) := FAST_ARRAY(TYPE).create_with_capacity 128;
- add_genere_list <-
(
@@@ -344,46 -361,89 +361,106 @@@
- id_counter_with_type:INTEGER := 4;
- id_counter_without_type:INTEGER := 0;
+
+ - generate_id_with_type :INTEGER <-
+ ( + res :INTEGER;
+ res := id_counter_with_type;
+ id_counter_with_type := id_counter_with_type + 1;
+ res
+ );
+
+ - generate_id_without_type :INTEGER <-
+ ( + res :INTEGER;
+ res := id_counter_without_type;
+ id_counter_without_type := id_counter_without_type + 1;
+ res
+ );
- - slot_size:FAST_ARRAY[FAST_ARRAY[SLOT_DATA]] :=
- ( + result:FAST_ARRAY[FAST_ARRAY[SLOT_DATA]];
+ - slot_size:FAST_ARRAY(FAST_ARRAY(SLOT_DATA)) :=
+ ( + result:FAST_ARRAY(FAST_ARRAY(SLOT_DATA));
- result := FAST_ARRAY[FAST_ARRAY[SLOT_DATA]].create_with_capacity 5;
+ result := FAST_ARRAY(FAST_ARRAY(SLOT_DATA)).create_with_capacity 5;
0.to 4 do { j:INTEGER;
- result.add_last (FAST_ARRAY[SLOT_DATA].create_with_capacity 8);
+ result.add_last (FAST_ARRAY(SLOT_DATA).create_with_capacity 8);
};
result
);
+ detect_recursivity_generation:BOOLEAN;
+ //
+ // Detect Alias.
+ //
+
+ + alias_slot:SLOT_DATA;
+
+ - alias_type:TYPE <- alias_slot.type.raw;
+
+ - detect_alias <-
+ (
+ (dico_type.lower).to (dico_type.upper) do { j:INTEGER;
+ dico_type.item j.detect_alias_struct;
+ };
+ );
+
+ - detect_alias_struct <-
+ [
+ -? {is_alias_struct};
+ ]
+ ( + slot:SLOT;
+ + i,nb:INTEGER;
+ + action:{SLOT_DATA; };
+
+ ((alias_slot = NULL) && {slot_run != NULL}).if {
+
+ action := { s:SLOT_DATA;
+ ((s.ensure_count > 0) || {s.id_section.is_mapping}).if {
+ (nb = 0).if {
+ ((s.type.is_expanded) && {s.type.raw.type_c = NULL}).if {
+ alias_slot := s;
+ };
+ } else {
+ alias_slot := NULL;
+ };
+ nb := nb + 1;
+ };
+ };
+
+ i := slot_run.lower;
+ {(i <= slot_run.upper) && {nb < 2}}.while_do {
+ slot := slot_run.item i;
+ ((slot.style = '+') && {slot.lower_style = 0}).if {
+ (slot.slot_data_list != NULL).if {
+ (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+ action.value (slot.slot_data_list.item k);
+ };
+ };
+ action.value (slot.slot_data);
+ };
+ i := i + 1;
+ };
+ };
+ (
+ (alias_slot != NULL) &&
+ {! (is_late_binding -> alias_slot.type.raw.is_late_binding)}
+ ).if {
+ alias_slot := NULL;
+ };
+ );
+
- genere_struct <-
( + slot_data:SLOT_DATA;
+ slot:SLOT;
- + tab:FAST_ARRAY[SLOT_DATA];
- + action:BLOCK;
+ + tab:FAST_ARRAY(SLOT_DATA);
+ + action:{SLOT_DATA; };
+ tg:TYPE_GENERIC;
- + count_slot:SLOT_DATA;
- + storage_slot:SLOT_DATA;
-
- ((slot_run.is_empty) || {slot_run.first != NULL}).if {
+
+ ((slot_run.is_empty) || {slot_run.first != NULL}).if {
+
+ //
+ // Detect recursivity
+ //
+
(detect_recursivity_generation).if {
string_tmp.copy "Compiler limit: Cyclic depending structure definition for ";
append_name_in string_tmp;
@@@ -391,159 -451,308 +468,194 @@@
semantic_error (position,string_tmp);
};
detect_recursivity_generation := TRUE;
-
- // Depending.
+
+ //
+ // Depending (generate structs we require)
+ //
+
(slot_run.lower).to (slot_run.upper) do { j:INTEGER;
- slot := slot_run.item j;
- ((slot.style = '+') && {slot.lower_style = 0}).if {
+ slot := slot_run.item j;
+ ((slot.style = '+') && {slot.lower_style = 0}).if {
action := { s:SLOT_DATA;
- (
- (
- (s.ensure_count > 0) ||
- {s.id_section.is_mapping}
- ) &&
- {s.type.raw != Self} &&
- {(s.type.is_expanded) || {s.type.raw.is_block}}
- ).if {
- s.type.raw.genere_struct;
+ (
+ (
+ (s.ensure_count > 0) ||
+ {s.id_section.is_mapping}
+ ) &&
+ {s.type.raw != Self} &&
+ {(s.type.is_expanded) || {s.type.raw.is_block}}
+ ).if {
+ s.type.raw.genere_struct;
};
- };
- (slot.slot_data_list != NULL).if {
- (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
- action.value (slot.slot_data_list.item k);
- };
- };
- action.value (slot.slot_data);
- };
- };
- // Sort slot.
- (slot_run.lower).to (slot_run.upper) do { j:INTEGER;
- slot := slot_run.item j;
- (slot.style = '+').if {
- // In struct.
- (slot.lower_style = 0).if {
- action := { s:SLOT_DATA;
- (
- (s.id_section.is_mapping) ||
- {s.ensure_count > 0}
- ).if {
- add_slot_struct s;
- };
- };
- (slot.slot_data_list != NULL).if {
- (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
- action.value (slot.slot_data_list.item k);
- };
- };
- action.value (slot.slot_data);
- };
- slot_data := slot.slot_id;
- ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
- add_slot_struct slot_data;
- };
- } else {
- // In global.
- (slot.lower_style = 0).if {
- action := { s:SLOT_DATA;
- (s.ensure_count > 0).if {
- s.genere output_glob;
- };
- };
- (slot.slot_data_list != NULL).if {
- (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
- action.value (slot.slot_data_list.item k);
- };
- };
- action.value (slot.slot_data);
- };
- slot_data := slot.slot_id;
- ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
- slot_data.slot_id.genere output_glob;
- };
- };
- };
-
- (
- (prototype.shortname = ALIAS_STR.prototype_native_array) ||
- {prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
- ).if {
- tg ?= Self;
- tg.generic_list.first.raw.genere_struct;
- } else {
- (type_c != NULL).if {
- 0.to 4 do { j:INTEGER;
- tab := slot_size.item j;
- // BSBS: A tester sont utilit� !
- (! tab.is_empty).if {
- semantic_error (tab.first.position,"Slot is not possible with a type C");
- };
- };
- (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";
+ (slot.slot_data_list != NULL).if {
+ (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+ action.value (slot.slot_data_list.item k);
};
- (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";
+ action.value (slot.slot_data);
+ };
+ };
+
+ //
+ // Sort slot. (whatever that might mean)
+ //
+
+ (slot_run.lower).to (slot_run.upper) do { j:INTEGER;
+ slot := slot_run.item j;
+ (slot.style = '+').if {
+ // In struct.
+ (slot.lower_style = 0).if {
+ action := { s:SLOT_DATA;
+ (
+ (s.id_section.is_mapping) ||
+ {s.ensure_count > 0}
+ ).if {
+ add_slot_struct s;
};
};
+ (slot.slot_data_list != NULL).if {
+ (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+ action.value (slot.slot_data_list.item k);
+ };
+ };
+ action.value (slot.slot_data);
};
- 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;
+ slot_data := slot.slot_id;
+ ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
+ add_slot_struct slot_data;
+ };
+ } else {
+ // In global.
+ // Mildred: is that useful to iterate? The action seems empty
+ (slot.lower_style = 0).if {
+ action := { s:SLOT_DATA;
+ (s.ensure_count > 0).if {
+ };
++|||||||
++ output_decl.append ")\n {\n ";
+ (is_late_binding).if {
- output_decl.append " extends __OBJ";
++ output_decl.append "__id = pid;\n";
++ } else {
++ output_decl.append "super();\n";
+ };
- output_decl.append " {\n";
++ output_decl.append " };\n};\n";
++ } else {
++ output_decl.append "struct ";
++ output_decl.append intern_name;
++ output_decl.append "_struct {\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 "} __attribute__ ((packed));\n";
++ } else {
++ output_decl.append "};\n";
++=======
+ 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";
++>>>>>>> mildred-projects:src/type/type.li
};
- };
- // 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 "__";
+ (slot.slot_data_list != NULL).if {
+ (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+ action.value (slot.slot_data_list.item k);
+ };
};
- 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 "__}";
+ action.value (slot.slot_data);
+ };
+ slot_data := slot.slot_id;
+ ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
+ };
+ };
+ };
+
+ //
+ // For NATIVE_ARRAY, only generate the generic type, don't bother
+ // to generate the struct for the NATIVE_ARRAY itself
+ //
+
+ ( // TODO: Mildred: don't use prototype name for detection
+ // Possibly, try to find a way to extend that to any prototype
+ (prototype.shortname = ALIAS_STR.prototype_native_array) ||
+ {prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
+ ).if {
+ tg ?= Self;
+ tg.generic_list.first.raw.genere_struct;
+ } else {
+
+ //
+ // Detect errors
+ //
+
+ (type_c != NULL).if {
+ // Forbid data slots when C type is specified
+ 0.to 4 do { j:INTEGER;
+ tab := slot_size.item j;
+ // BSBS: A tester sont utilit� !
+ (! tab.is_empty).if {
+ semantic_error ((tab.first.position),"Slot is not possible with a type C");
};
- 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";
};
- };
+ // Raise an error for C types that have a late binding
+ (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),
+ "Late binding is not possible with `mapping' object.");
+ };
+ };
+
+ //
+ // Generate code
+ //
+
+ backend.generate_type_struct_for Self in output_decl;
+ backend.generate_type_globals_for Self in output_glob;
+
};
-
- // Flag on:
+
+ // Flag on (don't generate twice the code)
slot_run.force NULL to 0;
- };
+ };
+
);
- genere_typedef <-
- ( + tg:TYPE_GENERIC;
- + t:TYPE;
- (
+ ( + tg:TYPE_GENERIC;
+
+ //
+ // For NATIVE_ARRAY, only generate the generic type typedef, don't bother
+ // to generate the typedef for the NATIVE_ARRAY itself
+ //
+
+ ( // TODO: Mildred: don't use prototype name for detection
+ // Possibly, try to find a way to extend that to any prototype
(prototype.shortname = ALIAS_STR.prototype_native_array) ||
{prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
).if {
tg ?= Self;
tg.generic_list.first.raw.genere_typedef;
- } else {
- output_decl.append "typedef ";
- (type_c != NULL).if {
- output_decl.append type_c;
- } else {
- t := Self;
- {t.alias_slot = NULL}.until_do {
- t := t.alias_type;
- };
- output_decl.append "struct ";
- output_decl.append (t.intern_name);
- output_decl.append "_struct";
- };
- output_decl.append " __";
- output_decl.append intern_name;
- output_decl.add_last ';';
- ((type_c = NULL) && {alias_slot != NULL}).if {
- output_decl.append " // ALIAS with ";
- output_decl.append (alias_type.intern_name);
- };
- output_decl.add_last '\n';
- };
+ } else {
+ backend.generate_type_typedef_for Self in output_decl;
+ };
);
Section Private
@@@ -572,21 -781,31 +684,21 @@@ Section Publi
//
- put_reference_declaration buffer:STRING <-
- (
- buffer.append "__";
- buffer.append intern_name;
+ (
+ backend.append_type_name_for Self in buffer;
add_genere_list;
);
- put_reference_star_declaration buffer:STRING <-
(
(is_block).if_false { // BSBS: A mettre dans TYPE_BLOCK
- (is_java).if {
- buffer.append "[]";
- } else {
- buffer.add_last '*';
- };
+ backend.generate_type_reference_star_declaration_in buffer;
};
);
- put_expanded_declaration buffer:STRING <-
- (
- ((is_java) && {type_c != NULL}).if {
- buffer.append type_c;
- } else {
- buffer.append "__";
- buffer.append intern_name;
- };
+ (
+ backend.generate_type_expanded_declaration_for Self in buffer;
add_genere_list;
);
@@@ -595,7 -814,11 +707,7 @@@
(is_block).if { // BSBS: A mettre dans TYPE_BLOCK
put_expanded_declaration buffer;
} else {
- (is_java).if {
- buffer.append "__OBJ ";
- } else {
- buffer.append (ALIAS_STR.c_void);
- };
+ backend.generate_type_generic_declaration_in buffer;
};
);
@@@ -605,7 -828,9 +717,7 @@@
- put_id buffer:STRING <-
(
- buffer.append (ALIAS_STR.separate); // <=> "__"
- buffer.append intern_name;
- buffer.append (ALIAS_STR.separate);
+ backend.append_type_typeid_name_for Self in buffer;
);
- put_access_id e:EXPR in buffer:STRING <-
@@@ -614,18 -839,26 +726,18 @@@
t := e.static_type.raw;
(t = type_boolean).if {
- e.genere buffer;
- }.elseif {t = type_block} then {
+ // TODO: Mildred: find a way to have expanded inheritance
e.genere buffer;
- //buffer.append ".__id";
+ }.elseif {t = type_block} then {
+ backend.generate_type_access_id_for_block e in buffer;
} else {
- (is_java).if {
- e.genere buffer;
- buffer.append ".__id";
- } else {
- buffer.append "((struct ___OBJ *)";
- e.genere buffer;
- buffer.append ")->__id";
- };
+ backend.generate_type_access_id_for_expr e in buffer;
};
);
- put_value buffer:STRING <-
(
- buffer.append intern_name;
- buffer.append (ALIAS_STR.separate);
+ backend.append_type_proto_name_for Self in buffer;
add_genere_list;
);
@@@ -649,7 -882,7 +761,7 @@@ Section Publi
- is_block:BOOLEAN := FALSE;
- - '==' Right 60 other:TYPE :BOOLEAN <- (Self = other);
+ - Self:SELF '==' Right 60 other:TYPE :BOOLEAN <- (Self = other);
- is_sub_type other:TYPE :BOOLEAN <-
( + result:BOOLEAN;
@@@ -727,7 -960,7 +839,7 @@@ Section TYP
string_tmp.replace_all '.' with '_';
intern_name := ALIAS_STR.get_intern string_tmp;
itm_type := itm_typ;
- slot_run := FAST_ARRAY[SLOT].create_with_capacity 10; // BSBS: A voir.
+ slot_run := FAST_ARRAY(SLOT).create_with_capacity 10; // BSBS: A voir.
(prototype.type_style = ALIAS_STR.keyword_expanded).if {
// Expanded.
mask_bit := TYPE_FULL.expanded_bit | TYPE_FULL.default_expanded_bit;
@@@ -738,7 -971,7 +850,7 @@@
default := TYPE_FULL.create Self with mask_bit;
prototype.init_slot_for Self;
//
- subtype_list := HASHED_SET[TYPE].create;
+ subtype_list := HASHED_SET(TYPE).create;
subtype_list.fast_add TYPE_NULL;
add_subtype Self;
// Size.
@@@ -768,12 -1001,14 +880,14 @@@
};
);
- /*- dico_name_to_prototype:HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT] :=
- HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT].create;*/
+ /*
+ - dico_name_to_prototype:HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT) :=
+ HASHED_DICTIONARY(PROTOTYPE,STRING_CONSTANT).create;
+ */
Section TYPE, TYPE_FULL
- + type_full_list:FAST_ARRAY[TYPE_FULL];
+ + type_full_list:FAST_ARRAY(TYPE_FULL);
- get_with flg:UINTEGER_8 :TYPE_FULL <-
( + result:TYPE_FULL;
@@@ -783,7 -1018,7 +897,7 @@@
result := default;
} else {
(type_full_list = NULL).if {
- type_full_list := FAST_ARRAY[TYPE_FULL].create_with_capacity 2;
+ type_full_list := FAST_ARRAY(TYPE_FULL).create_with_capacity 2;
result := TYPE_FULL.create Self with flg;
type_full_list.add_last result;
} else {
diff --combined src/type/type_context.li
index 4e4f2d2,5547ba9..2a8d371
--- a/src/type/type_context.li
+++ b/src/type/type_context.li
@@@ -47,7 -47,7 +47,7 @@@ Section Publi
- make_context <-
(
dico_type.fast_put Self to name;
- //slot_run := FAST_ARRAY[SLOT].create_with_capacity 1; // BSBS: Plus utile !
+ //slot_run := FAST_ARRAY(SLOT).create_with_capacity 1; // BSBS: Plus utile !
default := TYPE_FULL.create Self with (TYPE_FULL.expanded_bit);
);
@@@ -58,6 -58,13 +58,6 @@@
- genere_struct <-
(
- output_decl.append
- "// ___CONTEXT\n\
- \typedef struct ___CONTEXT_struct _____CONTEXT; \n\
- \struct ___CONTEXT_struct {\n\
- \ unsigned long code; \n\
- \ _____CONTEXT *back; \n\
- \};\n\
- \_____CONTEXT *top_context; \n\n";
+ backend.generate_type_struct_for_context_in output_decl;
);
diff --combined src/type/type_generic.li
index 632bcc9,b080adc..d3d13f1
--- a/src/type/type_generic.li
+++ b/src/type/type_generic.li
@@@ -37,8 -37,8 +37,8 @@@ Section Privat
// BSBS: Vu que les ITM_TYPE sont aliaser, il n'est pas necessary d'aliaser les TYPE !
// Mais attention au pb des TYPE_GENERIC et de leur alias de slot_run...
- - dicog_type:HASHED_DICTIONARY[TYPE_GENERIC,STRING_CONSTANT] :=
- HASHED_DICTIONARY[TYPE_GENERIC,STRING_CONSTANT].create;
+ - dicog_type:HASHED_DICTIONARY(TYPE_GENERIC,STRING_CONSTANT) :=
+ HASHED_DICTIONARY(TYPE_GENERIC,STRING_CONSTANT).create;
Section Public
@@@ -46,11 -46,11 +46,11 @@@
+ key:STRING_CONSTANT;
- + generic_list:FAST_ARRAY[TYPE_FULL];
+ + generic_list:FAST_ARRAY(TYPE_FULL);
- parameter_to_type p:ITM_TYPE_PARAMETER :TYPE_FULL <-
( + idx:INTEGER;
- + tab:FAST_ARRAY[ITM_TYPE_PARAMETER];
+ + tab:FAST_ARRAY(ITM_TYPE_PARAMETER);
+ result:TYPE_FULL;
tab := prototype.idf_generic_list;
@@@ -60,7 -60,19 +60,19 @@@
};
result
);
+
+ //
+ // Detect Alias.
+ //
+
+ - detect_alias <-
+ (
+ (dicog_type.lower).to (dicog_type.upper) do { j:INTEGER;
+ dicog_type.item j.detect_alias_struct;
+ };
+ );
+
//
// Import / Export
//
@@@ -77,12 -89,12 +89,12 @@@
Section Private
- + export_list:FAST_ARRAY[TYPE_FULL];
- + import_list:FAST_ARRAY[TYPE_FULL];
+ + export_list:FAST_ARRAY(TYPE_FULL);
+ + import_list:FAST_ARRAY(TYPE_FULL);
- is_cast t:TYPE_FULL with msg:STRING_CONSTANT
- on lst:FAST_ARRAY[TYPE_FULL]
- and lstp:FAST_ARRAY[ITM_TYPE_MONO] :BOOLEAN <-
+ on lst:FAST_ARRAY(TYPE_FULL)
+ and lstp:FAST_ARRAY(ITM_TYPE_MONO) :BOOLEAN <-
( + result:BOOLEAN;
+ j:INTEGER;
@@@ -109,7 -121,7 +121,7 @@@ Section Publi
NULL
);
- - get itm_typ:ITM_TYPE_SIMPLE with gen:FAST_ARRAY[TYPE_FULL] :TYPE_FULL <-
+ - get itm_typ:ITM_TYPE_SIMPLE with gen:FAST_ARRAY(TYPE_FULL) :TYPE_FULL <-
( + base:TYPE_GENERIC;
+ result,t:TYPE_FULL;
+ styl,k:STRING_CONSTANT;
@@@ -152,12 -164,12 +164,12 @@@
// il faudrai plutot stocker ca ailleurs... ou? ch�pa!
//
- + put_to_list:FAST_ARRAY[PUT_TO];
+ + put_to_list:FAST_ARRAY(PUT_TO);
- add_put_to n:PUT_TO <-
(
(put_to_list = NULL).if {
- put_to_list := FAST_ARRAY[PUT_TO].create_with_capacity 16;
+ put_to_list := FAST_ARRAY(PUT_TO).create_with_capacity 16;
};
put_to_list.add_last n;
);
@@@ -218,8 -230,12 +230,8 @@@
(
(prototype.shortname = ALIAS_STR.prototype_native_array) ||
{prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
- ).if {
- (is_java).if {
- buffer.append "[]";
- } else {
- buffer.add_last '*';
- };
+ ).if {
+ backend.generate_type_reference_star_declaration_in buffer;
generic_list.first.genere_star_declaration buffer;
} else {
parent_type.put_reference_star_declaration buffer;
@@@ -234,34 -250,34 +246,34 @@@ Section Publi
);
- make itm_typ:ITM_TYPE_SIMPLE with proto:PROTOTYPE
- generic gen:FAST_ARRAY[TYPE_FULL] key k:STRING_CONSTANT <-
+ generic gen:FAST_ARRAY(TYPE_FULL) key k:STRING_CONSTANT <-
( + mask_bit:UINTEGER_8;
index := index_count;
index_count := index_count + 1;
//
string_tmp.copy (itm_typ.name);
- string_tmp.add_last '[';
+ string_tmp.add_last '(';
(gen.lower).to (gen.upper - 1) do { j:INTEGER;
gen.item j.append_name_in string_tmp;
string_tmp.add_last ',';
};
gen.last.append_name_in string_tmp;
- string_tmp.add_last ']';
+ string_tmp.add_last ')';
name := ALIAS_STR.get string_tmp;
key := k;
generic_list := gen;
string_tmp.copy name;
string_tmp.replace_all ',' with 'x';
- string_tmp.replace_all '[' with 'o';
- string_tmp.replace_all ']' with 'o';
+ string_tmp.replace_all '(' with 'o';
+ string_tmp.replace_all ')' with 'o';
string_tmp.replace_all ' ' with '_';
string_tmp.replace_all '.' with '_';
intern_name := ALIAS_STR.get_intern string_tmp;
//
prototype := proto;
itm_type := itm_typ;
- slot_run := FAST_ARRAY[SLOT].create_with_capacity 10; // BSBS: A voir.
+ slot_run := FAST_ARRAY(SLOT).create_with_capacity 10; // BSBS: A voir.
(prototype.type_style = ALIAS_STR.keyword_expanded).if {
// Expanded.
mask_bit := TYPE_FULL.expanded_bit | TYPE_FULL.default_expanded_bit;
@@@ -272,20 -288,20 +284,20 @@@
default := TYPE_FULL.create Self with mask_bit;
prototype.init_slot_for Self;
//
- subtype_list := HASHED_SET[TYPE].create;
+ subtype_list := HASHED_SET(TYPE).create;
subtype_list.fast_add TYPE_NULL;
add_subtype Self;
// BSBS: Size ???
// Import / Export.
(prototype.export_list != NULL).if {
- export_list := FAST_ARRAY[TYPE_FULL].create_with_capacity (prototype.export_list.count);
+ export_list := FAST_ARRAY(TYPE_FULL).create_with_capacity (prototype.export_list.count);
(prototype.export_list.lower).to (prototype.export_list.upper) do { j:INTEGER;
export_list.add_last (prototype.export_list.item j.to_run_for Self);
};
};
(prototype.import_list != NULL).if {
- import_list := FAST_ARRAY[TYPE_FULL].create_with_capacity (prototype.import_list.count);
+ import_list := FAST_ARRAY(TYPE_FULL).create_with_capacity (prototype.import_list.count);
(prototype.import_list.lower).to (prototype.import_list.upper) do { j:INTEGER;
import_list.add_last (prototype.import_list.item j.to_run_for Self);
};
diff --combined src/type/type_null.li
index 1d65180,482e86c..65368cf
--- a/src/type/type_null.li
+++ b/src/type/type_null.li
@@@ -47,7 -47,7 +47,7 @@@ Section Publi
index := index_count;
index_count := index_count + 1;
dico_type.fast_put Self to name;
- slot_run := FAST_ARRAY[SLOT].create_with_capacity 1; // BSBS: Plus utile !
+ slot_run := FAST_ARRAY(SLOT).create_with_capacity 1; // BSBS: Plus utile !
default := TYPE_FULL.create Self with 0;
);
@@@ -61,15 -61,9 +61,9 @@@
//- bug:INTEGER;
- - product_error p:POSITION in lst:LIST <-
- ( + ctext:LOCAL;
-
+ - product_error p:POSITION in lst:LIST with ctext:LOCAL <-
+ (
(debug_level_option != 0).if {
- (profil_current = NULL).if {
- ctext := context_main;
- } else {
- ctext := profil_current.context;
- };
lst.add_last (
PUSH.create p context ctext first FALSE
);
@@@ -99,7 -93,13 +93,7 @@@ Section Publi
- genere_struct <-
(
- (is_java).if_false {
- output_decl.append
- "// NULL\n\
- \#ifndef NULL\n\
- \#define NULL ((void *)0)\n\
- \#endif\n\n";
- };
+ backend.generate_type_struct_for_null_in output_decl;
);
//
@@@ -114,7 -114,11 +108,7 @@@
- put_access_id e:EXPR in buffer:STRING <- e.genere buffer;
- put_value buffer:STRING <-
- (
- (is_java).if {
- buffer.append "null";
- } else {
- buffer.append name;
- };
+ (
+ backend.append_null_value_in buffer;
);
--
Lisaac compiler
More information about the Lisaac-commits
mailing list