[SCM] Lisaac compiler branch, mildred-coverage-rebase, updated. lisaac-0.12-637-ge054115
Mildred Ki'Lya
silkensedai at online.fr
Fri Jul 30 09:15:29 UTC 2010
The following commit has been merged in the mildred-coverage-rebase branch:
commit 37e9ac93363e0954fed41b0c5fa237c99e305f8b
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Sat Mar 6 19:34:14 2010 +0100
Added -coverage switch that output coverage information when file execute
diff --git a/make.lip.sample b/make.lip.sample
index 53a4a9b..d666732 100644
--- a/make.lip.sample
+++ b/make.lip.sample
@@ -44,7 +44,8 @@ Section Private
// Generate code.
+ is_cop:BOOLEAN; // Correct value after compilation.
- + is_library:BOOLEAN; // For build a lisaac library C
+ + is_library:BOOLEAN; // For build a lisaac library C
+ + is_coverage:BOOLEAN;// Generate coverage information
+ execute_back_end:BOOLEAN := TRUE;
+ execute_status_code:INTEGER := 0;
@@ -338,12 +339,18 @@ Section Public
(
is_quiet := TRUE;
);
-
+
- build_library <-
- // For to build library (`main' => `init')
+ // For to build library (`main' => `init')
(
is_library := TRUE;
);
+
+ - coverage <-
+ // Build coverage information
+ (
+ is_coverage := TRUE;
+ );
//
// Information.
diff --git a/src/any.li b/src/any.li
index 4db5a7c..fe5f2f2 100644
--- a/src/any.li
+++ b/src/any.li
@@ -136,6 +136,7 @@ Section Public
- is_readable:BOOLEAN;
- is_graph:BOOLEAN;
+ - is_coverage:BOOLEAN;
//
// Other flags.
diff --git a/src/item/itm_list.li b/src/item/itm_list.li
index 6302b18..e5d1035 100644
--- a/src/item/itm_list.li
+++ b/src/item/itm_list.li
@@ -34,7 +34,7 @@ Section Inherit
Section Public
- // BSBS: OPTIM : Dans 95% des cas, les list sont sans local (il faudrait spécialiser)
+ // BSBS: OPTIM : Dans 95% des cas, les list sont sans local (il faudrait sp�cialiser)
// Mais pb avec le parser...
//
@@ -111,6 +111,27 @@ Section Public
result
);
+ - insert_code_coverage_hook last_position:POSITION in lst:FAST_ARRAY(ITM_CODE) <-
+ [
+ -? { lst != NULL };
+ ]
+ (
+ is_coverage.if {
+ //warning_error2 (position, last_position, "ITM_LIST.insert_code_coverage_hook");
+ string_tmp.copy "lisaac_coverage_hook(";
+ position.code.append_in string_tmp;
+ string_tmp.append ",";
+ last_position.code.append_in string_tmp;
+ string_tmp.append ")";
+ lst.add_first ( // TODO: Mildred: optimize (ALIAS_ARRAY)
+ ITM_EXTERNAL.create position text (ALIAS_STR.get string_tmp)
+ );
+ };
+ );
+
+ - insert_code_coverage_hook last_position:POSITION <-
+ insert_code_coverage_hook last_position in code;
+
//
// Runnable.
//
diff --git a/src/lisaac.li b/src/lisaac.li
index 47c8374..0b13110 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -257,6 +257,7 @@ Section Private
is_statistic := LIP_CODE.get_boolean (ALIAS_STR.slot_is_statistic);
is_quiet := LIP_CODE.get_boolean (ALIAS_STR.slot_is_quiet);
is_library := LIP_CODE.get_boolean (ALIAS_STR.slot_is_library);
+ is_coverage := LIP_CODE.get_boolean (ALIAS_STR.slot_is_coverage);
//
((input_name = NULL) || {input_name.is_empty}).if {
"ERROR: `input_file' is empty.\n".print;
@@ -489,6 +490,32 @@ Section Private
\ print_char(car); \n\
\} \n\n";
};
+ is_coverage.if {
+ buf.append "char *__Lisaac_proto_file_names[";
+ 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.filename);
+ buf.append "\",\n";
+ };
+ proto := PROTOTYPE.prototype_list.last;
+ buf.append " \"";
+ buf.append (proto.filename);
+ buf.append "\"\n};\n\n";
+ title "CODE COVERAGE HOOKS" in buf;
+ buf.append
+ "static void lisaac_coverage_hook(unsigned long start, unsigned long stop)\n\
+ \{\n\
+ \ fprintf (lisaac_coverage_file, \"%d:%d:%d:%d:%s\\n\",\n\
+ \ start >> 17, (start >> 9) & 0xFF,\n\
+ \ stop >> 17, (stop >> 9) & 0xFF,\n\
+ \ __Lisaac_proto_file_names[start & 0x1FF]);\n\
+ \}\n\
+ \\n";
+ };
);
- load_main_object <-
@@ -630,6 +657,9 @@ Section Public
(debug_level_option != 0).if {
output_decl.append "#include <signal.h>\n";
};
+ is_coverage.if {
+ output_decl.append "#include <stdio.h>\n";
+ };
output_decl.append
"int arg_count;\n\
\char **arg_vector;\n";
@@ -682,6 +712,15 @@ Section Public
};
};
+ // Coverage
+ is_coverage.if {
+ output_code.append "\
+ \\n/* Code Coverage Hooks */\n\
+ \static FILE* lisaac_coverage_file = NULL;\n\
+ \static void lisaac_coverage_hook(unsigned long start, unsigned long stop);\n\
+ \\n";
+ };
+
// Extern source code.
output_code.append "/* Source code */\n";
PROFIL_LIST.genere_handler output_code;
@@ -699,11 +738,20 @@ Section Public
};
};
output_code.append "{\n";
+ is_coverage.if {
+ output_code.append "lisaac_coverage_file = fopen(\"";
+ output_code.append (type_input.prototype.filename);
+ output_code.append ".cov\", \"a\");\n";
+ };
indent.append " ";
profil_current := NULL;
list_main.genere_extern output_code;
+ is_coverage.if {
+ output_code.append "fflush(lisaac_coverage_file);\n";
+ output_code.append "fclose(lisaac_coverage_file);\n";
+ };
(is_java).if_false {
output_code.append " return(0);\n";
};
diff --git a/src/parser.li b/src/parser.li
index 7aec4d9..1b62fcb 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -1938,6 +1938,9 @@ Section Private
+ group_sav:ITM_LIST;
+ arg:ITM_ARGUMENT;
+ result_id:STRING_CONSTANT;
+ + pos : POSITION;
+
+ pos := current_position; // Get the position before consuming the tokens
(read_this_keyword (ALIAS_STR.variable_self)).if {
result := ITM_READ.create current_position name last_string;
@@ -1966,7 +1969,8 @@ Section Private
}.elseif {(result := read_constant) != NULL} then {
}.elseif {read_character '(' } then {
group_sav := last_group;
- last_group := ITM_LIST.create current_position;
+ // @bookmark Create list
+ last_group := ITM_LIST.create pos;
result := last_group;
last_group.set_code read_group;
(read_character ')').if_false {
@@ -1976,7 +1980,8 @@ Section Private
}.elseif {read_character '{' } then {
short (ALIAS_STR.short_block) token (position-1) to position;
group_sav := last_group;
- last_group := ITM_LIST.create current_position;
+ // @bookmark Create block
+ last_group := ITM_LIST.create pos;
save_context; // !! SAVE CONTEXT !!
@@ -2080,6 +2085,8 @@ Section Private
e := ITM_RESULT.create e;
result.add_last e;
};
+ read_space;
+ last_group.insert_code_coverage_hook current_position in result;
ALIAS_ARRAY(ITM_CODE).copy result
);
@@ -2120,9 +2127,13 @@ Section Private
+ e:ITM_CODE;
+ result:ITM_LIST;
+ lst:FAST_ARRAY(ITM_CODE);
+ + pos : POSITION;
+
+ pos := current_position;
(read_character '[').if {
- result := last_group := ITM_LIST.create current_position;
+ // @bookmark: create contract
+ result := last_group := ITM_LIST.create pos;
read_def_local;
lst := ALIAS_ARRAY(ITM_CODE).new;
@@ -2142,9 +2153,14 @@ Section Private
};
}.do_while {continue};
+ read_space;
+ pos := current_position;
+
(! read_character ']').if {
warning_error (current_position,"Added ']'.");
};
+
+ result.insert_code_coverage_hook pos in lst;
e := ITM_PROTOTYPE.create current_position type (ITM_TYPE_SIMPLE.type_void);
lst.add_last e;
//
diff --git a/src/tools/alias_str.li b/src/tools/alias_str.li
index 31ef4f8..a1d8eb3 100644
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@ -175,6 +175,7 @@ Section Public
- slot_is_statistic :STRING_CONSTANT := "is_statistic";
- slot_is_quiet :STRING_CONSTANT := "is_quiet";
- slot_is_library :STRING_CONSTANT := "is_library";
+ - slot_is_coverage :STRING_CONSTANT := "is_coverage";
- slot_get_integer :STRING_CONSTANT := "get_integer";
- slot_get_string :STRING_CONSTANT := "get_string";
- slot_is_cop :STRING_CONSTANT := "is_cop";
@@ -482,6 +483,7 @@ Section Public
list.add slot_is_statistic;
list.add slot_is_quiet;
list.add slot_is_library;
+ list.add slot_is_coverage;
list.add slot_get_integer;
list.add slot_get_string;
list.add slot_is_cop;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list