comparison dmd2/irstate.c @ 1452:638d16625da2

LDC 2 compiles again.
author Robert Clipsham <robert@octarineparrot.com>
date Sat, 30 May 2009 17:23:32 +0100
parents
children
comparison
equal deleted inserted replaced
1423:42bd767ec5a4 1452:638d16625da2
1
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7
8 #include <stdio.h>
9
10 #include "irstate.h"
11
12 IRState::IRState(IRState *irs, Statement *s)
13 {
14 prev = irs;
15 statement = s;
16 symbol = NULL;
17 breakBlock = NULL;
18 contBlock = NULL;
19 switchBlock = NULL;
20 defaultBlock = NULL;
21 ident = NULL;
22 ehidden = NULL;
23 startaddress = NULL;
24 if (irs)
25 {
26 m = irs->m;
27 shidden = irs->shidden;
28 sclosure = irs->sclosure;
29 sthis = irs->sthis;
30 blx = irs->blx;
31 deferToObj = irs->deferToObj;
32 }
33 else
34 {
35 m = NULL;
36 shidden = NULL;
37 sclosure = NULL;
38 sthis = NULL;
39 blx = NULL;
40 deferToObj = NULL;
41 }
42 }
43
44 IRState::IRState(IRState *irs, Dsymbol *s)
45 {
46 prev = irs;
47 statement = NULL;
48 symbol = s;
49 breakBlock = NULL;
50 contBlock = NULL;
51 switchBlock = NULL;
52 defaultBlock = NULL;
53 ident = NULL;
54 ehidden = NULL;
55 startaddress = NULL;
56 if (irs)
57 {
58 m = irs->m;
59 shidden = irs->shidden;
60 sclosure = irs->sclosure;
61 sthis = irs->sthis;
62 blx = irs->blx;
63 deferToObj = irs->deferToObj;
64 }
65 else
66 {
67 m = NULL;
68 shidden = NULL;
69 sclosure = NULL;
70 sthis = NULL;
71 blx = NULL;
72 deferToObj = NULL;
73 }
74 }
75
76 IRState::IRState(Module *m, Dsymbol *s)
77 {
78 prev = NULL;
79 statement = NULL;
80 this->m = m;
81 symbol = s;
82 breakBlock = NULL;
83 contBlock = NULL;
84 switchBlock = NULL;
85 defaultBlock = NULL;
86 ident = NULL;
87 ehidden = NULL;
88 shidden = NULL;
89 sclosure = NULL;
90 sthis = NULL;
91 blx = NULL;
92 deferToObj = NULL;
93 startaddress = NULL;
94 }
95
96 block *IRState::getBreakBlock(Identifier *ident)
97 {
98 IRState *bc;
99
100 for (bc = this; bc; bc = bc->prev)
101 {
102 if (ident)
103 {
104 if (bc->prev && bc->prev->ident == ident)
105 return bc->breakBlock;
106 }
107 else if (bc->breakBlock)
108 return bc->breakBlock;
109 }
110 return NULL;
111 }
112
113 block *IRState::getContBlock(Identifier *ident)
114 {
115 IRState *bc;
116
117 for (bc = this; bc; bc = bc->prev)
118 {
119 if (ident)
120 {
121 if (bc->prev && bc->prev->ident == ident)
122 return bc->contBlock;
123 }
124 else if (bc->contBlock)
125 return bc->contBlock;
126 }
127 return NULL;
128 }
129
130 block *IRState::getSwitchBlock()
131 {
132 IRState *bc;
133
134 for (bc = this; bc; bc = bc->prev)
135 {
136 if (bc->switchBlock)
137 return bc->switchBlock;
138 }
139 return NULL;
140 }
141
142 block *IRState::getDefaultBlock()
143 {
144 IRState *bc;
145
146 for (bc = this; bc; bc = bc->prev)
147 {
148 if (bc->defaultBlock)
149 return bc->defaultBlock;
150 }
151 return NULL;
152 }
153
154 FuncDeclaration *IRState::getFunc()
155 {
156 IRState *bc;
157
158 for (bc = this; bc->prev; bc = bc->prev)
159 {
160 }
161 return (FuncDeclaration *)(bc->symbol);
162 }
163
164