-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathpretty_func.c
More file actions
62 lines (51 loc) · 1.46 KB
/
pretty_func.c
File metadata and controls
62 lines (51 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** \file pretty_func.c
* split out of exppp.c 9/21/13
*/
#include <exppp/exppp.h>
#include "pp.h"
#include "pretty_alg.h"
#include "pretty_type.h"
#include "pretty_stmt.h"
#include "pretty_func.h"
void FUNC_out( Function fn, int level ) {
if( fn->u.func->builtin ) {
return;
}
first_newline();
exppp_ref_info( &fn->symbol );
raw( "%*sFUNCTION %s", level, "", fn->symbol.name );
if( fn->u.func->parameters ) {
unsigned int param_indent = level + strlen( "FUNCTION " );
raw( "(\n" );
ALGargs_out( fn->u.func->parameters, param_indent );
raw( "\n%*s)", param_indent - exppp_continuation_indent, "" );
}
raw( " :" );
indent2 = curpos + exppp_continuation_indent;
TYPE_head_out( fn->u.func->return_type, NOLEVEL );
raw( ";\n" );
ALGscope_out( fn, level + exppp_nesting_indent );
STMTlist_out( fn->u.proc->body, level + exppp_nesting_indent );
raw( "\n%*sEND_FUNCTION;", level, "" );
tail_comment( fn->symbol.name );
}
char * FUNCto_string( Function f ) {
if( prep_string() ) {
return placeholder;
}
FUNC_out( f, 0 );
return ( finish_string() );
}
/** return length of buffer used */
int FUNCto_buffer( Function e, char * buffer, int length ) {
if( prep_buffer( buffer, length ) ) {
return -1;
}
FUNC_out( e, 0 );
return( finish_buffer() );
}
void FUNCout( Function f ) {
prep_file();
FUNC_out( f, 0 );
finish_file();
}