25 #include "pips_config.h"
32 #include "constants.h"
43 #include "pips-libs.h"
45 #ifdef HAVE_PIPS_c_syntax_LIBRARY
57 #define FILE_WARNING \
59 "! This module was automatically generated by PIPS and should\n" \
60 "! be updated by the user with READ and WRITE effects on\n" \
61 "! formal parameters to be useful...\n" \
64 #define C_FILE_WARNING_EFFECT \
66 "// This module was automatically generated by PIPS and should\n" \
67 "// be updated by the user with READ and WRITE effects on\n" \
68 "// formal parameters to be useful...\n" \
71 #define C_FILE_WARNING \
73 "// This module was automatically generated by PIPS\n" \
79 string number =
int2a(n);
98 "! Unable to determine the type of parameter number ", name,
"\n",
100 " ", name,
"\n", NULL));
109 strdup(
" "), name,
strdup(is_fortran?
"" :
";"), NULL)));
163 for(number=1; number<=n; number++)
178 for(number=1; number<=n; number++) {
295 pips_assert(
"We must be in a C prettyprinter environment",
310 pips_debug(8,
"Redundant list of supporting entities: ");
319 for(cse = sel; !
ENDP(cse);
POP(cse)) {
328 pips_debug(8,
"List of supporting entities: ");
372 const char* res = is_fortran? DBR_INITIAL_FILE : DBR_C_SOURCE_FILE;
380 cu_real[strlen(cu_real)-1]=0;
392 asprintf(&finit_name,
"%s/%s", dir_name, init_name);
435 bool success_p =
true;
439 const char *res = is_fortran? DBR_INITIAL_FILE : DBR_C_SOURCE_FILE;
448 "No entity defined for module %s although it might"
449 " have been encountered at a call site\n",
module_name);
475 char * the_cu = NULL,*iter;
487 string cu_real =
strdup(cun);
488 cu_real[strlen(cu_real)-1]=0;
499 asprintf(&finit_name,
"%s/%s" ,dir_name,init_name);
532 else if(!is_fortran) {
581 pips_user_error(
"No occurence of function \"%s\" has been encountered. "
606 string res= is_fortran? DBR_INITIAL_FILE : DBR_C_SOURCE_FILE;
620 bool module_found =
false;
628 string file = (* internal_resolver)(
module);
629 if(!file || *file==
'\0') {
631 pips_user_error(
"The resolver couldn't find a source file for module '%s'"
632 ", did you forgot a source file ? For external library you have to"
633 " provide a stub file.\n",
module);
638 "given by the resolver : %s\n",
652 bool module_found =
false;
655 const char* missing_file_generator =
659 string generator_cmd = NULL;
661 asprintf(&generator_cmd,
"%s %s", missing_file_generator,
module);
665 FILE* pout = popen(generator_cmd,
"r");
667 pips_user_error(
"Failed to launch command %s\n",missing_file_generator);
681 int ret = pclose(pout);
688 if(!file || *file==
'\0') {
690 pips_user_error(
"The resolver couldn't find a source file for module '%s'"
691 ", did you forgot a source file ? For external library you have to"
692 " provide a stub file.\n",
module);
698 "given by the resolver : %s\n",
718 bool request_the_module =
true;
719 bool module_found =
false;
722 while(request_the_module) {
723 file =
user_request(
"Please enter a file for module %s\n or \"quit\" "
724 "to abort or \"generate\" to generate a stub\n",
module);
731 request_the_module =
false;
739 request_the_module =
true;
750 request_the_module =
true;
755 "Please type \"quit\" or another file name.\n",
758 request_the_module =
true;
785 bool success_p =
false;
790 "set PREPROCESSOR_MISSING_FILE_HANDLING"
791 " to \"query\" or \"generate\"...\n",
module_name);
804 "PREPROCESSOR_MISSING_FILE_HANDLING = \"%s\"",
809 if(success_p && !is_fortran) {
843 debug_on(
"INITIALIZER_DEBUG_LEVEL");
857 debug_on(
"INITIALIZER_DEBUG_LEVEL");
void user_log(const char *format,...)
unformatted make_unformatted(string a1, intptr_t a2, intptr_t a3, list a4)
sentence make_sentence(enum sentence_utype tag, void *val)
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
string compilation_unit_name
cproto-generated files
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
#define ret(why, what)
true if not a remapping for old.
bool empty_string_p(const char *s)
const char * module_name(const char *s)
Return the module part of an entity name.
FILE * safe_fopen(const char *filename, const char *what)
bool file_exists_p(const char *name)
char * get_string_property(const char *)
int safe_fclose(FILE *stream, const char *filename)
void safe_link(const char *topath, const char *frompath)
Create a hard link to topath.
void safe_unlink(const char *file_name)
Delete the given file.
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
#define ENDP(l)
Test if a list is empty.
list gen_make_list(int domain,...)
list gen_nreverse(list cp)
reverse a list in place
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
bool gen_once_p(list l)
FC: ARGH...O(n^2)!
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#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
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define list_undefined
Undefined list definition :-)
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
#define full_name(dir, name)
bool fortran_initializer(const string module_name)
Create a module with its related file resources when there is no Fortran source for it.
static bool retrieve_a_missing_file_using_internal_resolver(const char *module, bool is_fortran)
static sentence stub_head(entity f, bool is_fortran)
Generate the head of a stub source for a missing source.
static bool missing_file_initializer(const char *module_name, bool is_fortran)
Generate a source file for a module, if none available.
static text compilation_unit_text(entity cu, entity module)
Generate the text of a compilation unit for a missing C module.
void set_internal_missing_module_resolver_handler(string(*_internal_resolver)(const char *))
static sentence stub_var_decl(parameter p, int n, bool is_fortran)
Generate an entry for one formal parameter of a stub declaration.
static bool module_in_user_file_p(const char *module, bool is_fortran)
bool initializer(const string module_name)
A phase that creates a module with its related file resources when there is no Fortran source for it.
static string nth_formal_name(int n)
Generate a string as "f42" for the number 42 for example.
static bool retrieve_a_missing_file_using_external_resolver(const char *module, bool is_fortran)
static text stub_text(entity module, bool is_fortran)
Generate the text for a missing module.
static bool generic_initializer(const char *module_name, bool is_fortran)
There is no real rule to produce source or user files when there is no corresponding file; so the ini...
bool add_new_module(const char *module_name, entity module, statement stat, bool is_fortran)
Add the new resource files associated to a module with its more-or-less correct code.
void compilation_unit_parser(_UNUSED_ const string s)
void add_new_compilation_unit(const char *compilation_unit_name, bool is_fortran, entity module)
Warning! Do not modify this file that is automatically generated!
#define C_FILE_WARNING_EFFECT
bool add_new_module_from_text(const char *module_name, text code_text, bool is_fortran, const char *compilation_unit_name)
Add the new resource files associated to a module with its more-or-less correct code.
static string(* internal_resolver)(const char *)=0
bool c_initializer(const string module_name)
A phase that creates a module with its related file resources when there is no C source for it.
static bool ask_a_missing_file(const char *module, bool is_fortran)
Generate a new module by asking some files to the user.
bool prettyprint_language_is_c_p()
void set_prettyprint_language_tag(enum language_utype lang)
set the prettyprint language from a language_utype argument
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
#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
string user_request(const char *,...)
#define DUMMY_STRUCT_PREFIX
#define DUMMY_ENUM_PREFIX
For enum and struct and union without names (see c_syntax/cyacc.y)
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
#define DUMMY_UNION_PREFIX
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define same_string_p(s1, s2)
#define string_undefined_p(s)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
#define WORKSPACE_TMP_SPACE
#define db_make_subdirectory(n)
string db_get_current_workspace_directory(void)
bool flag_as_stub(const string)
bool bootstrap_stubs(const string)
bool process_user_file(string)
list generic_c_words_entity(type t, list name, bool is_safe, bool add_dummy_parameter_name_p, list *ppdl)
This recursive function prints a C variable with its type.
text c_text_entity(entity module, entity e, int margin, list *ppdl, bool init_p)
Regeneration of declarations from the symbol table.
text c_text_entity_simple(entity module, entity e, int margin)
text text_module(entity, statement)
string basic_to_string(basic)
#define PIPS_IO_BARRIER_OPERATOR_NAME
#define PIPS_MEMORY_BARRIER_OPERATOR_NAME
special pips intrinsics with global effects
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
const char * module_local_name(entity e)
Returns the module local user name.
void print_entities(list l)
entity MakeCompilationUnitEntity(const char *name)
This is useful for the C language only.
list functional_type_supporting_entities(list, functional)
list type_supporting_entities(list, type)
#define type_functional_p(x)
#define functional_result(x)
#define parameter_type(x)
#define type_functional(x)
#define basic_overloaded_p(x)
#define type_undefined_p(x)
#define entity_undefined_p(x)
#define functional_parameters(x)
#define PARAMETER(x)
PARAMETER.
#define type_varargs_p(x)
#define type_variable_p(x)
#define variable_basic(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strchrnul(const char *s, int c_in)
Searching in a string.
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
The structure used to build lists in NewGen.
#define CHAIN_SWORD(l, s)
#define MERGE_TEXTS(r, t)
#define ADD_SENTENCE_TO_TEXT(t, p)
void print_text(FILE *fd, text t)
#define sentence_undefined
#define SENTENCE(x)
newgen_unformatted_domain_defined
#define text_sentences(x)
@ is_sentence_unformatted