source: dev/BasicCompiler_Common/LexicalScoping.h@ 34

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

スコープ処理を統一した。関数の途中でReturnしても、スコープにあるローカルオブジェクトを正確に破棄できるようにした。

File size: 1.3 KB
Line 
1
2
3enum SCOPE_TYPE{
4 //ベース
5 SCOPE_TYPE_BASE,
6
7 //分岐
8 SCOPE_TYPE_IF,
9
10 //ループ
11 SCOPE_TYPE_DO,
12 SCOPE_TYPE_FOR,
13 SCOPE_TYPE_WHILE,
14
15 //ケース分け
16 SCOPE_TYPE_SELECT,
17};
18
19class CScope{
20 int level;
21 int StartAddress;
22 SCOPE_TYPE TypeOfStatement;
23
24 DWORD *pBreakSchedule;
25 int nBreakSchedule;
26
27public:
28 CScope( int level, int addr, SCOPE_TYPE TypeOfStatement );
29 ~CScope();
30
31 int GetStartAddress();
32 SCOPE_TYPE GetTypeOfStatement();
33
34 void Break();
35 void RunScheduleOfBreak();
36};
37
38class CLexicalScopes{
39 CScope **ppScopes;
40 int level;
41
42 CScope *SearchScope( SCOPE_TYPE TypeOfStatement );
43
44public:
45 CLexicalScopes();
46 ~CLexicalScopes();
47
48 //初期化(関数コンパイルの開始時に呼び出される)
49 void Init(int addr);
50
51 // スコープを開始
52 void Start( int addr, SCOPE_TYPE TypeOfStatement );
53
54 //スコープを終了
55 void End();
56
57 //スコープ抜け出しステートメント
58 void Break();
59 void ExitFor();
60 void ExitWhile();
61 void ExitDo();
62
63 int GetNowLevel(void);
64 void SetNowLevel( int level );
65 int GetStartAddress(void);
66
67 //スコープ終了時のデストラクタ呼び出し
68 void CallDestructorsOfScopeEnd();
69
70 //Returnステートメント用のデストラクタ呼び出し
71 void CallDestructorsOfReturn( int BaseLevel = 0 );
72
73private:
74 VARIABLE *add(void);
75};
76
77extern CLexicalScopes obj_LexScopes;
Note: See TracBrowser for help on using the repository browser.