PIPS
flint_walk.c File Reference
#include "local.h"
+ Include dependency graph for flint_walk.c:

Go to the source code of this file.

Macros

#define FATAL(msg, value)   {fprintf(stderr,msg,value);exit(1);}
 This file contains a set of functions defined to walk through the internal representation of a module and chek different things, as the number of arguments, the compatibility of the types of these arguments, ... More...
 

Functions

void flint_cons_dimension (list pc)
 The only global variable : the name of the current module. More...
 
dimension flint_dimension (dimension d)
 
call flint_call (call c)
 This function checks the syntax of a call and recursively. More...
 
range flint_range (range r)
 This function verifies that incremented or decremented
More...
 
reference flint_reference (reference r)
 A reference is used when given a function the address of. More...
 
void flint_syntax (syntax s)
 verification of syntaxes
More...
 
void flint_cons_expression (list pc)
 These two functions operate on the list of expressions
More...
 
void flint_cons_actual_argument (list pc)
 
expression flint_expression (expression e)
 
loop flint_loop (loop l)
 Recursive verification of a loop as (range)+(expression) More...
 
test flint_test (test t)
 A test is taken as (expression)+(statement)+(statement)
More...
 
instruction flint_instruction (instruction i)
 Verification of an instruction with branching according
More...
 
void flint_unstructured (unstructured u)
 
void flint_cons_statement (list pc)
 
statement flint_statement (statement s)
 

Variables

statement flint_current_statement
 cproto-generated files More...
 

Macro Definition Documentation

◆ FATAL

#define FATAL (   msg,
  value 
)    {fprintf(stderr,msg,value);exit(1);}

This file contains a set of functions defined to walk through the internal representation of a module and chek different things, as the number of arguments, the compatibility of the types of these arguments, ...

There is one function for each domain. Its basic principle is to walk through the internal representation by recursive calls to functions handling sub-domains.

Laurent Aniort & Fabien Coelho 1992 Print message and exit violently from flint

Definition at line 42 of file flint_walk.c.

Function Documentation

◆ flint_call()

call flint_call ( call  c)

This function checks the syntax of a call and recursively.

verifies its arguments

Definition at line 74 of file flint_walk.c.

76 {
77  list la = call_arguments(c);
78 
79  check_the_call(c);
80 
82 
83  return (c);
84 }
bool check_the_call(call)
Definition: flint_check.c:130
void flint_cons_actual_argument(list pc)
Definition: flint_walk.c:158
void gen_mapl(gen_iter_func_t fp, const list l)
MAP.
Definition: list.c:165
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
#define call_arguments(x)
Definition: ri.h:711
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References call_arguments, check_the_call(), flint_cons_actual_argument(), and gen_mapl().

Referenced by flint_instruction(), and flint_syntax().

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

◆ flint_cons_actual_argument()

void flint_cons_actual_argument ( list  pc)

An array actual argument may have no indices

Parameters
pcc

Definition at line 158 of file flint_walk.c.

159 {
160  expression e = EXPRESSION(CAR(pc));
161 
162  /* An array actual argument may have no indices */
163  if(expression_reference_p(e)) {
165 
166  if(gen_length(reference_indices(r))!=0)
167  flint_expression(e);
168  }
169  else {
170  flint_expression(e);
171  }
172 }
expression flint_expression(expression e)
Definition: flint_walk.c:174
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328

References CAR, EXPRESSION, expression_reference(), expression_reference_p(), flint_expression(), gen_length(), and reference_indices.

Referenced by flint_call().

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

◆ flint_cons_dimension()

void flint_cons_dimension ( list  pc)

The only global variable : the name of the current module.

flint_walk.c

extern char *current_module_name; unused and changed These two functions deal with the boundaries of finite
arrays, verifying their definition as expressions

Parameters
pcc

Definition at line 52 of file flint_walk.c.

54 {
56 }
dimension flint_dimension(dimension d)
Definition: flint_walk.c:58

References CAR, DIMENSION, and flint_dimension().

+ Here is the call graph for this function:

◆ flint_cons_expression()

void flint_cons_expression ( list  pc)

These two functions operate on the list of expressions

Parameters
pcc

Definition at line 150 of file flint_walk.c.

152 {
154 }

References CAR, EXPRESSION, and flint_expression().

Referenced by flint_reference().

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

◆ flint_cons_statement()

void flint_cons_statement ( list  pc)
Parameters
pcc

Definition at line 269 of file flint_walk.c.

271 {
273 }
statement flint_statement(statement s)
Definition: flint_walk.c:278
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CAR, flint_statement(), and STATEMENT.

Referenced by flint_instruction().

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

◆ flint_dimension()

dimension flint_dimension ( dimension  d)

Definition at line 58 of file flint_walk.c.

60 {
63 
64  flint_expression(el);
65  flint_expression(eu);
66 
67  return (d);
68 }
#define dimension_lower(x)
Definition: ri.h:980
#define dimension_upper(x)
Definition: ri.h:982

References dimension_lower, dimension_upper, and flint_expression().

Referenced by flint_cons_dimension().

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

◆ flint_expression()

expression flint_expression ( expression  e)

Definition at line 174 of file flint_walk.c.

176 {
177  syntax s = expression_syntax(e);
178 
179  flint_syntax(s);
180 
181  return (e);
182 }
void flint_syntax(syntax s)
verification of syntaxes
Definition: flint_walk.c:121
#define expression_syntax(x)
Definition: ri.h:1247

References expression_syntax, and flint_syntax().

Referenced by flint_cons_actual_argument(), flint_cons_expression(), flint_dimension(), flint_range(), and flint_test().

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

◆ flint_instruction()

instruction flint_instruction ( instruction  i)

Verification of an instruction with branching according

to its subclass as defined in the data structure

Definition at line 217 of file flint_walk.c.

219 {
220  list pc;
221  test t;
222  loop l;
223  call c;
224  unstructured u;
225 
226  switch (instruction_tag(i)) {
228  pc = instruction_block(i);
230  break;
231  case is_instruction_test:
232  t = instruction_test(i);
233  flint_test(t);
234  break;
235  case is_instruction_loop:
236  l = instruction_loop(i);
237  flint_loop(l);
238  break;
239  case is_instruction_goto:
240  break;
244  break;
245  case is_instruction_call:
246  c = instruction_call(i);
247  (void) check_procedure(c);
248  flint_call(c);
249  break;
250  default:
251  FATAL("flint_instruction: unexpected tag %u\n", instruction_tag(i));
252  }
253 
254  return (i);
255 }
bool check_procedure(call)
flint_check.c
Definition: flint_check.c:88
loop flint_loop(loop l)
Recursive verification of a loop as (range)+(expression)
Definition: flint_walk.c:186
call flint_call(call c)
This function checks the syntax of a call and recursively.
Definition: flint_walk.c:74
test flint_test(test t)
A test is taken as (expression)+(statement)+(statement)
Definition: flint_walk.c:200
#define FATAL(msg, value)
This file contains a set of functions defined to walk through the internal representation of a module...
Definition: flint_walk.c:42
void flint_unstructured(unstructured u)
Definition: flint_walk.c:257
void flint_cons_statement(list pc)
Definition: flint_walk.c:269
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define instruction_loop(x)
Definition: ri.h:1520
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define instruction_call(x)
Definition: ri.h:1529
#define instruction_test(x)
Definition: ri.h:1517
#define instruction_unstructured(x)
Definition: ri.h:1532

References check_procedure(), FATAL, flint_call(), flint_cons_statement(), flint_loop(), flint_test(), flint_unstructured(), gen_mapl(), instruction_block, instruction_call, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, and is_instruction_unstructured.

Referenced by flint_statement().

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

◆ flint_loop()

loop flint_loop ( loop  l)

Recursive verification of a loop as (range)+(expression)

Definition at line 186 of file flint_walk.c.

188 {
189  range r = loop_range(l);
190  statement s = loop_body(l);
191 
192  flint_range(r);
193  flint_statement(s);
194 
195  return (l);
196 }
range flint_range(range r)
This function verifies that incremented or decremented
Definition: flint_walk.c:90
#define loop_body(x)
Definition: ri.h:1644
#define loop_range(x)
Definition: ri.h:1642

References flint_range(), flint_statement(), loop_body, and loop_range.

Referenced by flint_instruction().

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

◆ flint_range()

range flint_range ( range  r)

This function verifies that incremented or decremented

loop(for) indices do not overflow or underflow their
limits

Definition at line 90 of file flint_walk.c.

92 {
93  expression el = range_lower(r);
94  expression eu = range_upper(r);
96 
97  flint_expression(el);
98  flint_expression(eu);
99  flint_expression(ei);
100 
101  return (r);
102 }
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define range_lower(x)
Definition: ri.h:2288

References flint_expression(), range_increment, range_lower, and range_upper.

Referenced by flint_loop(), and flint_syntax().

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

◆ flint_reference()

reference flint_reference ( reference  r)

A reference is used when given a function the address of.

an element instead of its value.

Definition at line 107 of file flint_walk.c.

109 {
110  list pc = reference_indices(r);
111 
112  (void) check_the_reference(r);
113 
115 
116  return (r);
117 }
void check_the_reference(reference)
Definition: flint_check.c:396
void flint_cons_expression(list pc)
These two functions operate on the list of expressions
Definition: flint_walk.c:150

References check_the_reference(), flint_cons_expression(), gen_mapl(), and reference_indices.

Referenced by flint_syntax().

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

◆ flint_statement()

statement flint_statement ( statement  s)

Definition at line 278 of file flint_walk.c.

280 {
281  instruction
282  i = statement_instruction(s);
283  statement
284  saved = flint_current_statement;
285 
287 
289 
290  flint_current_statement = saved;
291  return (s);
292 }
instruction flint_instruction(instruction i)
Verification of an instruction with branching according
Definition: flint_walk.c:217
statement flint_current_statement
cproto-generated files
Definition: flint.c:46
#define statement_instruction(x)
Definition: ri.h:2458

References flint_current_statement, flint_instruction(), and statement_instruction.

Referenced by flint_cons_statement(), flint_loop(), flint_test(), flint_unstructured(), and flinter().

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

◆ flint_syntax()

void flint_syntax ( syntax  s)

verification of syntaxes

branch according to the syntax subclass

Definition at line 121 of file flint_walk.c.

123 {
124  reference re;
125  range ra;
126  call c;
127 
128  /* branch according to the syntax subclass */
129  switch (syntax_tag(s)) {
130  case is_syntax_reference:
131  re = syntax_reference(s);
132  flint_reference(re);
133  break;
134  case is_syntax_range:
135  ra = syntax_range(s);
136  flint_range(ra);
137  break;
138  case is_syntax_call:
139  c = syntax_call(s);
140  flint_call(c);
141  break;
142  default:
143  FATAL("flint_syntax: unexpected tag %u\n", syntax_tag(s));
144  }
145 }
reference flint_reference(reference r)
A reference is used when given a function the address of.
Definition: flint_walk.c:107
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
#define syntax_call(x)
Definition: ri.h:2736

References FATAL, flint_call(), flint_range(), flint_reference(), is_syntax_call, is_syntax_range, is_syntax_reference, syntax_call, syntax_range, syntax_reference, and syntax_tag.

Referenced by flint_expression().

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

◆ flint_test()

test flint_test ( test  t)

A test is taken as (expression)+(statement)+(statement)

Definition at line 200 of file flint_walk.c.

202 {
203  expression e = test_condition(t);
204  statement st = test_true(t);
205  statement sf = test_false(t);
206 
207  flint_expression(e);
208  flint_statement(st);
209  flint_statement(sf);
210 
211  return (t);
212 }
#define test_false(x)
Definition: ri.h:2837
#define test_true(x)
Definition: ri.h:2835
#define test_condition(x)
Definition: ri.h:2833

References flint_expression(), flint_statement(), test_condition, test_false, and test_true.

Referenced by flint_instruction().

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

◆ flint_unstructured()

void flint_unstructured ( unstructured  u)

Definition at line 257 of file flint_walk.c.

259 {
260  list blocs = NIL;
261 
262  CONTROL_MAP(c, {
264  }, unstructured_control(u), blocs);
265 
266  gen_free_list(blocs);
267 }
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define control_statement(x)
Definition: ri.h:941

References CONTROL_MAP, control_statement, flint_statement(), gen_free_list(), NIL, and unstructured_control.

Referenced by flint_instruction().

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

Variable Documentation

◆ flint_current_statement

statement flint_current_statement
extern

cproto-generated files

Warning! Do not modify this file that is automatically generated!

flint.c

Definition at line 46 of file flint.c.

Referenced by flint_message(), flint_statement(), and flinter().