-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecl.cpp
More file actions
56 lines (46 loc) · 1.01 KB
/
decl.cpp
File metadata and controls
56 lines (46 loc) · 1.01 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
#include "decl.hpp"
var_decl::var_decl( symbol* name, const type* ty )
:m_name( name ), m_type( ty ), m_initialized( false )
{
}
void var_decl::set_init( expr* e )
{
if( m_initialized )
throw std::runtime_error(
"variable has already been initialized\n" );
else
m_init = e;
}
function_decl::function_decl(
symbol* name, const type* ret_type, std::vector<decl*>& param )
:name( name ), return_type( ret_type ), param( param )
{
}
symbol* function_decl::get_name() const
{
return name;
}
const type* function_decl::get_ret_type() const
{
return return_type;
}
const std::vector<decl*>& function_decl::get_param() const
{
return param;
}
param_decl::param_decl( symbol* name, const type* ty )
:name( name ), ty( ty )
{
}
param_decl::param_decl( symbol* name, const type* ty, expr* init )
:name( name ), ty( ty ), init( init )
{
}
program_decl::program_decl( std::vector<stmt*> stmt_seq )
:statement_seq( stmt_seq )
{
}
const std::vector<stmt*>& program_decl::get_stmt_seq() const
{
return statement_seq;
}