Skip to content

Commit

Permalink
Merge SVN 5037
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Nov 18, 2024
1 parent 75ef94d commit 9b8f7de
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 39 deletions.
12 changes: 12 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
* typeck.c (cb_emit_sort_init): generate call to cob_file_sort_options
* help.c (cobc_print_usage_dialect): extended -fregister help

2023-05-09 Simon Sobisch <[email protected]>

* codegen.c (output_funcall): backup and restore adjusted static fields,
minor refactoring
* codegen.c (output_funcall_item): extracted from (output_funcall)

2023-05-08 Simon Sobisch <[email protected]>

* tree.c (cb_build_funcall), tree.h (struct cb_funcall): defined
max. parameters for internal function calls as CB_BUILD_FUNCALL_MAX
and increased it to 14

2023-05-05 Simon Sobisch <[email protected]>

* field.c (cb_resolve_redefines): fix #881 wrong REDEFINES error on
Expand Down
5 changes: 3 additions & 2 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2119,14 +2119,15 @@ set_compile_date (void)
{
static int sde_todo = 0;
if (sde_todo == 0) {
char *s = getenv ("SOURCE_DATE_EPOCH");
unsigned char *s = (unsigned char *) getenv ("SOURCE_DATE_EPOCH");
sde_todo = 1;
if (s && *s) {
if (cob_set_date_from_epoch (&current_compile_time, s) == 0) {
set_compile_date_tm ();
return;
}
cobc_err_msg (_("environment variable '%s' has invalid content"), "SOURCE_DATE_EPOCH");
cobc_err_msg (_("environment variable '%s' has invalid content"),
"SOURCE_DATE_EPOCH");
if (!cb_flag_syntax_only) {
cb_source_file = NULL;
cobc_abort_terminate (0);
Expand Down
45 changes: 24 additions & 21 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -4847,12 +4847,26 @@ output_funcall_typed (struct cb_funcall *p, const char type)
}


static void COB_INLINE COB_A_INLINE
output_funcall_item (cb_tree x, const int i, unsigned int func_nolitcast)
{
if (x && CB_LITERAL_P (x)) {
nolitcast = func_nolitcast;
} else {
nolitcast = 0;
}
output_param (x, i);
}


static void
output_funcall (cb_tree x)
{
struct cb_funcall *p;
cb_tree l;
int i;
const int nolitcast_origin = nolitcast;
const int screenptr_origin = screenptr;

p = CB_FUNCALL (x);
if (p->name[0] == '$') {
Expand All @@ -4863,33 +4877,22 @@ output_funcall (cb_tree x)
screenptr = p->screenptr;
output ("%s (", p->name);
for (i = 0; i < p->argc; i++) {
if (i) {
output (", ");
}
if (p->varcnt && i + 1 == p->argc) {
output ("%d, ", p->varcnt);
for (l = p->argv[i]; l; l = CB_CHAIN (l)) {
if (CB_VALUE (l) && CB_LITERAL_P (CB_VALUE (l))) {
nolitcast = p->nolitcast;
}
output_param (CB_VALUE (l), i);
nolitcast = 0;
i++;
if (CB_CHAIN (l)) {
output (", ");
}
}
} else {
if (p->argv[i] && CB_LITERAL_P (p->argv[i])) {
nolitcast = p->nolitcast;
}
output_param (p->argv[i], i);
nolitcast = 0;
if (i + 1 < p->argc) {
output ("%d", p->varcnt);
for (l = p->argv[i]; l; l = CB_CHAIN (l), i++) {
output (", ");
output_funcall_item (CB_VALUE (l), i, p->nolitcast);
}
} else {
output_funcall_item (p->argv[i], i, p->nolitcast);
}
}
output (")");
nolitcast = 0;
screenptr = 0;
nolitcast = nolitcast_origin;
screenptr = screenptr_origin;
}

static void
Expand Down
6 changes: 5 additions & 1 deletion cobc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6832,7 +6832,8 @@ cb_build_funcall (const char *name, const int argc,
const cb_tree a1, const cb_tree a2, const cb_tree a3,
const cb_tree a4, const cb_tree a5, const cb_tree a6,
const cb_tree a7, const cb_tree a8, const cb_tree a9,
const cb_tree a10, const cb_tree a11)
const cb_tree a10, const cb_tree a11, const cb_tree a12,
const cb_tree a13, const cb_tree a14)
{
struct cb_funcall *p;

Expand All @@ -6853,6 +6854,9 @@ cb_build_funcall (const char *name, const int argc,
p->argv[8] = a9;
p->argv[9] = a10;
p->argv[10] = a11;
p->argv[11] = a12;
p->argv[12] = a13;
p->argv[13] = a14;
return CB_TREE (p);
}

Expand Down
50 changes: 35 additions & 15 deletions cobc/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ struct cb_field {
cb_tree screen_foreg; /* FOREGROUND */
cb_tree screen_backg; /* BACKGROUND */
cb_tree screen_prompt; /* PROMPT */
cb_tree screen_control; /* CONTROL identifier (variable named attributes) */
cb_tree screen_color; /* COLOR identifier (variable bit-shifted attributes) */
cb_tree report_source; /* SOURCE field */
cb_tree report_from; /* SOURCE field subscripted; so MOVE to report_source */
cb_tree report_sum_counter;/* SUM counter */
Expand Down Expand Up @@ -1316,10 +1318,11 @@ struct cb_binary_op {

/* Function call */

#define CB_BUILD_FUNCALL_MAX 14
struct cb_funcall {
struct cb_tree_common common; /* Common values */
const char *name; /* Function name */
cb_tree argv[11]; /* Function arguments */
cb_tree argv[CB_BUILD_FUNCALL_MAX]; /* Function arguments */
int argc; /* Number of arguments */
int varcnt; /* Variable argument count */
unsigned int screenptr; /* SCREEN usage */
Expand Down Expand Up @@ -1529,6 +1532,9 @@ struct cb_attr_struct {
cb_tree timeout; /* TIMEOUT */
cb_tree prompt; /* PROMPT */
cb_tree size_is; /* [PROTECTED] SIZE [IS] */
cb_tree control; /* CONTROL [IS] (named attributes) */
cb_tree color; /* CONTROL (bit-shifted attributes) */
cb_tree cursor; /* CURSOR */
cob_flags_t dispattrs; /* Attributes */
};

Expand Down Expand Up @@ -1861,7 +1867,8 @@ struct cb_program {
when cb_correct_program_order is set */
const char *program_name; /* Internal program-name */
const char *program_id; /* Demangled external PROGRAM-ID */
char *source_name; /* Source name */
char *source_name; /* Source name,
only set in the first "real" program */
char *orig_program_id; /* Original external PROGRAM-ID */
struct cb_word **word_table; /* Name hash table */
struct local_filename *local_include; /* Local include info */
Expand Down Expand Up @@ -2197,7 +2204,8 @@ extern cb_tree cb_build_funcall (const char *, const int,
const cb_tree, const cb_tree,
const cb_tree, const cb_tree,
const cb_tree, const cb_tree,
const cb_tree);
const cb_tree, const cb_tree,
const cb_tree, const cb_tree);

extern cb_tree cb_build_cast (const enum cb_cast_type,
const cb_tree);
Expand Down Expand Up @@ -2691,51 +2699,63 @@ extern int cobc_has_areacheck_directive (const char *directive);

#define CB_BUILD_FUNCALL_0(f) \
cb_build_funcall (f, 0, NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_1(f,a1) \
cb_build_funcall (f, 1, a1, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_2(f,a1,a2) \
cb_build_funcall (f, 2, a1, a2, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_3(f,a1,a2,a3) \
cb_build_funcall (f, 3, a1, a2, a3, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_4(f,a1,a2,a3,a4) \
cb_build_funcall (f, 4, a1, a2, a3, a4, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_5(f,a1,a2,a3,a4,a5) \
cb_build_funcall (f, 5, a1, a2, a3, a4, a5, \
NULL, NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_6(f,a1,a2,a3,a4,a5,a6) \
cb_build_funcall (f, 6, a1, a2, a3, a4, a5, a6, \
NULL, NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_7(f,a1,a2,a3,a4,a5,a6,a7) \
cb_build_funcall (f, 7, a1, a2, a3, a4, a5, a6, a7, \
NULL, NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_8(f,a1,a2,a3,a4,a5,a6,a7,a8) \
cb_build_funcall (f, 8, a1, a2, a3, a4, a5, a6, a7, a8, \
NULL, NULL, NULL)
NULL, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
cb_build_funcall (f, 9, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, NULL, NULL)
a9, NULL, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
cb_build_funcall (f, 10, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, a10, NULL)
a9, a10, NULL, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_11(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
cb_build_funcall (f, 11, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, a10, a11)
a9, a10, a11, NULL, NULL, NULL)

#define CB_BUILD_FUNCALL_12(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a11,a12) \
cb_build_funcall (f, 9, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, a10, a11, a12, NULL, NULL)

#define CB_BUILD_FUNCALL_13(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
cb_build_funcall (f, 10, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, a10, a11, a12, a13, NULL)

#define CB_BUILD_FUNCALL_14(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
cb_build_funcall (f, 11, a1, a2, a3, a4, a5, a6, a7, a8, \
a9, a10, a11, a12, a13, a14)

/* Miscellaneous defines */

Expand Down

0 comments on commit 9b8f7de

Please sign in to comment.