Changeset 248 in dev for trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
- Timestamp:
- Jul 29, 2007, 12:33:04 PM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
r245 r248 1 1 #include "stdafx.h" 2 2 3 #include <LexicalScop ingImpl.h>3 #include <LexicalScope.h> 4 4 #include <Compiler.h> 5 5 … … 13 13 14 14 15 void ScopeImpl::Break(){15 void LexicalScope::Break(){ 16 16 //未解放のローカルオブジェクトを解放する 17 GetLexicalScopes().CallDestructorsOfReturn( level );17 compiler.codeGenerator.lexicalScopes.CallDestructorsOfReturn( level ); 18 18 19 19 //jmp ...(Next addr) 20 OpBuffer[obp++]=(char)0xE9; 21 22 pBreakSchedule=(DWORD *)realloc( pBreakSchedule, ( nBreakSchedule + 1 ) * sizeof(DWORD) ); 23 pBreakSchedule[nBreakSchedule]=obp; 24 nBreakSchedule++; 25 26 obp+=sizeof(long); 20 breakPertialSchedules.push_back( 21 compiler.codeGenerator.op_jmp( 0, sizeof(long), true ) 22 ); 27 23 } 28 void ScopeImpl::RunScheduleOfBreak(){ 29 for(int i=0;i<nBreakSchedule;i++){ 30 *((long *)(OpBuffer+pBreakSchedule[i]))=obp-(pBreakSchedule[i]+sizeof(long)); 24 void LexicalScope::RunScheduleOfBreak(){ 25 BOOST_FOREACH( const PertialSchedule *pBreakPertialSchedule, breakPertialSchedules ) 26 { 27 compiler.codeGenerator.opfix_JmpPertialSchedule( pBreakPertialSchedule ); 31 28 } 32 29 } 33 30 34 void LexicalScopesImpl::End(){ 31 32 33 LexicalScope *LexicalScopes::SearchScope( LexicalScope::SCOPE_TYPE TypeOfStatement ){ 34 for( int i = level; i>=0; i-- ){ 35 if( ppScopes[i]->GetTypeOfStatement() == TypeOfStatement ){ 36 return ppScopes[i]; 37 } 38 } 39 return NULL; 40 } 41 42 void LexicalScopes::Init(int addr){ 43 // TODO: エラーチェック 44 45 level = -1; 46 Start( addr, LexicalScope::SCOPE_TYPE_BASE ); 47 } 48 void LexicalScopes::Start( int addr, LexicalScope::SCOPE_TYPE TypeOfStatement ){ 49 level++; 50 ppScopes = (LexicalScope **)realloc( ppScopes, ( level + 1 ) * sizeof( LexicalScope * ) ); 51 ppScopes[level] = new LexicalScope( level, addr, TypeOfStatement ); 52 } 53 54 int LexicalScopes::GetNowLevel(){ 55 return level; 56 } 57 void LexicalScopes::SetNowLevel( int level ){ 58 this->level = level; 59 } 60 int LexicalScopes::GetStartAddress(){ 61 return ppScopes[level]->GetStartAddress(); 62 } 63 64 void LexicalScopes::End(){ 35 65 if( level <= 0 ){ 36 66 SetError(); … … 65 95 66 96 // スコープ終了時のデストラクタ呼び出し 67 void LexicalScopes Impl::CallDestructorsOfScopeEnd(){97 void LexicalScopes::CallDestructorsOfScopeEnd(){ 68 98 69 99 Variables &vars = UserProc::IsGlobalAreaCompiling() ? … … 134 164 135 165 // Returnステートメントで発行されるデストラクタを生成 136 void LexicalScopes Impl::CallDestructorsOfReturn( int BaseLevel ){166 void LexicalScopes::CallDestructorsOfReturn( int BaseLevel ){ 137 167 //現在のスコープレベルを退避 138 168 int backupScopeLevel = GetNowLevel(); … … 147 177 SetNowLevel( backupScopeLevel ); 148 178 } 149 150 LexicalScopesImpl &GetLexicalScopes()151 {152 static LexicalScopesImpl *pTemp = NULL;153 if( !pTemp )154 {155 pTemp = (LexicalScopesImpl *)Smoothie::Temp::pLexicalScopes;156 }157 return *pTemp;158 }
Note:
See TracChangeset
for help on using the changeset viewer.