25 #include "pips_config.h"
45 #include "constants.h"
151 init_word_to_attachments_begin();
152 init_word_to_attachments_end();
167 close_word_to_attachments_begin();
171 close_word_to_attachments_end();
179 #define ADD_AN_ATTACHMENT_TO_A_MAPPING(a, \
182 if (bound_##a_mapping##_p(a_char)) { \
183 attachments ats = load_##a_mapping(a_char); \
184 list l = attachments_attachment(ats); \
185 l = CONS(ATTACHMENT, a, l); \
186 attachments_attachment(ats) = l; \
189 store_##a_mapping(a_char, \
190 make_attachments(CONS(ATTACHMENT, \
206 debug(6,
"attach_to_character_region",
207 "Attach attachment %p (attachee %p, tag %d) from \"%c\" (%p) to \"%c\" (%p)\n",
209 *begin_char, begin_char,
210 *end_char, end_char);
215 word_to_attachments_begin);
220 word_to_attachments_end);
232 debug(6,
"attach_to_word_list",
233 "Attach attachee %p from \"%s\" (%p) to \"%s\" (%p)\n",
235 begin_word, begin_word,
241 end_word + strlen(end_word) - 1,
361 string declaration_type)
367 strdup(declaration_type)));
375 string declaration_type,
379 char * size_char =
int2a(size);
465 bool (* bound_word_to_attachments_boundary_p)(
void_star))
467 debug(8,
"deal_with_attachment_boundary",
468 "Looking for \"%c\" (%p) at %d\n",
471 if (bound_word_to_attachments_boundary_p(a_character)) {
473 list some_attachments =
477 debug(4,
"deal_with_attachment_boundary",
478 "*** Found attachment = %p for \"%c\" (%p) at %d\n",
479 an_attachment, *a_character,
484 if (load_word_to_attachments_boundary
485 == load_word_to_attachments_begin)
505 debug(8,
"deal_with_attachment_boundaries",
506 "Looking for attachment starts\n");
509 load_word_to_attachments_begin,
510 bound_word_to_attachments_begin_p);
512 debug(8,
"deal_with_attachment_boundaries",
513 "Looking for attachment ends\n");
516 load_word_to_attachments_end,
517 bound_word_to_attachments_end_p);
531 for(i = 0;
a_string[i] !=
'\0'; i++)
546 for(i = 0; i < a_length; i++) {
547 pips_assert(
"Length is too big since end of string encountered",
564 int source_length = strlen(source);
568 pips_debug(5,
"source = \"%s\" (%p), new_position = \"%s\" (%p)\n",
570 new_position, new_position);
572 for(i = 0; i < source_length; i++) {
573 if (bound_word_to_attachments_begin_p(source + i)) {
574 pips_debug(4,
"Relocating begin of attachment from %p to %p\n",
577 pips_assert(
"There is already an attachment on the target",
578 !bound_word_to_attachments_begin_p(new_position + i));
579 store_word_to_attachments_begin(new_position + i,
580 load_word_to_attachments_begin(source + i));
581 delete_word_to_attachments_begin(source + i);
583 if (bound_word_to_attachments_end_p(source + i)) {
584 pips_debug(4,
"Relocating end of attachment from %p to %p\n",
587 pips_assert(
"There is already an attachment on the target",
588 !bound_word_to_attachments_end_p(new_position + i));
589 store_word_to_attachments_end(new_position + i,
590 load_word_to_attachments_end(source + i));
591 delete_word_to_attachments_end(source + i);
607 int target_length = strlen(target);
610 new_string = strcat(target, source);
615 new_string = strcat(target, source);
643 pips_debug(5,
"begin: %d, end: %d, attachment %p (attachee %p)\n",
656 fprintf(output_file,
"(add-text-properties %d %d `(", begin + 1,
end + 2);
665 fprintf(output_file,
"face epips-face-reference mouse-face epips-mouse-face-reference local-map ,epips-reference-keymap epips-property-reference \"%p\" epips-property-reference-variable \"%p\"",
675 fprintf(output_file,
"face epips-face-call mouse-face epips-mouse-face-call local-map ,epips-call-keymap epips-property-call \"%p\"",
686 fprintf(output_file,
"face epips-face-declaration epips-property-declaration \"%p\"",
695 fprintf(output_file,
"epips-property-type \"%s\"", s);
704 fprintf(output_file,
"face epips-face-parallel-loop ");
705 fprintf(output_file,
"epips-property-loop \"%p\"", l);
714 "face epips-face-module-head epips-module-head-name \"%s\"",
723 "invisible epips-invisible-decoration");
731 "face epips-face-preconditions invisible epips-invisible-preconditions");
739 "face epips-face-transformers invisible epips-invisible-transformers");
747 "face epips-face-cumulated-effect invisible epips-invisible-cumulated-effect");
755 "face epips-face-proper-effect invisible epips-invisible-proper-effect");
763 pips_debug(5,
"\tstatement_line_number %d\n", line_number);
764 fprintf(output_file,
"epips-line-number %d", line_number);
816 number_of_attachments,
820 for(i = 0; i < number_of_attachments; i++) {
856 fprintf(output_file,
"(insert \"");
888 pips_debug(6,
"Key %p, value %p\n", word_pointer, attachment_list);
900 get_word_to_attachments_begin());
917 FILE * emacs_file_stream =
safe_fopen(emacs_file_name,
"w");
922 char c = getc(file_stream);
924 if (feof(file_stream))
928 if (c ==
'"' || c ==
'\\')
929 (void) putc(
'\\', emacs_file_stream);
931 (void) putc(c, emacs_file_stream);
937 free(emacs_file_name);
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
attachment make_attachment(attachee a1, intptr_t a2, intptr_t a3)
attachee make_attachee(enum attachee_utype tag, void *val)
void attach_declaration_type_to_words(list l, string declaration_type)
Attach a declaration type to all the words of the given list.
char * strcat_word_and_migrate_attachments(char *target, const char *source)
Concatenate source to target and update the source attachments to point to the new location:
static void attach_to_words(list l, attachee a)
Attach something to all the words of the list given in argument:
void attach_transformers_decoration_to_text(text t)
Attach a transformers decoration:
void deal_with_attachments_in_this_string(string a_string, int position_in_the_output)
Try to find some attachments in the given string.
void attach_preconditions_decoration_to_text(text t)
Attach a preconditions decoration:
static void attach_to_sentence(sentence s, attachee a)
Attach something to a sentence:
void relocate_attachments(char *source, char *new_position)
Many pretty-printers format their own pseudo-comment by their own and move in memory words that have ...
static const char * module_local_name(entity e)
Declare the various mapping between the words and attachments:
sentence attach_head_to_sentence(sentence s, entity module)
Attach the PROGRAM/FUNCTION head:
static bool is_emacs_pretty_print_asked
To store the fact a prettyprinter ask for Emacs attachments:
void attach_proper_effects_decoration_to_text(text t)
Attach a proper effects decoration:
static void attach_to_character_region(char *begin_char, char *end_char, attachee at)
Attach something from begin_char up to end_char:
#define ADD_AN_ATTACHMENT_TO_A_MAPPING(a, a_char, a_mapping)
Use to create or extend the attachment list of a character:
static void attach_to_sentence_list(sentence begin, sentence end, attachee a)
Attach something to a sentence list:
void attach_declaration_to_words(list l, entity e)
Attach a declaration to all the words of the given list:
static void attach_to_sentence_up_to_end_of_text(sentence s, text t, attachee a)
Attach something to a sentence up to the end of the given text:
void attach_decoration_to_text(text t)
Attach a decoration:
void deal_with_attachments_in_this_string_length(string a_string, int position_in_the_output, int a_length)
Try to find some attachments in the a_length first characters of the given string.
void begin_attachment_prettyprint(void)
The translation functions between unique names and objects:
void end_attachment_prettyprint(void)
Clean the things related with the attachment of properties:
char * void_star
Used in word_to_attachments:
static void rewrite_an_attachment(attachment __attribute__((unused)) a)
Nothing to do...
void attach_reference_to_word_list(string begin_word, string end_word, reference r)
Attach a module usage (CALL or function call):
void attach_declaration_size_type_to_words(list l, string declaration_type, int size)
Attach a declaration type with its size to all the words of the given list.
void attach_total_preconditions_decoration_to_text(text __attribute__((unused)) t)
Attach a total preconditions decoration:
void attach_regular_call_to_word(string word, call c)
Attach a reference:
void deal_with_attachments_at_this_character(char *a_character, int position_in_the_output)
Try to find some attachments in the given character that are printed out.
void attach_statement_information_to_text(text t, statement s)
Attach some statement information to text:
static void deal_with_attachment_boundary(char *a_character, int position_in_the_output, attachments(*load_word_to_attachments_boundary)(void_star), bool(*bound_word_to_attachments_boundary_p)(void_star))
Try to find some attachments in the given character.
void attach_cumulated_effects_decoration_to_text(text t)
Attach a cumulated effects decoration:
static void attach_to_word_list(string begin_word, string end_word, attachee at)
Attach something to a word list, from begin_word to end_word:
static void attach_to_text(text t, attachee a)
Attach something to all a text:
char * strdup_and_migrate_attachments(char *a_string)
Duplicate a string and update the attachments to point to the new returned string:
list attachments_before_sorting
To store the attachment before sorting:
void write_an_attachment_file(string file_name)
Add the attachment in Emacs mode by creating a twin file that is decorated with Emacs properties:
static bool put_an_attachment_in_the_list(attachment a)
Add the attachment to the intermediate list:
static int compare_attachment_for_qsort(const void *xp, const void *yp)
The function used by qsort to compare 2 attachment structures:
static void output_the_attachments_for_emacs(FILE *output_file)
Output the list of all the attachments found in the text file with Emacs Lisp syntax:
static void init_output_the_attachments_for_emacs(FILE *output_file)
Begin the Emacs Lisp file:
void attach_loop_to_sentence_up_to_end_of_text(sentence s, text t, loop l)
The user interface:
static void output_the_attachments_in_a_sorted_order(FILE *output_file)
Output the attachment in a sorted order with less precise property first:
static void output_an_attachment(FILE *output_file, attachment a)
Output an attachment to the output file:
const char * local_name(const char *s)
Does not take care of block scopes and returns a pointer.
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
list gen_last(list l)
Return the last element of a list.
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define loop_execution(x)
#define reference_variable(x)
#define statement_number(x)
#define execution_parallel_p(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
GENERIC_LOCAL_FUNCTION(directives, step_directives)
Copyright 2007, 2008, 2009 Alain Muller, Frederique Silber-Chaussumier.
The structure used to build lists in NewGen.
string first_word_of_sentence(sentence)
Return the first word of a sentence:
string last_word_of_sentence(sentence)
Return the last word of a sentence:
#define SENTENCE(x)
newgen_unformatted_domain_defined
#define text_sentences(x)
static int position_in_the_output
FI: just to make sure that text.h is built; pips-makemake -l does not take into account a library who...
@ is_attachee_preconditions
@ is_attachee_statement_line_number
@ is_attachee_transformers
@ is_attachee_module_head
@ is_attachee_declaration
@ is_attachee_cumulated_effects
@ is_attachee_proper_effects
#define attachment_domain
newgen_attachee_domain_defined
#define ATTACHMENT(x)
ATTACHMENT.
#define attachment_undefined
#define attachment_begin(x)
#define attachment_attachee(x)
#define attachee_module_head(x)
#define attachment_end(x)
#define WORD_TO_ATTACHMENTS_MAP(k, v, c, f)
#define attachee_declaration(x)
#define attachments_attachment(x)
#define attachee_reference(x)
#define attachee_statement_line_number(x)