forked from bonetblai/mini-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.cc
34 lines (30 loc) · 895 Bytes
/
functions.cc
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
#include "functions.h"
FunctionTable::~FunctionTable()
{
for( std::vector<TypeList*>::const_iterator pi = parameters_.begin(); pi != parameters_.end(); ++pi )
delete *pi;
}
Function
FunctionTable::add_function( const std::string& name )
{
Function function = last_function() + 1;
names_.push_back( name );
functions_.insert( std::make_pair( name, function ) );
parameters_.push_back( new TypeList() );
static_functions_.insert( function );
return( function );
}
std::pair<Function,bool>
FunctionTable::find_function( const std::string& name ) const
{
std::map<std::string,Function>::const_iterator fi = functions_.find( name );
if( fi != functions_.end() )
return( std::make_pair( (*fi).second, true ) );
else
return( std::make_pair( 0,false ) );
}
void
FunctionTable::print_function( std::ostream& os, Function function ) const
{
os << names_[function];
}