summaryrefslogtreecommitdiff
path: root/includes/compiler/Exceptions.h
blob: 01efcde91f723ffc5bed293acfcea51f32df674b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef COMPILER_EXCEPTIONS_H
#define COMPILER_EXCEPTIONS_H

#include "compiler/common.h"

#ifdef __MWERKS__
#pragma options align=mac68k
#endif

typedef enum ExceptionActionType {
    EAT_NOP,
    EAT_DESTROYLOCAL,
    EAT_DESTROYLOCALCOND,
    EAT_DESTROYLOCALOFFSET,
    EAT_DESTROYLOCALPOINTER,
    EAT_DESTROYLOCALARRAY,
    EAT_DESTROYPARTIALARRAY,
    EAT_DESTROYMEMBER,
    EAT_DESTROYMEMBERCOND,
    EAT_DESTROYMEMBERARRAY,
    EAT_DELETEPOINTER,
    EAT_DELETELOCALPOINTER,
    EAT_DELETEPOINTERCOND,
    EAT_CATCHBLOCK,
    EAT_ACTIVECATCHBLOCK,
    EAT_SPECIFICATION,
    EAT_TERMINATE,
    EAT_DESTROYBASE,
    EAT_NACTIONS
} ExceptionActionType;

struct ExceptionAction {
    ExceptionAction *prev;
    union {
        struct {
            Object *local;
            Object *dtor;
        } destroy_local;
        struct {
            Object *local;
            Object *cond;
            Object *dtor;
        } destroy_local_cond;
        struct {
            Object *local;
            Object *dtor;
            SInt32 offset;
        } destroy_local_offset;
        struct {
            Object *pointer;
            Object *dtor;
        } destroy_local_pointer;
        struct {
            Object *localarray;
            Object *dtor;
            SInt32 elements;
            SInt32 element_size;
        } destroy_local_array;
        struct {
            Object *arraypointer;
            Object *arraycounter;
            Object *dtor;
            Object *element_size;
        } destroy_partial_array;
        struct { // TODO: merge me with destroy_member
            Object *objectptr;
            Object *dtor;
            SInt32 offset;
        } destroy_base;
        struct {
            Object *objectptr;
            Object *dtor;
            SInt32 offset;
        } destroy_member;
        struct {
            Object *objectptr;
            Object *cond;
            Object *dtor;
            SInt32 offset;
        } destroy_member_cond;
        struct {
            Object *objectptr;
            Object *dtor;
            SInt32 offset;
            SInt32 elements;
            SInt32 element_size;
        } destroy_member_array;
        struct {
            Object *pointerobject;
            Object *deletefunc;
        } delete_pointer;
        struct {
            Object *pointerobject;
            Object *deletefunc;
            Object *cond;
        } delete_pointer_cond;
        struct {
            Object *catch_object;
            Object *catch_info_object;
            CLabel *catch_label;
            Object *catch_typeid;
            Type *catch_type;
            UInt32 catch_qual;
        } catch_block;
        struct {
            Object *catch_info_object;
            Boolean call_dtor;
        } active_catch_block;
        struct {
            SInt32 unexp_ids;
            Object **unexp_id;
            CLabel *unexp_label;
            Object *unexp_info_object;
        } specification;
        struct {
            Object *object;
            Boolean is_dep;
        } local;
    } data;
    ExceptionActionType type;
};

typedef struct EANode {
    struct EANode *dagListNext;
    struct EANode *prev;
    ExceptionAction *action;
    UInt16 count;
    UInt16 xE;
} EANode;

typedef struct PCAction {
    struct PCAction *next;
    struct PCAction *prev;
    PCode *firstInstr;
    PCode *lastInstr;
    ExceptionAction *actions;
    EANode *node;
} PCAction;

#ifdef __MWERKS__
#pragma options align=reset
#endif

extern EANode *DAG[EAT_NACTIONS];

extern void initializeexceptiontables(void);
extern int countexceptionactionregisters(ExceptionAction *actions);
extern void noteexceptionactionregisters(ExceptionAction *actions, PCodeArg *ops);
extern void recordexceptionactions(PCode *instr, ExceptionAction *actions);
extern void dumpexceptiontables(Object *function, SInt32 codesize);

#endif