source: dev/trunk/jenga/src/smoothie/LexicalScoping.cpp@ 205

Last change on this file since 205 was 205, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

File size: 1.4 KB
Line 
1#include <jenga/include/smoothie/LexicalScoping.h>
2#include <jenga/include/smoothie/SmoothieException.h>
3
4
5CScope::CScope( int level, int addr, SCOPE_TYPE TypeOfStatement ){
6 this->level = level;
7 this->StartAddress = addr;
8 this->TypeOfStatement = TypeOfStatement;
9
10 pBreakSchedule = (DWORD *)malloc( 1 );
11 nBreakSchedule = 0;
12}
13CScope::~CScope(){
14 free( pBreakSchedule );
15}
16
17int CScope::GetStartAddress(){
18 return StartAddress;
19}
20SCOPE_TYPE CScope::GetTypeOfStatement(){
21 return TypeOfStatement;
22}
23
24
25
26
27CScope *CLexicalScopes::SearchScope( SCOPE_TYPE TypeOfStatement ){
28 for( int i = level; i>=0; i-- ){
29 if( ppScopes[i]->GetTypeOfStatement() == TypeOfStatement ){
30 return ppScopes[i];
31 }
32 }
33 return NULL;
34}
35
36CLexicalScopes::CLexicalScopes(){
37 ppScopes = (CScope **)malloc( 1 );
38 level=0;
39}
40CLexicalScopes::~CLexicalScopes(){
41 free( ppScopes );
42}
43void CLexicalScopes::Init(int addr){
44 // TODO: エラーチェック
45
46 level = -1;
47 Start( addr, SCOPE_TYPE_BASE );
48}
49void CLexicalScopes::Start( int addr, SCOPE_TYPE TypeOfStatement ){
50 level++;
51 ppScopes = (CScope **)realloc( ppScopes, ( level + 1 ) * sizeof( CScope * ) );
52 ppScopes[level] = CreateScope( level, addr, TypeOfStatement );
53}
54
55int CLexicalScopes::GetNowLevel(){
56 return level;
57}
58void CLexicalScopes::SetNowLevel( int level ){
59 this->level = level;
60}
61int CLexicalScopes::GetStartAddress(){
62 return ppScopes[level]->GetStartAddress();
63}
Note: See TracBrowser for help on using the repository browser.