PIPS
module.c File Reference
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "constants.h"
#include "text-util.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "prettyprint.h"
+ Include dependency graph for module.c:

Go to the source code of this file.

Functions

static void do_recompile_module (entity module, statement module_statement)
 High-level functions about modules, using prettyprint, pipsdbm and ri-util. More...
 
bool recompile_module (const string module)
 build a textual representation of the modified module and update db More...
 

Function Documentation

◆ do_recompile_module()

static void do_recompile_module ( entity  module,
statement  module_statement 
)
static

High-level functions about modules, using prettyprint, pipsdbm and ri-util.

build and register textual representation

the module will be reparsed, so fix(=delete) all its previous entites

Definition at line 50 of file module.c.

50  {
51 
52  /* build and register textual representation */
54  //add_new_module_from_text(module,t,fortran_module_p(modified_module),compilation_unit_of_module(module));
55  string dirname = db_get_current_workspace_directory();
56  string res = fortran_module_p(module)? DBR_INITIAL_FILE : DBR_C_SOURCE_FILE;
57  string filename = db_get_file_resource(res,module_local_name(module),true);
58  string fullname = strdup(concatenate(dirname, "/",filename, NULL));
59  FILE* f = safe_fopen(fullname,"w");
60  free(fullname);
61  print_text(f,t);
62  fclose(f);
63  free_text(t);
64 
66 
67  /* the module will be reparsed, so fix(=delete) all its previous entites */
68 #if 0
69  {
70  list p = NIL;
71  FOREACH(ENTITY, e, entity_declarations(modified_module))
72  {
73  if( recompile_module_removable_entity_p((gen_chunkp)e))
75  else
76  p = CONS(ENTITY,e,p);
77  }
78  entity_declarations(modified_module) = gen_nreverse(p);
80  }
81 #endif
82 }
sequence make_sequence(list a)
Definition: ri.c:2125
void free_text(text p)
Definition: text.c:74
static statement module_statement
Definition: alias_check.c:125
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
void free(void *)
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static char * module
Definition: pips.c:74
#define db_get_file_resource
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
text text_module(entity, statement)
#define entity_declarations(e)
MISC: newgen shorthands.
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define code_initializations(x)
Definition: ri.h:788
#define value_code(x)
Definition: ri.h:3067
#define entity_initial(x)
Definition: ri.h:2796
char * strdup()
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
void gen_clear_tabulated_element(gen_chunk *obj)
GEN_CLEAR_TABULATED_ELEMENT only clears the entry for object OBJ in the gen_tabulated_ and gen_tabula...
Definition: tabulated.c:251
void print_text(FILE *fd, text t)
Definition: print.c:195
A gen_chunk is used to store every object.
Definition: genC.h:58

References code_initializations, concatenate(), CONS, db_get_current_workspace_directory(), db_get_file_resource, DB_PUT_FILE_RESOURCE, ENTITY, entity_declarations, entity_initial, f(), FOREACH, fortran_module_p(), free(), free_text(), gen_clear_tabulated_element(), gen_nreverse(), make_sequence(), module, module_local_name(), module_statement, NIL, print_text(), safe_fopen(), strdup(), text_module(), and value_code.

Referenced by recompile_module().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recompile_module()

bool recompile_module ( const string  module)

build a textual representation of the modified module and update db

module.c

Parameters
moduleodule

Definition at line 87 of file module.c.

88 {
89  entity modified_module = module_name_to_entity(module);
90  statement modified_module_statement =
91  (statement) db_get_memory_resource(DBR_CODE, module, true);
92  do_recompile_module(modified_module,modified_module_statement);
93  return true;
94 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
static void do_recompile_module(entity module, statement module_statement)
High-level functions about modules, using prettyprint, pipsdbm and ri-util.
Definition: module.c:50
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

References db_get_memory_resource(), do_recompile_module(), module, and module_name_to_entity().

Referenced by do_inlining(), and do_unfolding().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: