25 #define CB_BEFORE cb_int0
26 #define CB_AFTER cb_int1
28 #define COB_MAX_SUBSCRIPTS 16
30 #define CB_PREFIX_ATTR "a_"
31 #define CB_PREFIX_BASE "b_"
32 #define CB_PREFIX_CONST "c_"
33 #define CB_PREFIX_DECIMAL "d_"
34 #define CB_PREFIX_FIELD "f_"
35 #define CB_PREFIX_FILE "h_"
36 #define CB_PREFIX_KEYS "k_"
37 #define CB_PREFIX_LABEL "l_"
38 #define CB_PREFIX_SEQUENCE "s_"
39 #define CB_PREFIX_STRING "st_"
41 #define CB_PROGRAM_TYPE 0
42 #define CB_FUNCTION_TYPE 1
44 #define CB_CALL_BY_REFERENCE 1
45 #define CB_CALL_BY_CONTENT 2
46 #define CB_CALL_BY_VALUE 3
48 #define CB_SIZE_AUTO 0
53 #define CB_SIZE_UNSIGNED 8
57 #define CB_WORD_HASH_SIZE (1U << 11)
58 #define CB_WORD_HASH_MASK (CB_WORD_HASH_SIZE - 1U)
105 #define CB_ALPHABET_NATIVE 0
106 #define CB_ALPHABET_ASCII 1
107 #define CB_ALPHABET_EBCDIC 2
108 #define CB_ALPHABET_CUSTOM 3
127 #define CB_CONV_L_TO_R (1 << 0)
128 #define CB_CONV_CALLEE_STACK (1 << 1)
129 #define CB_CONV_NO_RET_UPD (1 << 2)
130 #define CB_CONV_STATIC_LINK (1 << 3)
131 #define CB_CONV_OPT_LINK (1 << 4)
132 #define CB_CONV_THUNK_16 (1 << 5)
133 #define CB_CONV_STDCALL (1 << 6)
151 #define CB_DEVICE_SYSIN 0
152 #define CB_DEVICE_SYSOUT 1
153 #define CB_DEVICE_SYSERR 2
154 #define CB_DEVICE_CONSOLE 3
156 #define CB_SWITCH_0 0
157 #define CB_SWITCH_1 1
158 #define CB_SWITCH_2 2
159 #define CB_SWITCH_3 3
160 #define CB_SWITCH_4 4
161 #define CB_SWITCH_5 5
162 #define CB_SWITCH_6 6
163 #define CB_SWITCH_7 7
164 #define CB_SWITCH_8 8
165 #define CB_SWITCH_9 9
166 #define CB_SWITCH_10 10
167 #define CB_SWITCH_11 11
168 #define CB_SWITCH_12 12
169 #define CB_SWITCH_13 13
170 #define CB_SWITCH_14 14
171 #define CB_SWITCH_15 15
173 #define CB_FEATURE_FORMFEED 0
174 #define CB_FEATURE_CONVENTION 1
175 #define CB_FEATURE_C01 2
176 #define CB_FEATURE_C02 3
177 #define CB_FEATURE_C03 4
178 #define CB_FEATURE_C04 5
179 #define CB_FEATURE_C05 6
180 #define CB_FEATURE_C06 7
181 #define CB_FEATURE_C07 8
182 #define CB_FEATURE_C08 9
183 #define CB_FEATURE_C09 10
184 #define CB_FEATURE_C10 11
185 #define CB_FEATURE_C11 12
186 #define CB_FEATURE_C12 13
417 #define CB_TREE(x) ((struct cb_tree_common *) (x))
418 #define CB_TREE_TAG(x) (CB_TREE (x)->tag)
419 #define CB_TREE_CLASS(x) cb_tree_class (CB_TREE (x))
420 #define CB_TREE_CATEGORY(x) cb_tree_category (CB_TREE (x))
422 #define CB_VALID_TREE(x) (x && CB_TREE (x) != cb_error_node)
423 #define CB_INVALID_TREE(x) (!(x) || CB_TREE (x) == cb_error_node)
425 #ifdef COB_TREE_DEBUG
427 #ifdef COB_HAVE_STEXPR
428 #define CB_TREE_CAST(tg,ty,x) \
431 if (unlikely(!_x || CB_TREE_TAG (_x) != tg)) { \
432 cobc_tree_cast_error (_x, __FILE__, __LINE__, tg); \
437 #define CB_TREE_CAST(tg,ty,x) \
438 ((ty *)cobc_tree_cast_check (x, __FILE__, __LINE__, tg))
442 #define CB_TREE_CAST(tg,ty,x) ((ty *) (x))
453 #define CB_CONST(x) (CB_TREE_CAST (CB_TAG_CONST, struct cb_const, x))
454 #define CB_CONST_P(x) (CB_TREE_TAG (x) == CB_TAG_CONST)
465 #define CB_DIRECT(x) (CB_TREE_CAST (CB_TAG_DIRECT, struct cb_direct, x))
466 #define CB_DIRECT_P(x) (CB_TREE_TAG (x) == CB_TAG_DIRECT)
478 #define CB_DEBUG(x) (CB_TREE_CAST (CB_TAG_DEBUG, struct cb_debug, x))
479 #define CB_DEBUG_P(x) (CB_TREE_TAG (x) == CB_TAG_DEBUG)
488 #define CB_DEBUG_CALL(x) (CB_TREE_CAST (CB_TAG_DEBUG_CALL, struct cb_debug_call, x))
489 #define CB_DEBUG_CALL_P(x) (CB_TREE_TAG (x) == CB_TAG_DEBUG_CALL)
499 #define CB_INTEGER(x) (CB_TREE_CAST (CB_TAG_INTEGER, struct cb_integer, x))
500 #define CB_INTEGER_P(x) (CB_TREE_TAG (x) == CB_TAG_INTEGER)
506 const unsigned char *
data;
510 #define CB_STRING(x) (CB_TREE_CAST (CB_TAG_STRING, struct cb_string, x))
511 #define CB_STRING_P(x) (CB_TREE_TAG (x) == CB_TAG_STRING)
527 #define CB_ALPHABET_NAME(x) (CB_TREE_CAST (CB_TAG_ALPHABET_NAME, struct cb_alphabet_name, x))
528 #define CB_ALPHABET_NAME_P(x) (CB_TREE_TAG (x) == CB_TAG_ALPHABET_NAME)
539 #define CB_CLASS_NAME(x) (CB_TREE_CAST (CB_TAG_CLASS_NAME, struct cb_class_name, x))
540 #define CB_CLASS_NAME_P(x) (CB_TREE_TAG (x) == CB_TAG_CLASS_NAME)
551 #define CB_LOCALE_NAME(x) (CB_TREE_CAST (CB_TAG_LOCALE_NAME, struct cb_locale_name, x))
552 #define CB_LOCALE_NAME_P(x) (CB_TREE_TAG (x) == CB_TAG_LOCALE_NAME)
563 #define CB_SYSTEM_NAME(x) (CB_TREE_CAST (CB_TAG_SYSTEM_NAME, struct cb_system_name, x))
564 #define CB_SYSTEM_NAME_P(x) (CB_TREE_TAG (x) == CB_TAG_SYSTEM_NAME)
578 #define CB_LITERAL(x) (CB_TREE_CAST (CB_TAG_LITERAL, struct cb_literal, x))
579 #define CB_LITERAL_P(x) (CB_TREE_TAG (x) == CB_TAG_LITERAL)
580 #define CB_NUMERIC_LITERAL_P(x) \
581 (CB_LITERAL_P (x) && CB_TREE_CATEGORY (x) == CB_CATEGORY_NUMERIC)
590 #define CB_DECIMAL(x) (CB_TREE_CAST (CB_TAG_DECIMAL, struct cb_decimal, x))
591 #define CB_DECIMAL_P(x) (CB_TREE_TAG (x) == CB_TAG_DECIMAL)
608 #define CB_PICTURE(x) (CB_TREE_CAST (CB_TAG_PICTURE, struct cb_picture, x))
609 #define CB_PICTURE_P(x) (CB_TREE_TAG (x) == CB_TAG_PICTURE)
712 #define CB_FIELD(x) (CB_TREE_CAST (CB_TAG_FIELD, struct cb_field, x))
713 #define CB_FIELD_P(x) (CB_TREE_TAG (x) == CB_TAG_FIELD)
715 #define CB_REF_OR_FIELD_P(x) (CB_REFERENCE_P (x) || CB_FIELD_P (x))
717 #define CB_FIELD_PTR(x) \
718 (CB_REFERENCE_P (x) ? CB_FIELD (cb_ref (x)) : CB_FIELD (x))
722 #define CB_INDEX_P(x) cb_check_index_p (x)
773 #define CB_LABEL(x) (CB_TREE_CAST (CB_TAG_LABEL, struct cb_label, x))
774 #define CB_LABEL_P(x) (CB_TREE_TAG (x) == CB_TAG_LABEL)
830 #define CB_FILE(x) (CB_TREE_CAST (CB_TAG_FILE, struct cb_file, x))
831 #define CB_FILE_P(x) (CB_TREE_TAG (x) == CB_TAG_FILE)
843 #define CB_WORD_TABLE_SIZE (CB_WORD_HASH_SIZE * sizeof (struct cb_word))
873 #define CB_REFERENCE(x) (CB_TREE_CAST (CB_TAG_REFERENCE, struct cb_reference, x))
874 #define CB_REFERENCE_P(x) (CB_TREE_TAG (x) == CB_TAG_REFERENCE)
876 #define CB_NAME(x) (CB_REFERENCE (x)->word->name)
877 #define CB_WORD_COUNT(x) (CB_REFERENCE (x)->word->count)
878 #define CB_WORD_ITEMS(x) (CB_REFERENCE (x)->word->items)
908 #define CB_BINARY_OP(x) (CB_TREE_CAST (CB_TAG_BINARY_OP, struct cb_binary_op, x))
909 #define CB_BINARY_OP_P(x) (CB_TREE_TAG (x) == CB_TAG_BINARY_OP)
923 #define CB_FUNCALL(x) (CB_TREE_CAST (CB_TAG_FUNCALL, struct cb_funcall, x))
924 #define CB_FUNCALL_P(x) (CB_TREE_TAG (x) == CB_TAG_FUNCALL)
934 #define CB_CAST(x) (CB_TREE_CAST (CB_TAG_CAST, struct cb_cast, x))
935 #define CB_CAST_P(x) (CB_TREE_TAG (x) == CB_TAG_CAST)
945 #define CB_ASSIGN(x) (CB_TREE_CAST (CB_TAG_ASSIGN, struct cb_assign, x))
946 #define CB_ASSIGN_P(x) (CB_TREE_TAG (x) == CB_TAG_ASSIGN)
957 const unsigned int refmod;
973 #define CB_INTRINSIC(x) (CB_TREE_CAST (CB_TAG_INTRINSIC, struct cb_intrinsic, x))
974 #define CB_INTRINSIC_P(x) (CB_TREE_TAG (x) == CB_TAG_INTRINSIC)
989 #define CB_INITIALIZE(x) (CB_TREE_CAST (CB_TAG_INITIALIZE, struct cb_initialize, x))
990 #define CB_INITIALIZE_P(x) (CB_TREE_TAG (x) == CB_TAG_INITIALIZE)
1003 #define CB_SEARCH(x) (CB_TREE_CAST (CB_TAG_SEARCH, struct cb_search, x))
1004 #define CB_SEARCH_P(x) (CB_TREE_TAG (x) == CB_TAG_SEARCH)
1019 #define CB_CALL(x) (CB_TREE_CAST (CB_TAG_CALL, struct cb_call, x))
1020 #define CB_CALL_P(x) (CB_TREE_TAG (x) == CB_TAG_CALL)
1029 #define CB_CANCEL(x) (CB_TREE_CAST (CB_TAG_CANCEL, struct cb_cancel, x))
1030 #define CB_CANCEL_P(x) (CB_TREE_TAG (x) == CB_TAG_CANCEL)
1040 #define CB_ALTER(x) (CB_TREE_CAST (CB_TAG_ALTER, struct cb_alter, x))
1041 #define CB_ALTER_P(x) (CB_TREE_TAG (x) == CB_TAG_ALTER)
1051 #define CB_GOTO(x) (CB_TREE_CAST (CB_TAG_GOTO, struct cb_goto, x))
1052 #define CB_GOTO_P(x) (CB_TREE_TAG (x) == CB_TAG_GOTO)
1064 #define CB_IF(x) (CB_TREE_CAST (CB_TAG_IF, struct cb_if, x))
1065 #define CB_IF_P(x) (CB_TREE_TAG (x) == CB_TAG_IF)
1088 #define CB_PERFORM_VARYING(x) (CB_TREE_CAST (CB_TAG_PERFORM_VARYING, struct cb_perform_varying, x))
1090 #define CB_PERFORM(x) (CB_TREE_CAST (CB_TAG_PERFORM, struct cb_perform, x))
1091 #define CB_PERFORM_P(x) (CB_TREE_TAG (x) == CB_TAG_PERFORM)
1126 #define CB_STATEMENT(x) (CB_TREE_CAST (CB_TAG_STATEMENT, struct cb_statement, x))
1127 #define CB_STATEMENT_P(x) (CB_TREE_TAG (x) == CB_TAG_STATEMENT)
1135 #define CB_CONTINUE(x) (CB_TREE_CAST (CB_TAG_CONTINUE, struct cb_continue, x))
1136 #define CB_CONTINUE_P(x) (CB_TREE_TAG (x) == CB_TAG_CONTINUE)
1147 #define CB_SET_ATTR(x) (CB_TREE_CAST (CB_TAG_SET_ATTR, struct cb_set_attr, x))
1148 #define CB_SET_ATTR_P(x) (CB_TREE_TAG (x) == CB_TAG_SET_ATTR)
1160 #define CB_LIST(x) (CB_TREE_CAST (CB_TAG_LIST, struct cb_list, x))
1161 #define CB_LIST_P(x) (CB_TREE_TAG (x) == CB_TAG_LIST)
1163 #define CB_PURPOSE(x) (CB_LIST (x)->purpose)
1164 #define CB_VALUE(x) (CB_LIST (x)->value)
1165 #define CB_CHAIN(x) (CB_LIST (x)->chain)
1166 #define CB_SIZES(x) (CB_LIST (x)->sizes)
1168 #define CB_PURPOSE_INT(x) (CB_INTEGER (CB_PURPOSE (x))->val)
1170 #define CB_SIZES_INT(x) ((CB_LIST (x)->sizes) & 0x07)
1171 #define CB_SIZES_INT_UNSIGNED(x) ((CB_LIST (x)->sizes) & CB_SIZE_UNSIGNED)
1175 #define CB_PAIR_P(x) (CB_LIST_P (x) && CB_PAIR_X (x))
1176 #define CB_PAIR_X(x) CB_PURPOSE (x)
1177 #define CB_PAIR_Y(x) CB_VALUE (x)
1199 #define CB_REPORT(x) (CB_TREE_CAST (CB_TAG_REPORT, struct cb_report, x))
1200 #define CB_REPORT_P(x) (CB_TREE_TAG (x) == CB_TAG_REPORT)
1327 extern char *
cb_name (cb_tree);
1341 extern cb_tree
cb_int (
const int);
1366 const unsigned int);
1401 extern const char *
cb_define (cb_tree, cb_tree);
1404 extern cb_tree
cb_ref (cb_tree);
1411 const cb_tree,
const cb_tree,
1412 const cb_tree,
const cb_tree,
1413 const cb_tree,
const cb_tree,
1414 const cb_tree,
const cb_tree,
1415 const cb_tree,
const cb_tree);
1425 cb_tree,
const int);
1429 const cb_tree,
const cb_tree,
1430 const cb_tree,
const cb_tree);
1433 const cb_tree,
const cb_tree,
1434 const cb_tree,
const cob_u32_t,
1441 extern cb_tree
cb_build_goto (
const cb_tree,
const cb_tree);
1443 extern cb_tree
cb_build_if (
const cb_tree,
const cb_tree,
1444 const cb_tree,
const unsigned int);
1456 extern cb_tree
cb_pair_add (cb_tree, cb_tree, cb_tree);
1478 const unsigned int);
1502 extern void cb_list_map (cb_tree (*) (cb_tree), cb_tree);
1505 extern void cb_warning_x (cb_tree,
const char *, ...) COB_A_FORMAT23;
1506 extern
void cb_error_x (cb_tree, const
char *, ...) COB_A_FORMAT23;
1554 const
unsigned int, struct cb_field *);
1569 extern cb_tree
cb_build_add (cb_tree, cb_tree, cb_tree);
1570 extern cb_tree
cb_build_sub (cb_tree, cb_tree, cb_tree);
1572 cb_tree (*) (cb_tree, cb_tree, cb_tree),
1573 cb_tree, cb_tree, cb_tree);
1601 extern
void cb_emit_call (cb_tree, cb_tree, cb_tree, cb_tree,
1612 struct cb_attr_struct *);
1628 extern
void cb_emit_if (cb_tree, cb_tree, cb_tree);
1636 cb_tree, const
unsigned int);
1652 extern
int validate_move (cb_tree, cb_tree, const
unsigned int);
1690 const
int, const
int);
1699 extern
void cb_emit_start (cb_tree, cb_tree, cb_tree, cb_tree);
1712 extern
void cb_emit_write (cb_tree, cb_tree, cb_tree, cb_tree);
1719 const enum
cb_tag) COB_A_NORETURN;
1721 #if !defined(__GNUC__) && defined(COB_TREE_DEBUG)
1722 extern cb_tree cobc_tree_cast_check (
const cb_tree,
const char *,
1723 const int,
const enum cb_tag);
1728 extern void codegen (
struct cb_program *,
const int);
1732 extern void cb_add_78 (
struct cb_field *);
1739 #define CB_BUILD_FUNCALL_0(f) \
1740 cb_build_funcall (f, 0, NULL, NULL, NULL, NULL, NULL, \
1741 NULL, NULL, NULL, NULL, NULL)
1743 #define CB_BUILD_FUNCALL_1(f,a1) \
1744 cb_build_funcall (f, 1, a1, NULL, NULL, NULL, NULL, \
1745 NULL, NULL, NULL, NULL, NULL)
1747 #define CB_BUILD_FUNCALL_2(f,a1,a2) \
1748 cb_build_funcall (f, 2, a1, a2, NULL, NULL, NULL, \
1749 NULL, NULL, NULL, NULL, NULL)
1751 #define CB_BUILD_FUNCALL_3(f,a1,a2,a3) \
1752 cb_build_funcall (f, 3, a1, a2, a3, NULL, NULL, \
1753 NULL, NULL, NULL, NULL, NULL)
1755 #define CB_BUILD_FUNCALL_4(f,a1,a2,a3,a4) \
1756 cb_build_funcall (f, 4, a1, a2, a3, a4, NULL, \
1757 NULL, NULL, NULL, NULL, NULL)
1759 #define CB_BUILD_FUNCALL_5(f,a1,a2,a3,a4,a5) \
1760 cb_build_funcall (f, 5, a1, a2, a3, a4, a5, \
1761 NULL, NULL, NULL, NULL, NULL)
1763 #define CB_BUILD_FUNCALL_6(f,a1,a2,a3,a4,a5,a6) \
1764 cb_build_funcall (f, 6, a1, a2, a3, a4, a5, a6, \
1765 NULL, NULL, NULL, NULL)
1767 #define CB_BUILD_FUNCALL_7(f,a1,a2,a3,a4,a5,a6,a7) \
1768 cb_build_funcall (f, 7, a1, a2, a3, a4, a5, a6, a7, \
1771 #define CB_BUILD_FUNCALL_8(f,a1,a2,a3,a4,a5,a6,a7,a8) \
1772 cb_build_funcall (f, 8, a1, a2, a3, a4, a5, a6, a7, a8, \
1775 #define CB_BUILD_FUNCALL_9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
1776 cb_build_funcall (f, 9, a1, a2, a3, a4, a5, a6, a7, a8, \
1781 #define CB_BUILD_CAST_ADDRESS(x) cb_build_cast (CB_CAST_ADDRESS, x)
1782 #define CB_BUILD_CAST_ADDR_OF_ADDR(x) cb_build_cast (CB_CAST_ADDR_OF_ADDR, x)
1783 #define CB_BUILD_CAST_LENGTH(x) cb_build_cast (CB_CAST_LENGTH, x)
1784 #define CB_BUILD_CAST_PPOINTER(x) cb_build_cast (CB_CAST_PROGRAM_POINTER, x)
1786 #define CB_BUILD_PARENTHESIS(x) cb_build_binary_op (x, '@', NULL)
1787 #define CB_BUILD_NEGATION(x) cb_build_binary_op (x, '!', NULL)
1789 #define CB_BUILD_STRING0(str) cb_build_string (str, strlen ((char *)(str)))
1791 #define CB_LIST_INIT(x) cb_build_list (NULL, x, NULL)
1792 #define CB_BUILD_CHAIN(x,y) cb_build_list (NULL, x, y)
1793 #define CB_BUILD_PAIR(x,y) cb_build_list (x, y, NULL)
1794 #define CB_ADD_TO_CHAIN(x,y) y = CB_BUILD_CHAIN (x, y)
1795 #define CB_CHAIN_PAIR(x,y,z) x = cb_pair_add (x, y, z)
1796 #define CB_FIELD_ADD(x,y) x = cb_field_add (x, y)