comparison ir/irlandingpad.h @ 319:e9c93739bc4c trunk

[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
author ChristianK
date Sat, 05 Jul 2008 10:22:56 +0200
parents
children d772927ca496
comparison
equal deleted inserted replaced
318:8e570dbe4087 319:e9c93739bc4c
1 #ifndef LLVMDC_IR_IRLANDINGPADINFO_H
2 #define LLVMDC_IR_IRLANDINGPADINFO_H
3
4 #include "ir/ir.h"
5 #include "statement.h"
6
7 #include <deque>
8 #include <stack>
9
10 struct IRLandingPadInfo
11 {
12 // default constructor for being able to store in a vector
13 IRLandingPadInfo()
14 : target(NULL), finallyBody(NULL), catchType(NULL)
15 {}
16
17 IRLandingPadInfo(Catch* catchstmt, llvm::BasicBlock* end);
18 IRLandingPadInfo(Statement* finallystmt);
19
20 // the target catch bb if this is a catch
21 // or the target finally bb if this is a finally
22 llvm::BasicBlock* target;
23
24 // nonzero if this is a finally
25 Statement* finallyBody;
26
27 // nonzero if this is a catch
28 ClassDeclaration* catchType;
29 };
30
31 struct IRLandingPad
32 {
33 IRLandingPad() : catch_var(NULL) {}
34
35 // builds a new landing pad according to given infos
36 // and the ones on the stack. also stores it as invoke target
37 void push(llvm::BasicBlock* inBB);
38
39 void addCatch(Catch* catchstmt, llvm::BasicBlock* end);
40 void addFinally(Statement* finallystmt);
41
42 // pops the most recently constructed landing pad bb
43 // and its infos
44 void pop();
45
46 // gets the current landing pad
47 llvm::BasicBlock* get();
48
49 // creates or gets storage for exception object
50 LLValue* getExceptionStorage();
51
52 private:
53 // constructs the landing pad from infos
54 void constructLandingPad(llvm::BasicBlock* inBB);
55
56 // information needed to create landing pads
57 std::deque<IRLandingPadInfo> infos;
58 std::deque<IRLandingPadInfo> unpushed_infos;
59
60 // the number of infos we had before the push
61 std::stack<size_t> nInfos;
62
63 // the target for invokes
64 std::stack<llvm::BasicBlock*> padBBs;
65
66 // storage for the catch variable
67 LLValue* catch_var;
68 };
69
70 #endif