1 | /* bc-emit.h - declare entry points for producing object files of bytecodes. */ |
---|
2 | |
---|
3 | /* Internal format of symbol table for the object file. */ |
---|
4 | struct bc_sym |
---|
5 | { |
---|
6 | /* Private copy separately malloc'd. */ |
---|
7 | char *name; |
---|
8 | |
---|
9 | /* Symbol has a defined value. */ |
---|
10 | unsigned int defined:1; |
---|
11 | |
---|
12 | /* Symbol has been globalized. */ |
---|
13 | unsigned int global:1; |
---|
14 | |
---|
15 | /* Symbol is common. */ |
---|
16 | unsigned int common:1; |
---|
17 | |
---|
18 | /* Value if defined. */ |
---|
19 | unsigned long int val; |
---|
20 | |
---|
21 | /* Used in internal symbol table structure. */ |
---|
22 | struct bc_sym *next; |
---|
23 | }; |
---|
24 | |
---|
25 | |
---|
26 | /* List of symbols defined in a particular segment. */ |
---|
27 | struct bc_segsym |
---|
28 | { |
---|
29 | struct bc_sym *sym; |
---|
30 | struct bc_segsym *next; |
---|
31 | }; |
---|
32 | |
---|
33 | |
---|
34 | /* List of relocations needed in a particular segment. */ |
---|
35 | struct bc_segreloc |
---|
36 | { |
---|
37 | /* Offset of datum to be relocated. */ |
---|
38 | unsigned int offset; |
---|
39 | |
---|
40 | /* Symbol to be relocated by. */ |
---|
41 | struct bc_sym *sym; |
---|
42 | |
---|
43 | struct bc_segreloc *next; |
---|
44 | }; |
---|
45 | |
---|
46 | |
---|
47 | /* Segment of an object file. */ |
---|
48 | struct bc_seg |
---|
49 | { |
---|
50 | /* Size allocated to contents. */ |
---|
51 | unsigned int alloc; |
---|
52 | |
---|
53 | /* Pointer to base of contents. */ |
---|
54 | char *data; |
---|
55 | |
---|
56 | /* Actual size of contents. */ |
---|
57 | unsigned int size; |
---|
58 | |
---|
59 | /* List of symbols defined in this segment. */ |
---|
60 | struct bc_segsym *syms; |
---|
61 | |
---|
62 | /* List of relocations for this segment. */ |
---|
63 | struct bc_segreloc *relocs; |
---|
64 | }; |
---|
65 | |
---|
66 | |
---|
67 | /* Anonymous bytecode label within a single function. */ |
---|
68 | struct bc_label |
---|
69 | { |
---|
70 | /* Offset of label from start of segment. */ |
---|
71 | unsigned int offset; |
---|
72 | |
---|
73 | /* True when offset is valid. */ |
---|
74 | unsigned int defined:1; |
---|
75 | |
---|
76 | /* Unique bytecode ID, used to determine innermost |
---|
77 | block containment */ |
---|
78 | int uid; |
---|
79 | |
---|
80 | /* Next node in list */ |
---|
81 | struct bc_label *next; |
---|
82 | }; |
---|
83 | |
---|
84 | |
---|
85 | /* Reference to a bc_label; a list of all such references is kept for |
---|
86 | the function, then when it is finished they are backpatched to |
---|
87 | contain the correct values. */ |
---|
88 | |
---|
89 | struct bc_labelref |
---|
90 | { |
---|
91 | /* Label referenced. */ |
---|
92 | struct bc_label *label; |
---|
93 | |
---|
94 | /* Code offset of reference. */ |
---|
95 | unsigned int offset; |
---|
96 | |
---|
97 | /* Next labelref in list */ |
---|
98 | struct bc_labelref *next; |
---|
99 | }; |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | extern void bc_initialize(); |
---|
104 | extern int bc_begin_function(); |
---|
105 | extern char *bc_emit_trampoline(); |
---|
106 | extern void bc_emit_bytecode(); |
---|
107 | extern void bc_emit_bytecode_const(); |
---|
108 | extern struct bc_label *bc_get_bytecode_label(); |
---|
109 | extern int bc_emit_bytecode_labeldef(); |
---|
110 | extern void bc_emit_bytecode_labelref(); |
---|
111 | extern void bc_emit_code_labelref(); |
---|
112 | extern char *bc_end_function(); |
---|
113 | extern void bc_align_const(); |
---|
114 | extern void bc_emit_const(); |
---|
115 | extern void bc_emit_const_skip(); |
---|
116 | extern int bc_emit_const_labeldef(); |
---|
117 | extern void bc_emit_const_labelref(); |
---|
118 | extern void bc_align_data(); |
---|
119 | extern void bc_emit_data(); |
---|
120 | extern void bc_emit_data_skip(); |
---|
121 | extern int bc_emit_data_labeldef(); |
---|
122 | extern void bc_emit_data_labelref(); |
---|
123 | extern int bc_define_pointer (); |
---|
124 | extern int bc_emit_common(); |
---|
125 | extern void bc_globalize_label(); |
---|
126 | extern void bc_text(); |
---|
127 | extern void bc_data(); |
---|
128 | extern void bc_align(); |
---|
129 | extern void bc_emit(); |
---|
130 | extern void bc_emit_skip(); |
---|
131 | extern int bc_emit_labeldef(); |
---|
132 | extern void bc_emit_labelref(); |
---|
133 | extern void bc_write_file(); |
---|