PIPS
language.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "properties.h"
#include "ri.h"
#include "text-util.h"
+ Include dependency graph for language.c:

Go to the source code of this file.

Functions

language get_prettyprint_language ()
 please avoid using this function directly, use predicate instead (see below) More...
 
enum language_utype get_prettyprint_language_tag ()
 
bool prettyprint_language_is_fortran_p ()
 
bool prettyprint_language_is_fortran95_p ()
 
bool prettyprint_language_is_c_p ()
 
void set_prettyprint_language_from_property (enum language_utype native)
 set the prettyprint language according to the property PRETTYPRINT_LANGUAGE @description If the property PRETTYPRINT_LANGUAGE is set to the special value "native" then the language passed in arg is used, usually it's the module native language. More...
 
void set_prettyprint_language (language lang)
 set the prettyprint language from a newgen language object More...
 
void set_prettyprint_language_tag (enum language_utype lang)
 set the prettyprint language from a language_utype argument More...
 
string get_C_label_printf_format (const char *label)
 Get the prettyprint format of a C label. More...
 

Variables

static language prettyprint_language = language_undefined
 ==================== Language management =========== More...
 

Function Documentation

◆ get_C_label_printf_format()

string get_C_label_printf_format ( const char *  label)

Get the prettyprint format of a C label.

Parameters
labela string to render
Returns
the printf-format string

If the label begin with a digit, prefix it with a 'l' to be C compatible.

Hmmm, this does not verify that there is no such label in the program already... :-( Should be solved quite earlier anyway...

Parameters
labelabel

Definition at line 155 of file language.c.

155  {
156  /* If the label begin with a digit, prefix it with a 'l' to be C
157  compatible.
158 
159  Hmmm, this does not verify that there is no such label in the program
160  already... :-( Should be solved quite earlier anyway...
161  */
162  return isdigit(label[0]) ? "l%s:" : "%s:";
163 }

Referenced by print_sentence().

+ Here is the caller graph for this function:

◆ get_prettyprint_language()

language get_prettyprint_language ( void  )

please avoid using this function directly, use predicate instead (see below)

language.c

Returns
the prettyprint language as a newgen language object

Definition at line 57 of file language.c.

57  {
60  return prettyprint_language;
61 }
language make_language_fortran(void)
Definition: ri.c:1250
static language prettyprint_language
==================== Language management ===========
Definition: language.c:51
#define language_undefined
Definition: ri.h:1551

References language_undefined, make_language_fortran(), and prettyprint_language.

Referenced by add_loop_parallel_threshold(), and merge_on_outer().

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

◆ get_prettyprint_language_tag()

enum language_utype get_prettyprint_language_tag ( void  )
Returns
the prettyprint language as a language_utype

Definition at line 57 of file language.c.

67  {
69 }
language get_prettyprint_language()
please avoid using this function directly, use predicate instead (see below)
Definition: language.c:57
#define language_tag(x)
Definition: ri.h:1590

Referenced by effect_words_reference(), ensure_comment_consistency(), generate_alternate_return_targets(), get_comment_continuation(), get_comment_sentinel(), loop_annotate(), loop_private_variables(), loop_test(), mark_block(), pragma_to_string(), prettyprint_language_is_c_p(), prettyprint_language_is_fortran95_p(), prettyprint_language_is_fortran_p(), print_code_or_source(), print_parallelized_code_common(), print_sentence(), sentence_head(), sentence_tail(), store_sc_text_line(), text_block_else(), text_block_elseif(), text_block_if(), text_block_ifthen(), text_directive(), text_instruction(), text_io_block_if(), text_logical_if(), text_loop_default(), text_omp_directive(), text_test(), text_trail(), text_whileloop(), this_entity_cdeclaration(), whileloop_test(), words_any_reference(), words_assign_op(), words_basic(), words_declaration(), words_dimension(), words_dimensions(), words_goto_label(), words_io_inst(), words_loop_list(), words_nullary_op(), words_parameters(), words_range(), words_regular_call(), words_subscript_range(), and words_test_list().

+ Here is the caller graph for this function:

◆ prettyprint_language_is_c_p()

bool prettyprint_language_is_c_p ( void  )
Returns
true if the language is C

Definition at line 91 of file language.c.

91  {
93 }
enum language_utype get_prettyprint_language_tag()
Definition: language.c:67
@ is_language_c
Definition: ri.h:1567

References get_prettyprint_language_tag(), and is_language_c.

Referenced by compilation_unit_text(), renamed_op_handling(), sentence_head(), text_block_elseif(), text_block_ifthen(), text_whileloop(), words_infix_binary_op(), words_io_inst(), words_prefix_unary_op(), and words_regular_call().

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

◆ prettyprint_language_is_fortran95_p()

bool prettyprint_language_is_fortran95_p ( void  )
Returns
true if the language is f95

Definition at line 83 of file language.c.

83  {
85 }
@ is_language_fortran95
Definition: ri.h:1568

References get_prettyprint_language_tag(), and is_language_fortran95.

Referenced by f77_f95_style_management(), text_entity_declaration(), and words_infix_binary_op().

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

◆ prettyprint_language_is_fortran_p()

bool prettyprint_language_is_fortran_p ( void  )
Returns
true if the language is f77

Definition at line 75 of file language.c.

75  {
77 }
@ is_language_fortran
Definition: ri.h:1566

References get_prettyprint_language_tag(), and is_language_fortran.

Referenced by close_pragma(), create_module_with_statement(), ensure_comment_consistency(), get_prettyprint_indentation(), marged(), omp_operator_entity(), omp_operator_str(), pragma_to_string(), print_sentence(), reductions_get_omp_pragma_str(), and text_instruction().

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

◆ set_prettyprint_language()

void set_prettyprint_language ( language  lang)

set the prettyprint language from a newgen language object

Parameters
lang,thelanguage to be used to set the prettyprint_language variable, content is copied so caller may free if it was malloced
Parameters
langang

Definition at line 130 of file language.c.

References language_undefined, make_language_fortran(), and prettyprint_language.

+ Here is the call graph for this function:

◆ set_prettyprint_language_from_property()

void set_prettyprint_language_from_property ( enum language_utype  native)

set the prettyprint language according to the property PRETTYPRINT_LANGUAGE @description If the property PRETTYPRINT_LANGUAGE is set to the special value "native" then the language passed in arg is used, usually it's the module native language.

The user can set "F77", "F95", or "C" to force the prettyprint of a language.

Parameters
nativeative

Definition at line 103 of file language.c.

103  {
106  }
107  const char* lang = get_string_property ("PRETTYPRINT_LANGUAGE");
108  if (strcmp (lang, "F77") == 0) {
110  }
111  else if (strcmp (lang, "C") == 0) {
113  }
114  else if (strcmp (lang, "F95") == 0) {
116  }
117  else if (strcmp (lang, "native") == 0) {
119  } else {
120  pips_internal_error("bad property value for language");
121  }
122 }
char * get_string_property(const char *)
#define pips_internal_error
Definition: misc-local.h:149

References get_string_property(), is_language_c, is_language_fortran, is_language_fortran95, language_tag, language_undefined, make_language_fortran(), pips_internal_error, and prettyprint_language.

Referenced by controlizer(), ensure_comment_consistency(), new_controlizer(), omp_loop_parallel_threshold_set(), omp_merge_pragma(), print_code_or_source(), and static_controlize().

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

◆ set_prettyprint_language_tag()

void set_prettyprint_language_tag ( enum language_utype  lang)

set the prettyprint language from a language_utype argument

Parameters
lang,thelanguage to be used to set the prettyprint_language variable
Parameters
langang

Definition at line 143 of file language.c.

References language_tag, language_undefined, make_language_fortran(), and prettyprint_language.

Referenced by actual_c_parser(), actual_symbol_table_dump(), add_new_module_from_text(), MakeCaseStatement(), missing_file_initializer(), and this_entity_cdeclaration().

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

Variable Documentation

◆ prettyprint_language

language prettyprint_language = language_undefined
static

==================== Language management ===========

The prettyprint language

Definition at line 51 of file language.c.

Referenced by get_prettyprint_language(), set_prettyprint_language(), set_prettyprint_language_from_property(), and set_prettyprint_language_tag().