GnuCOBOL  2.0
A free COBOL compiler
typeck.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include "cobc.h"
#include "tree.h"
#include "libcob/system.def"
Include dependency graph for typeck.c:

Go to the source code of this file.

Data Structures

struct  system_table
 
struct  optim_table
 
struct  expr_node
 

Macros

#define START_STACK_SIZE   32
 
#define TOKEN(offset)   (expr_stack[expr_index + offset].token)
 
#define VALUE(offset)   (expr_stack[expr_index + offset].value)
 
#define dpush(x)   CB_ADD_TO_CHAIN (x, decimal_stack)
 
#define cb_emit(x)   current_statement->body = cb_list_add (current_statement->body, x)
 
#define cb_emit_list(l)   current_statement->body = cb_list_append (current_statement->body, l)
 
#define COB_SYSTEM_GEN(x, y, z)   { x, y },
 

Functions

static cb_tree cb_check_needs_break (cb_tree stmt)
 
static size_t cb_validate_one (cb_tree x)
 
static size_t cb_validate_list (cb_tree l)
 
static cb_tree cb_check_group_name (cb_tree x)
 
static cb_tree cb_check_numeric_name (cb_tree x)
 
static cb_tree cb_check_numeric_edited_name (cb_tree x)
 
cb_tree cb_check_numeric_value (cb_tree x)
 
static cb_tree cb_check_integer_value (cb_tree x)
 
static void cb_check_data_incompat (cb_tree x)
 
static void cb_check_lit_subs (struct cb_reference *r, const int numsubs, const int numindex)
 
static int cb_field_size (const cb_tree x)
 
void cb_list_system (void)
 
size_t cb_check_index_p (cb_tree x)
 
void cb_check_field_debug (cb_tree fld)
 
void cb_build_registers (void)
 
char * cb_encode_program_id (const char *name)
 
char * cb_build_program_id (cb_tree name, cb_tree alt_name, const cob_u32_t is_func)
 
cb_tree cb_define_switch_name (cb_tree name, cb_tree sname, const int flag)
 
cb_tree cb_build_section_name (cb_tree name, const int sect_or_para)
 
cb_tree cb_build_assignment_name (struct cb_file *cfile, cb_tree name)
 
cb_tree cb_build_index (cb_tree x, cb_tree values, const unsigned int indexed_by, struct cb_field *qual)
 
cb_tree cb_build_address (cb_tree x)
 
cb_tree cb_build_identifier (cb_tree x, const int subchk)
 
static cb_tree cb_build_length_1 (cb_tree x)
 
cb_tree cb_build_const_length (cb_tree x)
 
cb_tree cb_build_length (cb_tree x)
 
cb_tree cb_build_ppointer (cb_tree x)
 
static int get_value (cb_tree x)
 
static void cb_validate_collating (struct cb_program *prog)
 
void cb_validate_program_environment (struct cb_program *prog)
 
void cb_build_debug_item (void)
 
void cb_validate_program_data (struct cb_program *prog)
 
void cb_validate_program_body (struct cb_program *prog)
 
static void cb_expr_init (void)
 
static int expr_chk_cond (cb_tree expr_1, cb_tree expr_2)
 
static int expr_reduce (int token)
 
static void cb_expr_shift_sign (const int op)
 
static void cb_expr_shift_class (const char *name)
 
static void cb_expr_shift (int token, cb_tree value)
 
static void expr_expand (cb_tree *x)
 
static cb_tree cb_expr_finish (void)
 
cb_tree cb_build_expr (cb_tree list)
 
static cb_tree build_store_option (cb_tree x, cb_tree round_opt)
 
static cb_tree decimal_alloc (void)
 
static void decimal_free (void)
 
static void decimal_compute (const int op, cb_tree x, cb_tree y)
 
static void decimal_expand (cb_tree d, cb_tree x)
 
static void decimal_assign (cb_tree x, cb_tree d, cb_tree round_opt)
 
static cb_tree cb_build_mul (cb_tree v, cb_tree n, cb_tree round_opt)
 
static cb_tree cb_build_div (cb_tree v, cb_tree n, cb_tree round_opt)
 
static cb_tree build_decimal_assign (cb_tree vars, const int op, cb_tree val)
 
void cb_emit_arithmetic (cb_tree vars, const int op, cb_tree val)
 
static cb_tree build_cond_88 (cb_tree x)
 
static cb_tree cb_build_optim_cond (struct cb_binary_op *p)
 
static int cb_chk_num_cond (cb_tree x, cb_tree y)
 
static int cb_chk_alpha_cond (cb_tree x)
 
cb_tree cb_build_cond (cb_tree x)
 
static cb_tree cb_build_optim_add (cb_tree v, cb_tree n)
 
static cb_tree cb_build_optim_sub (cb_tree v, cb_tree n)
 
cb_tree cb_build_add (cb_tree v, cb_tree n, cb_tree round_opt)
 
cb_tree cb_build_sub (cb_tree v, cb_tree n, cb_tree round_opt)
 
static unsigned int emit_corresponding (cb_tree(*func)(cb_tree f1, cb_tree f2, cb_tree f3), cb_tree x1, cb_tree x2, cb_tree opt)
 
void cb_emit_corresponding (cb_tree(*func)(cb_tree f1, cb_tree f2, cb_tree f3), cb_tree x1, cb_tree x2, cb_tree opt)
 
static unsigned int emit_move_corresponding (cb_tree x1, cb_tree x2)
 
void cb_emit_move_corresponding (cb_tree x1, cb_tree x2)
 
static void output_screen_from (struct cb_field *p, const unsigned int sisters)
 
static void output_screen_to (struct cb_field *p, const unsigned int sisters)
 
static COB_INLINE COB_A_INLINE int is_less_than_four_or_is_six (int x)
 
static COB_INLINE COB_A_INLINE int is_reference_with_value (cb_tree pos)
 
static COB_INLINE COB_A_INLINE int value_is_numeric_field (cb_tree pos)
 
static COB_INLINE COB_A_INLINE int value_has_picture_clause (cb_tree pos)
 
static COB_INLINE COB_A_INLINE int value_pic_has_no_scale (cb_tree pos)
 
static int valid_screen_pos_type (cb_tree pos)
 
static int valid_screen_pos (cb_tree pos)
 
static void cb_gen_field_accept (cb_tree var, cb_tree pos, cb_tree fgc, cb_tree bgc, cb_tree scroll, cb_tree timeout, cb_tree prompt, cb_tree size_is, int dispattrs)
 
void cb_emit_accept (cb_tree var, cb_tree pos, struct cb_attr_struct *attr_ptr)
 
void cb_emit_accept_line_or_col (cb_tree var, const int l_or_c)
 
void cb_emit_accept_escape_key (cb_tree var)
 
void cb_emit_accept_exception_status (cb_tree var)
 
void cb_emit_accept_user_name (cb_tree var)
 
void cb_emit_accept_date (cb_tree var)
 
void cb_emit_accept_date_yyyymmdd (cb_tree var)
 
void cb_emit_accept_day (cb_tree var)
 
void cb_emit_accept_day_yyyyddd (cb_tree var)
 
void cb_emit_accept_day_of_week (cb_tree var)
 
void cb_emit_accept_time (cb_tree var)
 
void cb_emit_accept_command_line (cb_tree var)
 
void cb_emit_get_environment (cb_tree envvar, cb_tree envval)
 
void cb_emit_accept_environment (cb_tree var)
 
void cb_emit_accept_arg_number (cb_tree var)
 
void cb_emit_accept_arg_value (cb_tree var)
 
void cb_emit_accept_mnemonic (cb_tree var, cb_tree mnemonic)
 
void cb_emit_accept_name (cb_tree var, cb_tree name)
 
void cb_emit_allocate (cb_tree target1, cb_tree target2, cb_tree size, cb_tree initialize)
 
void cb_emit_alter (cb_tree source, cb_tree target)
 
void cb_emit_call (cb_tree prog, cb_tree par_using, cb_tree returning, cb_tree on_exception, cb_tree not_on_exception, cb_tree convention)
 
void cb_emit_cancel (cb_tree prog)
 
void cb_emit_close (cb_tree file, cb_tree opt)
 
void cb_emit_commit (void)
 
void cb_emit_continue (void)
 
void cb_emit_delete (cb_tree file)
 
void cb_emit_delete_file (cb_tree file)
 
void cb_emit_env_name (cb_tree value)
 
void cb_emit_env_value (cb_tree value)
 
void cb_emit_arg_number (cb_tree value)
 
void cb_emit_command_line (cb_tree value)
 
static int validate_attrs (cb_tree pos, cb_tree fgc, cb_tree bgc, cb_tree scroll, cb_tree size_is)
 
static void initialize_attrs (const struct cb_attr_struct *const attr_ptr, cb_tree *const fgc, cb_tree *const bgc, cb_tree *const scroll, cb_tree *const size_is, int *const dispattrs)
 
static void get_line_and_column_from_pos (const cb_tree pos, cb_tree *const line, cb_tree *const column)
 
static void emit_screen_display (const cb_tree x, const cb_tree pos)
 
static void emit_field_display (const cb_tree x, const cb_tree pos, const cb_tree fgc, const cb_tree bgc, const cb_tree scroll, const cb_tree size_is, const int dispattrs)
 
void cb_emit_display_omitted (cb_tree pos, struct cb_attr_struct *attr_ptr)
 
void cb_emit_display (cb_tree values, cb_tree upon, cb_tree no_adv, cb_tree pos, struct cb_attr_struct *attr_ptr)
 
cb_tree cb_build_display_mnemonic (cb_tree x)
 
cb_tree cb_build_display_name (cb_tree x)
 
void cb_emit_divide (cb_tree dividend, cb_tree divisor, cb_tree quotient, cb_tree remainder)
 
static cb_tree evaluate_test (cb_tree s, cb_tree o)
 
static void build_evaluate (cb_tree subject_list, cb_tree case_list, cb_tree labid)
 
void cb_emit_evaluate (cb_tree subject_list, cb_tree case_list)
 
void cb_emit_free (cb_tree vars)
 
void cb_emit_goto (cb_tree target, cb_tree depending)
 
void cb_emit_exit (const unsigned int goback)
 
void cb_emit_if (cb_tree cond, cb_tree stmt1, cb_tree stmt2)
 
cb_tree cb_build_if_check_break (cb_tree cond, cb_tree stmts)
 
void cb_emit_initialize (cb_tree vars, cb_tree fillinit, cb_tree value, cb_tree replacing, cb_tree def)
 
static void validate_inspect (cb_tree x, cb_tree y, const unsigned int replconv)
 
void cb_emit_inspect (cb_tree var, cb_tree body, cb_tree replacing, const unsigned int replconv)
 
void cb_init_tallying (void)
 
cb_tree cb_build_tallying_data (cb_tree x)
 
cb_tree cb_build_tallying_characters (cb_tree l)
 
cb_tree cb_build_tallying_all (void)
 
cb_tree cb_build_tallying_leading (void)
 
cb_tree cb_build_tallying_trailing (void)
 
cb_tree cb_build_tallying_value (cb_tree x, cb_tree l)
 
cb_tree cb_build_replacing_characters (cb_tree x, cb_tree l)
 
cb_tree cb_build_replacing_all (cb_tree x, cb_tree y, cb_tree l)
 
cb_tree cb_build_replacing_leading (cb_tree x, cb_tree y, cb_tree l)
 
cb_tree cb_build_replacing_first (cb_tree x, cb_tree y, cb_tree l)
 
cb_tree cb_build_replacing_trailing (cb_tree x, cb_tree y, cb_tree l)
 
cb_tree cb_build_converting (cb_tree x, cb_tree y, cb_tree l)
 
cb_tree cb_build_inspect_region_start (void)
 
static void warning_destination (cb_tree x)
 
static void move_warning (cb_tree src, cb_tree dst, const unsigned int value_flag, const int flag, const int src_flag, const char *msg)
 
static int count_pic_alphanumeric_edited (struct cb_field *field)
 
static size_t cb_check_overlapping (cb_tree src, cb_tree dst, struct cb_field *src_f, struct cb_field *dst_f)
 
int validate_move (cb_tree src, cb_tree dst, const unsigned int is_value)
 
static cb_tree cb_build_memset (cb_tree x, const int c)
 
static cb_tree cb_build_move_copy (cb_tree src, cb_tree dst)
 
static cb_tree cb_build_move_num_zero (cb_tree x)
 
static cb_tree cb_build_move_space (cb_tree x)
 
static cb_tree cb_build_move_zero (cb_tree x)
 
static cb_tree cb_build_move_high (cb_tree x)
 
static cb_tree cb_build_move_low (cb_tree x)
 
static cb_tree cb_build_move_quote (cb_tree x)
 
static void cob_put_sign_ebcdic (unsigned char *p, const int sign)
 
static cb_tree cb_build_move_literal (cb_tree src, cb_tree dst)
 
static cb_tree cb_build_move_field (cb_tree src, cb_tree dst)
 
cb_tree cb_build_move (cb_tree src, cb_tree dst)
 
void cb_emit_move (cb_tree src, cb_tree dsts)
 
void cb_emit_open (cb_tree file, cb_tree mode, cb_tree sharing)
 
void cb_emit_perform (cb_tree perform, cb_tree body)
 
cb_tree cb_build_perform_once (cb_tree body)
 
cb_tree cb_build_perform_times (cb_tree times)
 
cb_tree cb_build_perform_until (cb_tree condition, cb_tree varying)
 
cb_tree cb_build_perform_forever (cb_tree body)
 
cb_tree cb_build_perform_exit (struct cb_label *label)
 
void cb_emit_read (cb_tree ref, cb_tree next, cb_tree into, cb_tree key, cb_tree lock_opts)
 
void cb_emit_ready_trace (void)
 
void cb_emit_reset_trace (void)
 
void cb_emit_rewrite (cb_tree record, cb_tree from, cb_tree lockopt)
 
void cb_emit_release (cb_tree record, cb_tree from)
 
void cb_emit_return (cb_tree ref, cb_tree into)
 
void cb_emit_rollback (void)
 
static unsigned int search_set_keys (struct cb_field *f, cb_tree x)
 
static cb_tree cb_build_search_all (cb_tree table, cb_tree cond)
 
void cb_emit_search (cb_tree table, cb_tree varying, cb_tree at_end, cb_tree whens)
 
void cb_emit_search_all (cb_tree table, cb_tree at_end, cb_tree when, cb_tree stmts)
 
void cb_emit_setenv (cb_tree x, cb_tree y)
 
void cb_emit_set_to (cb_tree vars, cb_tree x)
 
void cb_emit_set_up_down (cb_tree l, cb_tree flag, cb_tree x)
 
void cb_emit_set_on_off (cb_tree l, cb_tree flag)
 
void cb_emit_set_true (cb_tree l)
 
void cb_emit_set_false (cb_tree l)
 
void cb_emit_set_attribute (cb_tree x, const int val_on, const int val_off)
 
void cb_emit_set_last_exception_to_off (void)
 
void cb_emit_sort_init (cb_tree name, cb_tree keys, cb_tree col)
 
void cb_emit_sort_using (cb_tree file, cb_tree l)
 
void cb_emit_sort_input (cb_tree proc)
 
void cb_emit_sort_giving (cb_tree file, cb_tree l)
 
void cb_emit_sort_output (cb_tree proc)
 
void cb_emit_sort_finish (cb_tree file)
 
static unsigned int check_valid_key (const struct cb_file *cbf, const struct cb_field *f)
 
void cb_emit_start (cb_tree file, cb_tree op, cb_tree key, cb_tree keylen)
 
void cb_emit_stop_run (cb_tree x)
 
void cb_emit_string (cb_tree items, cb_tree into, cb_tree pointer)
 
void cb_emit_unlock (cb_tree ref)
 
void cb_emit_unstring (cb_tree name, cb_tree delimited, cb_tree into, cb_tree pointer, cb_tree tallying)
 
cb_tree cb_build_unstring_delimited (cb_tree all, cb_tree value)
 
cb_tree cb_build_unstring_into (cb_tree name, cb_tree delimiter, cb_tree count)
 
void cb_emit_write (cb_tree record, cb_tree from, cb_tree opt, cb_tree lockopt)
 
cb_tree cb_build_write_advancing_lines (cb_tree pos, cb_tree lines)
 
cb_tree cb_build_write_advancing_mnemonic (cb_tree pos, cb_tree mnemonic)
 
cb_tree cb_build_write_advancing_page (cb_tree pos)
 
void cobc_init_typeck (void)
 

Variables

cb_tree cb_debug_item
 
cb_tree cb_debug_line
 
cb_tree cb_debug_name
 
cb_tree cb_debug_sub_1
 
cb_tree cb_debug_sub_2
 
cb_tree cb_debug_sub_3
 
cb_tree cb_debug_contents
 
size_t suppress_warn = 0
 
static cb_tree decimal_stack = ((void*)0)
 
static const char * inspect_func
 
static cb_tree inspect_data
 
static int expr_op
 
static cb_tree expr_lh
 
static size_t initialized = 0
 
static size_t overlapping = 0
 
static int expr_index
 
static int expr_stack_size
 
static struct expr_nodeexpr_stack
 
static const unsigned char hexval [] = "0123456789ABCDEF"
 
static unsigned char expr_prio [256]
 
static unsigned char valid_char [256]
 
static const unsigned char pvalid_char []
 
static const unsigned char cob_refer_ascii [256]
 
static const unsigned char cob_refer_ebcdic [256]
 
static const struct system_table system_tab []
 
static const struct optim_table bin_set_funcs []
 
static const struct optim_table bin_compare_funcs []
 
static const struct optim_table bin_add_funcs []
 
static const struct optim_table bin_sub_funcs []
 

Macro Definition Documentation

#define cb_emit (   x)    current_statement->body = cb_list_add (current_statement->body, x)

Definition at line 75 of file typeck.c.

Referenced by build_evaluate(), cb_build_length(), cb_check_data_incompat(), cb_emit_accept(), cb_emit_accept_arg_number(), cb_emit_accept_arg_value(), cb_emit_accept_command_line(), cb_emit_accept_date(), cb_emit_accept_date_yyyymmdd(), cb_emit_accept_day(), cb_emit_accept_day_of_week(), cb_emit_accept_day_yyyyddd(), cb_emit_accept_environment(), cb_emit_accept_escape_key(), cb_emit_accept_exception_status(), cb_emit_accept_line_or_col(), cb_emit_accept_mnemonic(), cb_emit_accept_name(), cb_emit_accept_time(), cb_emit_accept_user_name(), cb_emit_allocate(), cb_emit_alter(), cb_emit_arg_number(), cb_emit_call(), cb_emit_cancel(), cb_emit_close(), cb_emit_command_line(), cb_emit_commit(), cb_emit_continue(), cb_emit_delete(), cb_emit_delete_file(), cb_emit_display(), cb_emit_divide(), cb_emit_env_name(), cb_emit_env_value(), cb_emit_evaluate(), cb_emit_exit(), cb_emit_free(), cb_emit_get_environment(), cb_emit_goto(), cb_emit_if(), cb_emit_initialize(), cb_emit_inspect(), cb_emit_move(), cb_emit_open(), cb_emit_perform(), cb_emit_read(), cb_emit_ready_trace(), cb_emit_release(), cb_emit_reset_trace(), cb_emit_return(), cb_emit_rewrite(), cb_emit_rollback(), cb_emit_search(), cb_emit_search_all(), cb_emit_set_attribute(), cb_emit_set_false(), cb_emit_set_last_exception_to_off(), cb_emit_set_on_off(), cb_emit_set_to(), cb_emit_set_true(), cb_emit_set_up_down(), cb_emit_setenv(), cb_emit_sort_finish(), cb_emit_sort_giving(), cb_emit_sort_init(), cb_emit_sort_input(), cb_emit_sort_output(), cb_emit_sort_using(), cb_emit_start(), cb_emit_stop_run(), cb_emit_string(), cb_emit_unlock(), cb_emit_unstring(), cb_emit_write(), cb_gen_field_accept(), decimal_expand(), emit_corresponding(), emit_field_display(), emit_move_corresponding(), emit_screen_display(), output_screen_from(), and output_screen_to().

#define cb_emit_list (   l)    current_statement->body = cb_list_append (current_statement->body, l)

Definition at line 77 of file typeck.c.

Referenced by cb_emit_arithmetic(), cb_emit_inspect(), and cb_emit_unstring().

#define COB_SYSTEM_GEN (   x,
  y,
 
)    { x, y },

Definition at line 280 of file typeck.c.

#define dpush (   x)    CB_ADD_TO_CHAIN (x, decimal_stack)

Definition at line 73 of file typeck.c.

Referenced by cb_build_cond(), decimal_assign(), decimal_compute(), and decimal_expand().

#define START_STACK_SIZE   32

Definition at line 69 of file typeck.c.

Referenced by cb_expr_init().

#define TOKEN (   offset)    (expr_stack[expr_index + offset].token)

Definition at line 70 of file typeck.c.

Referenced by cb_expr_shift(), cb_expr_shift_class(), cb_expr_shift_sign(), expr_reduce(), and pplex().

#define VALUE (   offset)    (expr_stack[expr_index + offset].value)

Definition at line 71 of file typeck.c.

Referenced by cb_expr_shift(), cb_expr_shift_class(), cb_expr_shift_sign(), and expr_reduce().

Function Documentation

static cb_tree build_cond_88 ( cb_tree  x)
static

Definition at line 3519 of file typeck.c.

References cb_build_binary_op(), cb_build_field_reference(), CB_CHAIN, cb_error_node, CB_FIELD_PTR, CB_PAIR_P, CB_PAIR_X, CB_PAIR_Y, CB_VALUE, cb_field::count, NULL, cb_field::parent, and cb_field::values.

Referenced by cb_build_cond(), and search_set_keys().

3520 {
3521  struct cb_field *f;
3522  cb_tree l;
3523  cb_tree t;
3524  cb_tree c1;
3525  cb_tree c2;
3526 
3527  f = CB_FIELD_PTR (x);
3528  /* Refer to parents data storage */
3529  if (!f->parent) {
3530  /* Field is invalid */
3531  return cb_error_node;
3532  }
3533  x = cb_build_field_reference (f->parent, x);
3534  f->parent->count++;
3535  c1 = NULL;
3536 
3537  /* Build condition */
3538  for (l = f->values; l; l = CB_CHAIN (l)) {
3539  t = CB_VALUE (l);
3540  if (CB_PAIR_P (t)) {
3541  /* VALUE THRU VALUE */
3542  c2 = cb_build_binary_op (cb_build_binary_op (CB_PAIR_X (t), '[', x),
3543  '&', cb_build_binary_op (x, '[', CB_PAIR_Y (t)));
3544  } else {
3545  /* VALUE */
3546  c2 = cb_build_binary_op (x, '=', t);
3547  }
3548  if (c1 == NULL) {
3549  c1 = c2;
3550  } else {
3551  c1 = cb_build_binary_op (c1, '|', c2);
3552  }
3553  }
3554  return c1;
3555 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_PAIR_P(x)
Definition: tree.h:1204
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
#define CB_PAIR_Y(x)
Definition: tree.h:1206
#define CB_VALUE(x)
Definition: tree.h:1193
Definition: tree.h:643
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
int count
Definition: tree.h:680
cb_tree cb_error_node
Definition: tree.c:140
struct cb_field * parent
Definition: tree.h:651
cb_tree values
Definition: tree.h:648
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree build_decimal_assign ( cb_tree  vars,
const int  op,
cb_tree  val 
)
static

Definition at line 3412 of file typeck.c.

References CB_CHAIN, cb_list_append(), cb_list_reverse(), CB_PURPOSE, CB_VALUE, decimal_alloc(), decimal_assign(), decimal_compute(), decimal_expand(), decimal_free(), and NULL.

Referenced by cb_emit_arithmetic().

3413 {
3414  cb_tree l;
3415  cb_tree t;
3416  cb_tree s1;
3417  cb_tree s2;
3418  cb_tree d;
3419 
3420  d = decimal_alloc ();
3421 
3422  /* Set d, VAL */
3423  decimal_expand (d, val);
3424 
3425  s1 = NULL;
3426  if (op == 0) {
3427  for (l = vars; l; l = CB_CHAIN (l)) {
3428  /* Set VAR, d */
3429  decimal_assign (CB_VALUE (l), d, CB_PURPOSE (l));
3431  if (!s1) {
3432  s1 = s2;
3433  } else {
3434  s1 = cb_list_append (s1, s2);
3435  }
3436  decimal_stack = NULL;
3437  }
3438  } else {
3439  t = decimal_alloc ();
3440  for (l = vars; l; l = CB_CHAIN (l)) {
3441  /* Set t, VAR
3442  * OP t, d
3443  * set VAR, t
3444  */
3445  decimal_expand (t, CB_VALUE (l));
3446  decimal_compute (op, t, d);
3447  decimal_assign (CB_VALUE (l), t, CB_PURPOSE (l));
3449  if (!s1) {
3450  s1 = s2;
3451  } else {
3452  s1 = cb_list_append (s1, s2);
3453  }
3454  decimal_stack = NULL;
3455  }
3456  decimal_free ();
3457  }
3458 
3459  decimal_free ();
3460 
3461  return s1;
3462 }
cb_tree cb_list_append(cb_tree l1, cb_tree l2)
Definition: tree.c:1305
static cb_tree decimal_stack
Definition: typeck.c:94
#define CB_PURPOSE(x)
Definition: tree.h:1192
static void decimal_expand(cb_tree d, cb_tree x)
Definition: typeck.c:3285
#define CB_VALUE(x)
Definition: tree.h:1193
static void decimal_free(void)
Definition: typeck.c:3251
static cb_tree decimal_alloc(void)
Definition: typeck.c:3229
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static void decimal_assign(cb_tree x, cb_tree d, cb_tree round_opt)
Definition: typeck.c:3361
static void decimal_compute(const int op, cb_tree x, cb_tree y)
Definition: typeck.c:3257
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327

Here is the call graph for this function:

Here is the caller graph for this function:

static void build_evaluate ( cb_tree  subject_list,
cb_tree  case_list,
cb_tree  labid 
)
static

Definition at line 5493 of file typeck.c.

References _, cb_build_binary_op(), cb_build_comment(), cb_build_cond(), cb_build_if(), CB_CHAIN, cb_emit, cb_error(), cb_error_node, CB_GOTO_P, cb_list_add(), CB_STATEMENT, CB_STATEMENT_P, CB_VALUE, evaluate_test(), and NULL.

Referenced by cb_emit_evaluate().

5494 {
5495  cb_tree c1;
5496  cb_tree c2;
5497  cb_tree c3;
5498  cb_tree subjs;
5499  cb_tree whens;
5500  cb_tree objs;
5501  cb_tree stmt;
5502 
5503  if (case_list == NULL) {
5504  return;
5505  }
5506 
5507  whens = CB_VALUE (case_list);
5508  stmt = CB_VALUE (whens);
5509  whens = CB_CHAIN (whens);
5510  c1 = NULL;
5511 
5512  /* For each WHEN sequence */
5513  for (; whens; whens = CB_CHAIN (whens)) {
5514  c2 = NULL;
5515  /* Single WHEN test */
5516  for (subjs = subject_list, objs = CB_VALUE (whens);
5517  subjs && objs;
5518  subjs = CB_CHAIN (subjs), objs = CB_CHAIN (objs)) {
5519  c3 = evaluate_test (CB_VALUE (subjs), CB_VALUE (objs));
5520  if (c3 == NULL || c3 == cb_error_node) {
5521  return;
5522  }
5523 
5524  if (c2 == NULL) {
5525  c2 = c3;
5526  } else {
5527  c2 = cb_build_binary_op (c2, '&', c3);
5528  if (c2 == cb_error_node) {
5529  return;
5530  }
5531  }
5532  }
5533  if (subjs || objs) {
5534  cb_error (_("Wrong number of WHEN parameters"));
5535  }
5536  /* Connect multiple WHEN's */
5537  if (c1 == NULL) {
5538  c1 = c2;
5539  } else {
5540  c1 = cb_build_binary_op (c1, '|', c2);
5541  if (c1 == cb_error_node) {
5542  return;
5543  }
5544  }
5545  }
5546 
5547  if (c1 == NULL) {
5548  cb_emit (cb_build_comment ("WHEN OTHER"));
5549  cb_emit (stmt);
5550  } else {
5551  c2 = stmt;
5552  /* Check if last statement is GO TO */
5553  for (c3 = stmt; c3; c3 = CB_CHAIN (c3)) {
5554  if (!CB_CHAIN(c3)) {
5555  break;
5556  }
5557  }
5558  if (c3 && CB_VALUE (c3) && CB_STATEMENT_P (CB_VALUE (c3))) {
5559  c3 = CB_STATEMENT(CB_VALUE(c3))->body;
5560  if (c3 && CB_VALUE (c3) && !CB_GOTO_P (CB_VALUE(c3))) {
5561  /* Append the jump */
5562  c2 = cb_list_add (stmt, labid);
5563  }
5564  }
5565  cb_emit (cb_build_if (cb_build_cond (c1), c2, NULL, 0));
5566  build_evaluate (subject_list, CB_CHAIN (case_list), labid);
5567  }
5568 }
#define CB_STATEMENT_P(x)
Definition: tree.h:1156
cb_tree cb_build_comment(const char *str)
Definition: tree.c:1540
#define CB_VALUE(x)
Definition: tree.h:1193
static cb_tree evaluate_test(cb_tree s, cb_tree o)
Definition: typeck.c:5430
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_STATEMENT(x)
Definition: tree.h:1155
cb_tree cb_error_node
Definition: tree.c:140
#define CB_GOTO_P(x)
Definition: tree.h:1080
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98
static void build_evaluate(cb_tree subject_list, cb_tree case_list, cb_tree labid)
Definition: typeck.c:5493
cb_tree cb_build_cond(cb_tree x)
Definition: typeck.c:3737
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
cb_tree cb_build_if(const cb_tree test, const cb_tree stmt1, const cb_tree stmt2, const unsigned int is_if)
Definition: tree.c:3132
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree build_store_option ( cb_tree  x,
cb_tree  round_opt 
)
static

Definition at line 3193 of file typeck.c.

References CB_FIELD_PTR, cb_int(), CB_INTEGER, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_X, CB_USAGE_DOUBLE, CB_USAGE_FLOAT, COB_STORE_KEEP_ON_OVERFLOW, COB_STORE_TRUNC_ON_OVERFLOW, current_statement, cb_statement::handler1, cb_statement::handler_id, and cb_field::usage.

Referenced by cb_build_add(), cb_build_div(), cb_build_mul(), cb_build_sub(), cb_emit_divide(), and decimal_assign().

3194 {
3195  struct cb_field *f;
3196  int opt;
3197  enum cb_usage usage;
3198 
3199  f = CB_FIELD_PTR (x);
3200  usage = f->usage;
3201 #if 0 /* RXWRXW - FP */
3202  if (usage == CB_USAGE_DOUBLE || usage == CB_USAGE_FLOAT) {
3203  /* Rounding on FP is useless */
3204  opt = 0;
3205  } else {
3206 #endif
3207  opt = CB_INTEGER (round_opt)->val;
3208 #if 0 /* RXWRXW - FP */
3209  }
3210 #endif
3211 
3212  if (usage == CB_USAGE_COMP_5 || usage == CB_USAGE_COMP_X) {
3213  /* Do not check NOT ERROR case, so that we optimize */
3214  if (current_statement->handler1) {
3216  }
3217  } else if (current_statement->handler_id) {
3218  /* There is a [NOT] ERROR/OVERFLOW/EXCEPTION - Set in parser */
3220  } else if (usage == CB_USAGE_BINARY && cb_binary_truncate) {
3221  /* Truncate binary field to digits in picture */
3223  }
3224 
3225  return cb_int (opt);
3226 }
#define CB_INTEGER(x)
Definition: tree.h:522
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int handler_id
Definition: tree.h:1148
cb_usage
Definition: tree.h:255
Definition: tree.h:643
#define COB_STORE_KEEP_ON_OVERFLOW
Definition: common.h:868
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define COB_STORE_TRUNC_ON_OVERFLOW
Definition: common.h:869
cb_tree handler1
Definition: tree.h:1141
enum cb_usage usage
Definition: tree.h:693
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_add ( cb_tree  v,
cb_tree  n,
cb_tree  round_opt 
)

Definition at line 4015 of file typeck.c.

References build_store_option(), cb_build_binary_op(), CB_BUILD_FUNCALL_3, cb_build_move(), cb_build_optim_add(), CB_CLASS_POINTER, CB_FIELD_PTR, cb_fits_int(), cb_high, CB_INDEX_P, cb_int0, CB_REF_OR_FIELD_P, CB_TREE_CLASS, COB_POINTER_MANIP, cb_field::count, and optimize_defs.

Referenced by cb_build_perform_varying(), cb_emit_arithmetic(), cb_emit_set_up_down(), and yyparse().

4016 {
4017  cb_tree opt;
4018  struct cb_field *f;
4019 
4020 #ifdef COB_NON_ALIGNED
4021  if (CB_INDEX_P (v)) {
4022  return cb_build_move (cb_build_binary_op (v, '+', n), v);
4023  }
4024  if (CB_TREE_CLASS (v) == CB_CLASS_POINTER) {
4026  return CB_BUILD_FUNCALL_3 ("cob_pointer_manip", v, n, cb_int0);
4027  }
4028 #else
4029  if (CB_INDEX_P (v) || CB_TREE_CLASS (v) == CB_CLASS_POINTER) {
4030  return cb_build_move (cb_build_binary_op (v, '+', n), v);
4031  }
4032 #endif
4033 
4034  if (CB_REF_OR_FIELD_P (v)) {
4035  f = CB_FIELD_PTR (v);
4036  f->count++;
4037  }
4038  if (CB_REF_OR_FIELD_P (n)) {
4039  f = CB_FIELD_PTR (n);
4040  f->count++;
4041  }
4042  if (round_opt == cb_high) {
4043  /* Short circuit from tree.c for perform */
4044  if (cb_fits_int (n)) {
4045  return cb_build_optim_add (v, n);
4046  } else {
4047  return CB_BUILD_FUNCALL_3 ("cob_add", v, n, cb_int0);
4048  }
4049  }
4050  opt = build_store_option (v, round_opt);
4051  if (opt == cb_int0 && cb_fits_int (n)) {
4052  return cb_build_optim_add (v, n);
4053  }
4054  return CB_BUILD_FUNCALL_3 ("cob_add", v, n, opt);
4055 }
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
static cb_tree cb_build_optim_add(cb_tree v, cb_tree n)
Definition: typeck.c:3876
#define CB_INDEX_P(x)
Definition: tree.h:750
Definition: tree.h:643
cb_tree cb_int0
Definition: tree.c:133
int count
Definition: tree.h:680
int cb_fits_int(const cb_tree x)
Definition: tree.c:914
cb_tree cb_high
Definition: tree.c:129
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_address ( cb_tree  x)

Definition at line 1357 of file typeck.c.

References _, CB_ADD_TO_CHAIN, CB_BUILD_CAST_ADDRESS, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_P, cb_list_length(), cb_one, cb_ref(), CB_REFERENCE, CB_REFERENCE_P, cb_warning_x(), cb_word::name, cb_reference::offset, cb_reference::subs, and cb_reference::word.

Referenced by cb_build_identifier(), and yyparse().

1358 {
1359  cb_tree v;
1360  struct cb_reference *r;
1361  const char *name;
1362  int numsubs;
1363  int refsubs;
1364 
1365  if (x == cb_error_node) {
1366  return cb_error_node;
1367  }
1368  if (!CB_REFERENCE_P (x)) {
1369  return CB_BUILD_CAST_ADDRESS (x);
1370  }
1371 
1372  r = CB_REFERENCE (x);
1373  name = r->word->name;
1374  v = cb_ref (x);
1375  if (v == cb_error_node) {
1376  return cb_error_node;
1377  }
1378 
1379  refsubs = cb_list_length (r->subs);
1380  if (CB_FIELD_P (v)) {
1381  numsubs = CB_FIELD (v)->indexes;
1382  if (refsubs > numsubs) {
1383  goto subserror;
1384  } else if (refsubs < numsubs) {
1385  if (!cb_relaxed_syntax_check) {
1386  goto subserror;
1387  } else {
1388  cb_warning_x (x,
1389  _("Subscripts missing for '%s' - Defaulting to 1"),
1390  name);
1391  for (; refsubs < numsubs; ++refsubs) {
1392  CB_ADD_TO_CHAIN (cb_one, r->subs);
1393  }
1394  }
1395  }
1396  } else {
1397  numsubs = 0;
1398  if (r->subs) {
1399  goto subserror;
1400  }
1401  if (r->offset) {
1402  cb_error_x (x, _("'%s' cannot be reference modified"), name);
1403  return cb_error_node;
1404  }
1405  }
1406 
1407  return CB_BUILD_CAST_ADDRESS (x);
1408 
1409 subserror:
1410  switch (numsubs) {
1411  case 0:
1412  cb_error_x (x, _("'%s' cannot be subscripted"), name);
1413  break;
1414  case 1:
1415  cb_error_x (x, _("'%s' requires 1 subscript"), name);
1416  break;
1417  default:
1418  cb_error_x (x, _("'%s' requires %d subscripts"),
1419  name, numsubs);
1420  break;
1421  }
1422  return cb_error_node;
1423 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
const char * name
Definition: tree.h:865
int cb_list_length(cb_tree l)
Definition: tree.c:1342
#define CB_FIELD_P(x)
Definition: tree.h:741
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define _(s)
Definition: cobcrun.c:59
cb_tree offset
Definition: tree.h:878
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_one
Definition: tree.c:126
cb_tree cb_error_node
Definition: tree.c:140
#define CB_ADD_TO_CHAIN(x, y)
Definition: tree.h:1854
cb_tree subs
Definition: tree.h:877
#define CB_FIELD(x)
Definition: tree.h:740
struct cb_word * word
Definition: tree.h:881

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_assignment_name ( struct cb_file cfile,
cb_tree  name 
)

Definition at line 1276 of file typeck.c.

References _, CB_ASSIGN_IBM, CB_ASSIGN_MF, cb_build_alphanumeric_literal(), cb_error_node, cb_list_add(), CB_NAME, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE_TAG, cb_warning(), current_program, cb_file::flag_ext_assign, NULL, cb_program::reference_list, and warningopt.

Referenced by yyparse().

1277 {
1278  const char *s;
1279  const char *p;
1280 
1281  if (name == cb_error_node) {
1282  return cb_error_node;
1283  }
1284  /* For special assignment */
1285  if (name == NULL) {
1286  return NULL;
1287  }
1288 
1289  switch (CB_TREE_TAG (name)) {
1290  case CB_TAG_LITERAL:
1291  return name;
1292 
1293  case CB_TAG_REFERENCE:
1294  s = CB_NAME (name);
1295  if (cb_assign_clause == CB_ASSIGN_MF) {
1296  if (cfile->flag_ext_assign) {
1297  p = strrchr (s, '-');
1298  if (p) {
1299  s = p + 1;
1300  }
1301  return cb_build_alphanumeric_literal (s, strlen (s));
1302  }
1305  return name;
1306  } else if (cb_assign_clause == CB_ASSIGN_IBM) {
1307  /* Check organization */
1308  if (strncmp (s, "S-", (size_t)2) == 0 ||
1309  strncmp (s, "AS-", (size_t)3) == 0) {
1310  goto org;
1311  }
1312  /* Skip the device label if exists */
1313  if ((p = strchr (s, '-')) != NULL) {
1314  s = p + 1;
1315  }
1316  /* Check organization again */
1317  if (strncmp (s, "S-", (size_t)2) == 0 ||
1318  strncmp (s, "AS-", (size_t)3) == 0) {
1319 org:
1320  /* Skip it for now */
1321  s = strchr (s, '-') + 1;
1322  }
1323  /* Convert the name into literal */
1324  if (warningopt) {
1325  cb_warning (_("ASSIGN interpreted as %s"), s);
1326  }
1327  return cb_build_alphanumeric_literal (s, strlen (s));
1328  }
1329  /* Fall through for CB_ASSIGN_COBOL2002 */
1330  /* To be looked at */
1331  default:
1332  return cb_error_node;
1333  }
1334 }
cb_tree reference_list
Definition: tree.h:1255
int warningopt
Definition: cobc.c:176
#define CB_ASSIGN_IBM
Definition: cobc.h:78
unsigned int flag_ext_assign
Definition: tree.h:851
cb_tree cb_build_alphanumeric_literal(const void *data, const size_t size)
Definition: tree.c:1716
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define CB_NAME(x)
Definition: tree.h:904
cb_tree cb_error_node
Definition: tree.c:140
#define CB_ASSIGN_MF
Definition: cobc.h:77
struct cb_program * current_program
Definition: parser.c:168
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_cond ( cb_tree  x)

Definition at line 3737 of file typeck.c.

References _, cb_program::alphabet_name_list, build_cond_88(), cb_any, CB_BINARY_OP, CB_BINARY_OP_P, cb_build_binary_op(), CB_BUILD_CAST_ADDRESS, CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_BUILD_NEGATION, cb_build_optim_cond(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, cb_chk_alpha_cond(), cb_chk_num_cond(), CB_CLASS_NUMERIC, CB_CLASS_POINTER, cb_error_node, cb_error_x(), cb_false, CB_FIELD_P, CB_FIELD_PTR, cb_field_size(), cb_fits_long_long(), cb_high, CB_INDEX_P, cb_int(), cb_list_reverse(), cb_low, cb_ref(), CB_REF_OR_FIELD_P, cb_space, CB_TAG_BINARY_OP, CB_TAG_CONST, CB_TAG_FUNCALL, CB_TAG_REFERENCE, CB_TREE, CB_TREE_CATEGORY, CB_TREE_CLASS, CB_TREE_TAG, cb_true, cb_zero, current_program, current_statement, d1, d2, decimal_alloc(), decimal_expand(), decimal_free(), dpush, cb_program::flag_debugging, cb_field::level, NULL, cb_binary_op::op, cb_binary_op::x, and cb_binary_op::y.

Referenced by build_evaluate(), cb_build_search_all(), and yyparse().

3738 {
3739  struct cb_field *f;
3740  struct cb_binary_op *p;
3741  cb_tree d1;
3742  cb_tree d2;
3743  int size1;
3744  int size2;
3745 
3746  if (x == cb_error_node) {
3747  return cb_error_node;
3748  }
3749  switch (CB_TREE_TAG (x)) {
3750  case CB_TAG_CONST:
3751  if (x != cb_any && x != cb_true && x != cb_false) {
3753  _("Invalid expression"));
3754  return cb_error_node;
3755  }
3756  return x;
3757  case CB_TAG_FUNCALL:
3758  return x;
3759  case CB_TAG_REFERENCE:
3760  if (!CB_FIELD_P (cb_ref (x))) {
3761  return cb_build_cond (cb_ref (x));
3762  }
3763 
3764  f = CB_FIELD_PTR (x);
3765 
3766  /* Level 88 condition */
3767  if (f->level == 88) {
3768  /* Build an 88 condition at every occurrence */
3769  /* as it may be subscripted */
3770  return cb_build_cond (build_cond_88 (x));
3771  }
3772 
3773  break;
3774  case CB_TAG_BINARY_OP:
3775  p = CB_BINARY_OP (x);
3776  if (!p->x || p->x == cb_error_node) {
3777  return cb_error_node;
3778  }
3779  switch (p->op) {
3780  case '!':
3781  return CB_BUILD_NEGATION (cb_build_cond (p->x));
3782  case '&':
3783  case '|':
3784  if (!p->y || p->y == cb_error_node) {
3785  return cb_error_node;
3786  }
3787  return cb_build_binary_op (cb_build_cond (p->x), p->op, cb_build_cond (p->y));
3788  default:
3789  if (!p->y || p->y == cb_error_node) {
3790  return cb_error_node;
3791  }
3792  if (CB_INDEX_P (p->x) || CB_INDEX_P (p->y) ||
3793  CB_TREE_CLASS (p->x) == CB_CLASS_POINTER ||
3794  CB_TREE_CLASS (p->y) == CB_CLASS_POINTER) {
3795  x = cb_build_binary_op (p->x, '-', p->y);
3796  } else if (CB_BINARY_OP_P (p->x) ||
3797  CB_BINARY_OP_P (p->y)) {
3798  /* Decimal comparison */
3799  d1 = decimal_alloc ();
3800  d2 = decimal_alloc ();
3801 
3802  decimal_expand (d1, p->x);
3803  decimal_expand (d2, p->y);
3804  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_cmp", d1, d2));
3805  decimal_free ();
3806  decimal_free ();
3808  decimal_stack = NULL;
3809  } else {
3810  /* DEBUG Bypass optimization for PERFORM */
3812  x = CB_BUILD_FUNCALL_2 ("cob_cmp", p->x, p->y);
3813  break;
3814  }
3815  if (cb_chk_num_cond (p->x, p->y)) {
3816  size1 = cb_field_size (p->x);
3817  x = CB_BUILD_FUNCALL_3 ("memcmp",
3818  CB_BUILD_CAST_ADDRESS (p->x),
3819  CB_BUILD_CAST_ADDRESS (p->y),
3820  cb_int (size1));
3821  break;
3822  }
3823  if (CB_TREE_CLASS (p->x) == CB_CLASS_NUMERIC &&
3824  CB_TREE_CLASS (p->y) == CB_CLASS_NUMERIC &&
3825  cb_fits_long_long (p->y)) {
3826  x = cb_build_optim_cond (p);
3827  break;
3828  }
3829 
3830  /* Field comparison */
3831  if ((CB_REF_OR_FIELD_P (p->x)) &&
3834  cb_field_size (p->x) == 1 &&
3836  (p->y == cb_space || p->y == cb_low ||
3837  p->y == cb_high || p->y == cb_zero)) {
3838  x = CB_BUILD_FUNCALL_2 ("$G", p->x, p->y);
3839  break;
3840  }
3841  if (cb_chk_alpha_cond (p->x) &&
3842  cb_chk_alpha_cond (p->y)) {
3843  size1 = cb_field_size (p->x);
3844  size2 = cb_field_size (p->y);
3845  } else {
3846  size1 = 0;
3847  size2 = 0;
3848  }
3849  if (size1 == 1 && size2 == 1) {
3850  x = CB_BUILD_FUNCALL_2 ("$G", p->x, p->y);
3851  } else if (size1 != 0 && size1 == size2) {
3852  x = CB_BUILD_FUNCALL_3 ("memcmp",
3853  CB_BUILD_CAST_ADDRESS (p->x),
3854  CB_BUILD_CAST_ADDRESS (p->y),
3855  cb_int (size1));
3856  } else {
3857  if (CB_TREE_CLASS (p->x) == CB_CLASS_NUMERIC && p->y == cb_zero) {
3858  x = cb_build_optim_cond (p);
3859  } else {
3860  x = CB_BUILD_FUNCALL_2 ("cob_cmp", p->x, p->y);
3861  }
3862  }
3863  }
3864  }
3865  return cb_build_binary_op (x, p->op, p->y);
3866  default:
3867  break;
3868  }
3869  cb_error_x (x, _("Invalid expression"));
3870  return cb_error_node;
3871 }
static cob_decimal d2
Definition: intrinsic.c:80
#define CB_TREE(x)
Definition: tree.h:440
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_true
Definition: tree.c:122
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static cb_tree decimal_stack
Definition: typeck.c:94
static int cb_chk_alpha_cond(cb_tree x)
Definition: typeck.c:3712
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
cb_tree cb_zero
Definition: tree.c:125
cob_decimal * d1
Definition: cobxref.c.l.h:21
static void decimal_expand(cb_tree d, cb_tree x)
Definition: typeck.c:3285
cb_tree cb_false
Definition: tree.c:123
#define dpush(x)
Definition: typeck.c:73
cb_tree cb_any
Definition: tree.c:121
int level
Definition: tree.h:673
int cb_fits_long_long(const cb_tree x)
Definition: tree.c:991
cb_tree cb_space
Definition: tree.c:127
unsigned int flag_debugging
Definition: tree.h:1320
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_BINARY_OP_P(x)
Definition: tree.h:937
#define CB_FIELD_P(x)
Definition: tree.h:741
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define CB_INDEX_P(x)
Definition: tree.h:750
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
static void decimal_free(void)
Definition: typeck.c:3251
static cb_tree decimal_alloc(void)
Definition: typeck.c:3229
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
int op
Definition: tree.h:932
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_TREE_TAG(x)
Definition: tree.h:441
static int cb_chk_num_cond(cb_tree x, cb_tree y)
Definition: typeck.c:3668
cb_tree alphabet_name_list
Definition: tree.h:1256
cb_tree cb_int(const int n)
Definition: tree.c:1488
static cb_tree build_cond_88(cb_tree x)
Definition: typeck.c:3519
cb_tree cb_error_node
Definition: tree.c:140
cb_tree y
Definition: tree.h:931
static cb_tree cb_build_optim_cond(struct cb_binary_op *p)
Definition: typeck.c:3558
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_high
Definition: tree.c:129
cb_tree x
Definition: tree.h:930
#define CB_BINARY_OP(x)
Definition: tree.h:936
cb_tree cb_build_cond(cb_tree x)
Definition: typeck.c:3737
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
cb_tree cb_low
Definition: tree.c:128

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_const_length ( cb_tree  x)

Definition at line 1730 of file typeck.c.

References _, cb_build_numeric_literal(), cb_error(), cb_error_node, CB_FIELD, cb_field_variable_size(), CB_INTEGER, CB_INTEGER_P, cb_ref(), CB_REFERENCE, CB_REFERENCE_P, cb_validate_field(), cb_field::flag_any_length, cb_field::level, cb_field::memory_size, cb_field::offset, cb_field::redefines, cb_field::rename_thru, and cb_field::size.

Referenced by yyparse().

1731 {
1732  struct cb_field *f;
1733  char buff[32];
1734 
1735  if (x == cb_error_node) {
1736  return cb_error_node;
1737  }
1738  if (CB_INTEGER_P (x)) {
1739  sprintf (buff, "%d", CB_INTEGER(x)->val);
1740  return cb_build_numeric_literal (0, buff, 0);
1741  }
1742  if (CB_REFERENCE_P (x)) {
1743  if (cb_ref (x) == cb_error_node) {
1744  return cb_error_node;
1745  }
1746  if (CB_REFERENCE (x)->offset) {
1747  cb_error (_("Reference modification not allowed here"));
1748  return cb_error_node;
1749  }
1750  }
1751 
1752  memset (buff, 0, sizeof (buff));
1753  f = CB_FIELD (cb_ref (x));
1754  if (f->flag_any_length) {
1755  cb_error (_("ANY LENGTH item not allowed here"));
1756  return cb_error_node;
1757  }
1758  if (f->level == 88) {
1759  cb_error (_("88 level item not allowed here"));
1760  return cb_error_node;
1761  }
1762  if (cb_field_variable_size (f)) {
1763  cb_error (_("Variable length item not allowed here"));
1764  return cb_error_node;
1765  }
1766  if (f->redefines) {
1768  if (f->rename_thru) {
1770  }
1771  cb_validate_field (f);
1772  sprintf (buff, "%d", f->size);
1773  } else {
1774  cb_validate_field (f);
1775  sprintf (buff, "%d", f->memory_size);
1776  }
1777  return cb_build_numeric_literal (0, buff, 0);
1778 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
#define CB_INTEGER(x)
Definition: tree.h:522
unsigned int flag_any_length
Definition: tree.h:712
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
int level
Definition: tree.h:673
cb_tree cb_build_numeric_literal(const int sign, const void *data, const int scale)
Definition: tree.c:1681
int offset
Definition: tree.h:675
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_REFERENCE(x)
Definition: tree.h:901
int size
Definition: tree.h:672
struct cb_field * rename_thru
Definition: tree.h:655
cb_tree cb_error_node
Definition: tree.c:140
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98
int memory_size
Definition: tree.h:674
void cb_validate_field(struct cb_field *f)
Definition: field.c:1338
struct cb_field * redefines
Definition: tree.h:654
#define CB_INTEGER_P(x)
Definition: tree.h:523
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_converting ( cb_tree  x,
cb_tree  y,
cb_tree  l 
)

Definition at line 5954 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_list_add(), and validate_inspect().

Referenced by yyparse().

5955 {
5956  validate_inspect (x, y, 2);
5957  return cb_list_add (l, CB_BUILD_FUNCALL_2 ("cob_inspect_converting", x, y));
5958 }
static void validate_inspect(cb_tree x, cb_tree y, const unsigned int replconv)
Definition: typeck.c:5714
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_build_debug_item ( void  )

Definition at line 2243 of file typeck.c.

References cb_build_field_tree(), cb_build_filler(), cb_build_picture(), cb_build_reference(), CB_FIELD, CB_FIELD_ADD, CB_LIST_INIT, CB_PICTURE, cb_space, CB_STORAGE_WORKING, cb_validate_field(), current_program, NULL, and cb_program::working_storage.

Referenced by yyparse().

2244 {
2245  cb_tree l;
2246  cb_tree x;
2247  cb_tree assign;
2248 
2249  /* Set up DEBUG-ITEM */
2250  l = cb_build_reference ("DEBUG-ITEM");
2252  NULL, 1);
2253  CB_FIELD (assign)->values = CB_LIST_INIT (cb_space);
2254  cb_debug_item = l;
2255 
2256  l = cb_build_reference ("DEBUG-LINE");
2257  x = cb_build_field_tree (NULL, l, CB_FIELD(assign),
2258  CB_STORAGE_WORKING, NULL, 3);
2259  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("9(6)"));
2261  cb_debug_line = l;
2262 
2263  l = cb_build_filler ();
2264  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2265  CB_STORAGE_WORKING, NULL, 3);
2266  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X"));
2267  CB_FIELD (x)->flag_filler = 1;
2269 
2270  l = cb_build_reference ("DEBUG-NAME");
2271  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2272  CB_STORAGE_WORKING, NULL, 3);
2273  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X(31)"));
2275  cb_debug_name = l;
2276 
2277  l = cb_build_filler ();
2278  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2279  CB_STORAGE_WORKING, NULL, 3);
2280  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X"));
2281  CB_FIELD (x)->flag_filler = 1;
2283 
2284  l = cb_build_reference ("DEBUG-SUB-1");
2285  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2286  CB_STORAGE_WORKING, NULL, 3);
2287  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("S9(4)"));
2288  CB_FIELD (x)->flag_sign_leading = 1;
2289  CB_FIELD (x)->flag_sign_separate = 1;
2291  cb_debug_sub_1 = l;
2292 
2293  l = cb_build_filler ();
2294  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2295  CB_STORAGE_WORKING, NULL, 3);
2296  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X"));
2297  CB_FIELD (x)->flag_filler = 1;
2299 
2300  l = cb_build_reference ("DEBUG-SUB-2");
2301  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2302  CB_STORAGE_WORKING, NULL, 3);
2303  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("S9(4)"));
2304  CB_FIELD (x)->flag_sign_leading = 1;
2305  CB_FIELD (x)->flag_sign_separate = 1;
2307  cb_debug_sub_2 = l;
2308 
2309  l = cb_build_filler ();
2310  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2311  CB_STORAGE_WORKING, NULL, 3);
2312  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X"));
2313  CB_FIELD (x)->flag_filler = 1;
2315 
2316  l = cb_build_reference ("DEBUG-SUB-3");
2317  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2318  CB_STORAGE_WORKING, NULL, 3);
2319  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("S9(4)"));
2320  CB_FIELD (x)->flag_sign_leading = 1;
2321  CB_FIELD (x)->flag_sign_separate = 1;
2323  cb_debug_sub_3 = l;
2324 
2325  l = cb_build_filler ();
2326  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2327  CB_STORAGE_WORKING, NULL, 3);
2328  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X"));
2329  CB_FIELD (x)->flag_filler = 1;
2331 
2332  l = cb_build_reference ("DEBUG-CONTENTS");
2333  x = cb_build_field_tree (NULL, l, CB_FIELD(x),
2334  CB_STORAGE_WORKING, NULL, 3);
2335  CB_FIELD (x)->pic = CB_PICTURE (cb_build_picture ("X(31)"));
2337  cb_debug_contents = l;
2338 
2339  cb_validate_field (CB_FIELD (assign));
2341 }
cb_tree cb_debug_sub_2
Definition: typeck.c:86
cb_tree cb_debug_name
Definition: typeck.c:84
cb_tree cb_build_filler(void)
Definition: tree.c:2591
#define CB_FIELD_ADD(x, y)
Definition: tree.h:1856
cb_tree cb_debug_line
Definition: typeck.c:83
cb_tree cb_build_field_tree(cb_tree level, cb_tree name, struct cb_field *last_field, enum cb_storage storage, struct cb_file *fn, const int expl_level)
Definition: field.c:90
#define CB_PICTURE(x)
Definition: tree.h:631
cb_tree cb_space
Definition: tree.c:127
cb_tree cb_build_picture(const char *str)
Definition: tree.c:1800
cb_tree cb_debug_item
Definition: typeck.c:82
cb_tree cb_debug_sub_1
Definition: typeck.c:85
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_build_reference(const char *name)
Definition: tree.c:2572
cb_tree cb_debug_sub_3
Definition: typeck.c:87
struct cb_program * current_program
Definition: parser.c:168
#define CB_LIST_INIT(x)
Definition: tree.h:1851
cb_tree cb_debug_contents
Definition: typeck.c:88
struct cb_field * working_storage
Definition: tree.h:1276
void cb_validate_field(struct cb_field *f)
Definition: field.c:1338
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_display_mnemonic ( cb_tree  x)

Definition at line 5340 of file typeck.c.

References _, CB_DEVICE_CONSOLE, CB_DEVICE_SYSERR, CB_DEVICE_SYSOUT, cb_error_node, cb_error_x(), cb_int0, cb_int1, cb_ref(), and CB_SYSTEM_NAME.

Referenced by yyparse().

5341 {
5342  if (x == cb_error_node) {
5343  return cb_int0;
5344  }
5345  if (cb_ref (x) == cb_error_node) {
5346  return cb_int0;
5347  }
5348 
5349  switch (CB_SYSTEM_NAME (cb_ref (x))->token) {
5350  case CB_DEVICE_CONSOLE:
5351  case CB_DEVICE_SYSOUT:
5352  return cb_int0;
5353  case CB_DEVICE_SYSERR:
5354  return cb_int1;
5355  default:
5356  cb_error_x (x, _("Invalid output device"));
5357  return cb_int0;
5358  }
5359 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
cb_tree cb_int1
Definition: tree.c:134
#define CB_DEVICE_SYSOUT
Definition: tree.h:154
#define CB_DEVICE_SYSERR
Definition: tree.h:155
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define _(s)
Definition: cobcrun.c:59
cb_tree cb_int0
Definition: tree.c:133
cb_tree cb_error_node
Definition: tree.c:140
#define CB_DEVICE_CONSOLE
Definition: tree.h:156

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_display_name ( cb_tree  x)

Definition at line 5362 of file typeck.c.

References _, CB_DEVICE_CONSOLE, CB_DEVICE_SYSERR, CB_DEVICE_SYSOUT, cb_error_node, cb_error_x(), cb_int0, cb_int1, CB_NAME, CB_SYSTEM_NAME, cb_warning_x(), lookup_system_name(), and cb_file::name.

Referenced by yyparse().

5363 {
5364  const char *name;
5365  cb_tree sys;
5366 
5367  if (x == cb_error_node) {
5368  return cb_error_node;
5369  }
5370  name = CB_NAME (x);
5371  /* Allow direct reference to a device name */
5372  sys = lookup_system_name (name);
5373  if (sys) {
5374  switch (CB_SYSTEM_NAME (sys)->token) {
5375  case CB_DEVICE_CONSOLE:
5376  case CB_DEVICE_SYSOUT:
5377  if (!cb_relaxed_syntax_check) {
5378  cb_warning_x (x, _("'%s' is not defined in SPECIAL-NAMES"), name);
5379  }
5380  return cb_int0;
5381  case CB_DEVICE_SYSERR:
5382  if (!cb_relaxed_syntax_check) {
5383  cb_warning_x (x, _("'%s' is not defined in SPECIAL-NAMES"), name);
5384  }
5385  return cb_int1;
5386  default:
5387  cb_error_x (x, _("'%s' is not an output device"), name);
5388  return cb_error_node;
5389  }
5390  }
5391 
5392  cb_error_x (x, _("'%s' is not defined in SPECIAL-NAMES"), name);
5393  return cb_error_node;
5394 }
const char * name
Definition: tree.h:645
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
cb_tree cb_int1
Definition: tree.c:134
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
#define CB_DEVICE_SYSOUT
Definition: tree.h:154
#define CB_DEVICE_SYSERR
Definition: tree.h:155
#define _(s)
Definition: cobcrun.c:59
cb_tree lookup_system_name(const char *name)
Definition: reserved.c:2860
cb_tree cb_int0
Definition: tree.c:133
#define CB_NAME(x)
Definition: tree.h:904
cb_tree cb_error_node
Definition: tree.c:140
#define CB_DEVICE_CONSOLE
Definition: tree.h:156

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_div ( cb_tree  v,
cb_tree  n,
cb_tree  round_opt 
)
static

Definition at line 3390 of file typeck.c.

References build_store_option(), cb_build_binary_op(), CB_BUILD_FUNCALL_3, cb_build_move(), CB_FIELD_PTR, CB_INDEX_P, CB_REF_OR_FIELD_P, and cb_field::count.

Referenced by cb_emit_arithmetic().

3391 {
3392  cb_tree opt;
3393  struct cb_field *f;
3394 
3395  if (CB_INDEX_P (v)) {
3396  return cb_build_move (cb_build_binary_op (v, '/', n), v);
3397  }
3398 
3399  if (CB_REF_OR_FIELD_P (v)) {
3400  f = CB_FIELD_PTR (v);
3401  f->count++;
3402  }
3403  if (CB_REF_OR_FIELD_P (n)) {
3404  f = CB_FIELD_PTR (n);
3405  f->count++;
3406  }
3407  opt = build_store_option (v, round_opt);
3408  return CB_BUILD_FUNCALL_3 ("cob_div", v, n, opt);
3409 }
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_INDEX_P(x)
Definition: tree.h:750
Definition: tree.h:643
int count
Definition: tree.h:680
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_expr ( cb_tree  list)

Definition at line 3136 of file typeck.c.

References CB_CHAIN, CB_CLASS_NAME, cb_expr_finish(), cb_expr_init(), cb_expr_shift(), cb_expr_shift_class(), cb_expr_shift_sign(), CB_PURPOSE_INT, cb_ref(), CB_VALUE, current_statement, NULL, cb_statement::null_check, and cb_binary_op::op.

Referenced by yyparse().

3137 {
3138  cb_tree l;
3139  int op;
3140 
3141  cb_expr_init ();
3142 
3143  for (l = list; l; l = CB_CHAIN (l)) {
3144  op = CB_PURPOSE_INT (l);
3145  switch (op) {
3146  case '9':
3147  /* NUMERIC */
3148  cb_expr_shift_class ("cob_is_numeric");
3149  break;
3150  case 'A':
3151  /* ALPHABETIC */
3152  cb_expr_shift_class ("cob_is_alpha");
3153  break;
3154  case 'L':
3155  /* ALPHABETIC_LOWER */
3156  cb_expr_shift_class ("cob_is_lower");
3157  break;
3158  case 'U':
3159  /* ALPHABETIC_UPPER */
3160  cb_expr_shift_class ("cob_is_upper");
3161  break;
3162  case 'P':
3163  /* POSITIVE */
3164  cb_expr_shift_sign ('>');
3165  break;
3166  case 'N':
3167  /* NEGATIVE */
3168  cb_expr_shift_sign ('<');
3169  break;
3170  case 'O':
3171  /* OMITTED */
3172  if (current_statement) {
3174  }
3175  cb_expr_shift_class ("cob_is_omitted");
3176  break;
3177  case 'C':
3178  /* CLASS */
3180  break;
3181  default:
3182  cb_expr_shift (op, CB_VALUE (l));
3183  break;
3184  }
3185  }
3186 
3187  return cb_expr_finish ();
3188 }
static void cb_expr_shift(int token, cb_tree value)
Definition: typeck.c:2970
#define CB_PURPOSE_INT(x)
Definition: tree.h:1197
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static void cb_expr_shift_class(const char *name)
Definition: typeck.c:2950
static void cb_expr_shift_sign(const int op)
Definition: typeck.c:2930
cb_tree null_check
Definition: tree.h:1144
#define CB_CLASS_NAME(x)
Definition: tree.h:562
static cb_tree cb_expr_finish(void)
Definition: typeck.c:3108
struct cb_statement * current_statement
Definition: parser.c:169
static void cb_expr_init(void)
Definition: typeck.c:2714

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_identifier ( cb_tree  x,
const int  subchk 
)

Definition at line 1426 of file typeck.c.

References _, CB_ADD_TO_CHAIN, CB_BINARY_OP, CB_BINARY_OP_P, cb_build_address(), cb_build_cast_int(), CB_BUILD_CAST_LENGTH, cb_build_field_reference(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_BUILD_FUNCALL_4, cb_build_reference(), CB_BUILD_STRING0, CB_CHAIN, cb_check_integer_value(), cb_check_lit_subs(), cb_error_node, cb_error_x(), CB_EXCEPTION_ENABLE, CB_FIELD, cb_field_founder(), CB_FIELD_P, CB_FIELD_PTR, cb_get_int(), cb_int(), cb_int1, cb_list_add(), cb_list_length(), cb_list_reverse(), CB_LITERAL_P, cb_one, cb_ref(), CB_REFERENCE, CB_STORAGE_CONSTANT, CB_STORAGE_LINKAGE, CB_USAGE_NATIONAL, CB_VALUE, cb_warning_x(), cb_reference::check, cb_field::children, COB_EC_BOUND_REF_MOD, COB_EC_BOUND_SUBSCRIPT, COB_EC_DATA_PTR_NULL, COB_EC_PROGRAM_ARG_OMITTED, COB_MAX_WORDLEN, current_statement, cb_field::depending, cb_reference::flag_all, cb_field::flag_any_length, cb_field::flag_is_pdiv_opt, cb_field::flag_is_pdiv_parm, cb_field::flag_item_based, cb_statement::flag_no_based, cb_field::flag_occurs, cb_field::indexes, cb_reference::length, cb_field::mem_offset, cb_field::name, cb_word::name, NULL, cb_statement::null_check, cb_field::occurs_max, cb_field::occurs_min, cb_field::odo_level, cb_field::offset, cb_reference::offset, cb_field::parent, cb_field::redefines, cb_field::size, cb_field::storage, cb_reference::subs, unlikely, cb_field::usage, cb_field::values, and cb_reference::word.

Referenced by yyparse().

1427 {
1428  struct cb_reference *r;
1429  struct cb_field *f;
1430  struct cb_field *p;
1431  const char *name;
1432  char full_name[COB_MAX_WORDLEN * 2 + 10];
1433  cb_tree xr;
1434  cb_tree v;
1435  cb_tree e1;
1436  cb_tree l;
1437  cb_tree sub;
1438  int offset;
1439  int length;
1440  int n;
1441  int numsubs;
1442  int refsubs;
1443  int pseudosize;
1444 
1445  if (x == cb_error_node) {
1446  return cb_error_node;
1447  }
1448 
1449  r = CB_REFERENCE (x);
1450  name = r->word->name;
1451 
1452  /* Resolve reference */
1453  v = cb_ref (x);
1454  if (v == cb_error_node) {
1455  return cb_error_node;
1456  }
1457 
1458  /* Check if it is a data name */
1459  if (!CB_FIELD_P (v)) {
1460  if (r->subs) {
1461  cb_error_x (x, _("'%s' cannot be subscripted"), name);
1462  return cb_error_node;
1463  }
1464  if (r->offset) {
1465  cb_error_x (x, _("'%s' cannot be reference modified"), name);
1466  return cb_error_node;
1467  }
1468  return x;
1469  }
1470  f = CB_FIELD (v);
1471 
1472  /* BASED check and check for OPTIONAL LINKAGE items */
1473  if (current_statement &&
1476  p = cb_field_founder (f);
1477  if (p->redefines) {
1478  p = p->redefines;
1479  }
1480  if (p == f) {
1481  sprintf(full_name, "'%s'", name);
1482  } else {
1483  sprintf(full_name, _("'%s' (accessed by '%s')"), p->name, name);
1484  }
1485  xr = cb_build_reference(full_name);
1486 
1489  if (p->flag_item_based ||
1490  (p->storage == CB_STORAGE_LINKAGE &&
1491  !p->flag_is_pdiv_parm)) {
1493  "cob_check_based",
1495  CB_BUILD_STRING0 (CB_REFERENCE(xr)->word->name));
1496  }
1497  }
1499  p->flag_is_pdiv_opt) {
1501  "cob_check_linkage",
1503  CB_BUILD_STRING0 (CB_REFERENCE(xr)->word->name), cb_int1);
1504  }
1505  }
1506 
1507  for (l = r->subs; l; l = CB_CHAIN (l)) {
1508  if (CB_BINARY_OP_P (CB_VALUE (l))) {
1509  /* Set special flag for codegen */
1510  CB_BINARY_OP(CB_VALUE(l))->flag = 1;
1511  }
1512  }
1513 
1514  /* Check the number of subscripts */
1515  numsubs = refsubs = cb_list_length (r->subs);
1516  cb_check_lit_subs (r, numsubs, f->indexes);
1517  if (subchk) {
1518  if (!f->indexes) {
1519  cb_error_x (x, _("'%s' has no OCCURS clause"), name);
1520  return cb_error_node;
1521  }
1522  numsubs = f->indexes - 1;
1523  } else {
1524  numsubs = f->indexes;
1525  }
1526  if (unlikely(!r->flag_all)) {
1527  if (refsubs != numsubs) {
1528  if (refsubs > numsubs) {
1529  goto refsubserr;
1530  } else if (refsubs < numsubs) {
1531  if (!cb_relaxed_syntax_check) {
1532  goto refsubserr;
1533  } else {
1534  cb_warning_x (x,
1535  _("Subscripts missing for '%s' - Defaulting to 1"),
1536  name);
1537  for (; refsubs < numsubs; ++refsubs) {
1538  CB_ADD_TO_CHAIN (cb_one, r->subs);
1539  }
1540  }
1541  }
1542  }
1543 
1544  /* Run-time check for ODO (including all the fields subordinate items) */
1546  for (p = f; p; p = p->children) {
1547  if (p->depending) {
1548  e1 = CB_BUILD_FUNCALL_4 ("cob_check_odo",
1550  cb_int (p->occurs_min),
1551  cb_int (p->occurs_max),
1553  ((CB_FIELD_PTR (p->depending)->name)));
1554  r->check = cb_list_add (r->check, e1);
1555  }
1556  }
1557  }
1558 
1559  /* Subscript check along with setting of table offset */
1560  if (r->subs) {
1561  l = r->subs;
1562  for (p = f; p; p = p->parent) {
1563  if (!p->flag_occurs) {
1564  continue;
1565  }
1566 
1567 #if 1 /* RXWRXW - Sub check */
1568  if (!l) {
1569  break;
1570  }
1571 #endif
1572  sub = cb_check_integer_value (CB_VALUE (l));
1573  l = CB_CHAIN (l);
1574  if (sub == cb_error_node) {
1575  continue;
1576  }
1577 
1578  /* Compile-time check for all literals */
1579  if (CB_LITERAL_P (sub)) {
1580  n = cb_get_int (sub);
1581  if (n < 1 || n > p->occurs_max) {
1582  cb_error_x (x, _("Subscript of '%s' out of bounds: %d"),
1583  name, n);
1584  }
1585  if (p==f) {
1586  /* Only valid for single subscript (!) */
1587  f->mem_offset = f->size * (n - 1);
1588  }
1589  }
1590 
1591  /* Run-time check for all non-literals */
1593  if (p->depending) {
1594  e1 = CB_BUILD_FUNCALL_4 ("cob_check_subscript",
1595  cb_build_cast_int (sub),
1596  cb_int1,
1598  CB_BUILD_STRING0 (name));
1599  r->check = cb_list_add (r->check, e1);
1600  } else {
1601  if (!CB_LITERAL_P (sub)) {
1602  e1 = CB_BUILD_FUNCALL_4 ("cob_check_subscript",
1603  cb_build_cast_int (sub),
1604  cb_int1,
1605  cb_int (p->occurs_max),
1606  CB_BUILD_STRING0 (name));
1607  r->check = cb_list_add (r->check, e1);
1608  }
1609  }
1610  }
1611  }
1612  }
1613 
1614  }
1615 
1616  if (subchk) {
1617  r->subs = cb_list_reverse (r->subs);
1618  r->subs = cb_list_add (r->subs, cb_int1);
1619  r->subs = cb_list_reverse (r->subs);
1620  }
1621 
1622  /* Reference modification check */
1623  if ( f->usage == CB_USAGE_NATIONAL ) {
1624  pseudosize = f->size / 2;
1625  } else {
1626  pseudosize = f->size;
1627  }
1628  if (r->offset) {
1629  /* Compile-time check */
1630  if (CB_LITERAL_P (r->offset)) {
1631  offset = cb_get_int (r->offset);
1632  if (f->flag_any_length) {
1633  if (offset < 1) {
1634  cb_error_x (x, _("Offset of '%s' out of bounds: %d"), name, offset);
1635  } else if (r->length && CB_LITERAL_P (r->length)) {
1636  length = cb_get_int (r->length);
1637  if (length < 1) {
1638  cb_error_x (x, _("Length of '%s' out of bounds: %d"),
1639  name, length);
1640  }
1641  }
1642  } else {
1643  if (offset < 1 || offset > pseudosize) {
1644  cb_error_x (x, _("Offset of '%s' out of bounds: %d"), name, offset);
1645  } else if (r->length && CB_LITERAL_P (r->length)) {
1646  length = cb_get_int (r->length);
1647  if (length < 1 || length > pseudosize - offset + 1) {
1648  cb_error_x (x, _("Length of '%s' out of bounds: %d"),
1649  name, length);
1650  }
1651  }
1652  }
1653  }
1654 
1655  /* Run-time check */
1657  if (f->flag_any_length || !CB_LITERAL_P (r->offset) ||
1658  (r->length && !CB_LITERAL_P (r->length))) {
1659  e1 = CB_BUILD_FUNCALL_4 ("cob_check_ref_mod",
1661  r->length ?
1662  cb_build_cast_int (r->length) :
1663  cb_int1,
1664  f->flag_any_length ?
1665  CB_BUILD_CAST_LENGTH (v) :
1666  cb_int (pseudosize),
1667  CB_BUILD_STRING0 (f->name));
1668  r->check = cb_list_add (r->check, e1);
1669  }
1670  }
1671  }
1672 
1673  if (f->storage == CB_STORAGE_CONSTANT) {
1674  return CB_VALUE (f->values);
1675  }
1676 
1677  return x;
1678 
1679 refsubserr:
1680  switch (numsubs) {
1681  case 0:
1682  cb_error_x (x, _("'%s' cannot be subscripted"), name);
1683  break;
1684  case 1:
1685  cb_error_x (x, _("'%s' requires 1 subscript"), name);
1686  break;
1687  default:
1688  cb_error_x (x, _("'%s' requires %d subscripts"),
1689  name, f->indexes);
1690  break;
1691  }
1692  return cb_error_node;
1693 }
int indexes
Definition: tree.h:678
cb_tree check
Definition: tree.h:880
const char * name
Definition: tree.h:645
int occurs_max
Definition: tree.h:677
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_int1
Definition: tree.c:134
unsigned int flag_is_pdiv_opt
Definition: tree.h:725
unsigned int odo_level
Definition: tree.h:687
unsigned int flag_any_length
Definition: tree.h:712
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
static void cb_check_lit_subs(struct cb_reference *r, const int numsubs, const int numindex)
Definition: typeck.c:746
unsigned int flag_no_based
Definition: tree.h:1149
struct cb_field * children
Definition: tree.h:652
int occurs_min
Definition: tree.h:676
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
const char * name
Definition: tree.h:865
#define COB_MAX_WORDLEN
Definition: common.h:574
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_BINARY_OP_P(x)
Definition: tree.h:937
int cb_list_length(cb_tree l)
Definition: tree.c:1342
cb_tree depending
Definition: tree.h:647
unsigned int flag_all
Definition: tree.h:888
int offset
Definition: tree.h:675
#define CB_FIELD_P(x)
Definition: tree.h:741
unsigned int flag_is_pdiv_parm
Definition: tree.h:724
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define unlikely(x)
Definition: common.h:437
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree offset
Definition: tree.h:878
unsigned int flag_occurs
Definition: tree.h:702
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_one
Definition: tree.c:126
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
cb_tree cb_build_reference(const char *name)
Definition: tree.c:2572
cb_tree cb_error_node
Definition: tree.c:140
struct cb_field * parent
Definition: tree.h:651
cb_tree cb_build_address(cb_tree x)
Definition: typeck.c:1357
static cb_tree cb_check_integer_value(cb_tree x)
Definition: typeck.c:666
#define CB_ADD_TO_CHAIN(x, y)
Definition: tree.h:1854
#define CB_BUILD_STRING0(str)
Definition: tree.h:1849
#define CB_EXCEPTION_ENABLE(id)
Definition: cobc.h:243
int mem_offset
Definition: tree.h:681
#define CB_BINARY_OP(x)
Definition: tree.h:936
cb_tree subs
Definition: tree.h:877
cb_tree null_check
Definition: tree.h:1144
#define CB_BUILD_CAST_LENGTH(x)
Definition: tree.h:1843
cb_tree length
Definition: tree.h:879
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
struct cb_field * redefines
Definition: tree.h:654
cb_tree values
Definition: tree.h:648
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
enum cb_usage usage
Definition: tree.h:693
struct cb_statement * current_statement
Definition: parser.c:169
enum cb_storage storage
Definition: tree.h:692
struct cb_field * cb_field_founder(const struct cb_field *f)
Definition: tree.c:2227
#define CB_FIELD(x)
Definition: tree.h:740
struct cb_word * word
Definition: tree.h:881
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315
unsigned int flag_item_based
Definition: tree.h:713

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_if_check_break ( cb_tree  cond,
cb_tree  stmts 
)

Definition at line 5671 of file typeck.c.

References cb_build_if(), cb_check_needs_break(), and NULL.

Referenced by yyparse().

5672 {
5673  cb_tree stmt_lis;
5674 
5675  stmt_lis = cb_check_needs_break (stmts);
5676  return cb_build_if (cond, stmt_lis, NULL, 0);
5677 }
static cb_tree cb_check_needs_break(cb_tree stmt)
Definition: typeck.c:523
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_build_if(const cb_tree test, const cb_tree stmt1, const cb_tree stmt2, const unsigned int is_if)
Definition: tree.c:3132

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_index ( cb_tree  x,
cb_tree  values,
const unsigned int  indexed_by,
struct cb_field qual 
)

Definition at line 1337 of file typeck.c.

References cb_build_field(), CB_FIELD, CB_FIELD_ADD, CB_LIST_INIT, CB_USAGE_INDEX, cb_validate_field(), current_program, cb_field::flag_indexed_by, cb_field::index_qual, cb_field::usage, cb_field::values, and cb_program::working_storage.

Referenced by cb_build_length(), cb_build_registers(), and yyparse().

1339 {
1340  struct cb_field *f;
1341 
1342  f = CB_FIELD (cb_build_field (x));
1343  f->usage = CB_USAGE_INDEX;
1344  cb_validate_field (f);
1345  if (values) {
1346  f->values = CB_LIST_INIT (values);
1347  }
1348  if (qual) {
1349  f->index_qual = qual;
1350  }
1351  f->flag_indexed_by = !!indexed_by;
1353  return x;
1354 }
#define CB_FIELD_ADD(x, y)
Definition: tree.h:1856
cb_tree cb_build_field(cb_tree name)
Definition: tree.c:2159
Definition: tree.h:643
unsigned int flag_indexed_by
Definition: tree.h:721
struct cb_program * current_program
Definition: parser.c:168
#define CB_LIST_INIT(x)
Definition: tree.h:1851
struct cb_field * working_storage
Definition: tree.h:1276
struct cb_field * index_qual
Definition: tree.h:656
void cb_validate_field(struct cb_field *f)
Definition: field.c:1338
cb_tree values
Definition: tree.h:648
enum cb_usage usage
Definition: tree.h:693
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_inspect_region_start ( void  )

Definition at line 5961 of file typeck.c.

References CB_BUILD_FUNCALL_0, and CB_LIST_INIT.

Referenced by yyparse().

5962 {
5963  return CB_LIST_INIT (CB_BUILD_FUNCALL_0 ("cob_inspect_start"));
5964 }
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define CB_LIST_INIT(x)
Definition: tree.h:1851

Here is the caller graph for this function:

cb_tree cb_build_length ( cb_tree  x)

Definition at line 1781 of file typeck.c.

References cb_build_any_intrinsic(), cb_build_assign(), cb_build_filler(), cb_build_index(), cb_build_length_1(), cb_build_numeric_literal(), cb_emit, cb_error_node, CB_FIELD, cb_field_size(), cb_field_variable_size(), CB_INTRINSIC_P, CB_LIST_INIT, CB_LITERAL, CB_LITERAL_P, cb_ref(), CB_REF_OR_FIELD_P, CB_REFERENCE, CB_REFERENCE_P, CB_USAGE_LENGTH, cb_field::flag_any_length, NULL, and cb_literal::size.

Referenced by cb_build_intrinsic(), and yyparse().

1782 {
1783  struct cb_field *f;
1784  struct cb_literal *l;
1785  cb_tree temp;
1786  char buff[32];
1787 
1788  if (x == cb_error_node) {
1789  return cb_error_node;
1790  }
1791  if (CB_REFERENCE_P (x) && cb_ref (x) == cb_error_node) {
1792  return cb_error_node;
1793  }
1794 
1795  if (CB_LITERAL_P (x)) {
1796  l = CB_LITERAL (x);
1797  sprintf (buff, "%d", (int)l->size);
1798  return cb_build_numeric_literal (0, buff, 0);
1799  }
1800  if (CB_INTRINSIC_P (x)) {
1801  return cb_build_any_intrinsic (CB_LIST_INIT (x));
1802  }
1803  if (CB_REF_OR_FIELD_P (x)) {
1804  if (CB_REFERENCE_P (x) && CB_REFERENCE (x)->offset) {
1805  return cb_build_any_intrinsic (CB_LIST_INIT (x));
1806  }
1807  f = CB_FIELD (cb_ref (x));
1808  if (f->flag_any_length) {
1809  return cb_build_any_intrinsic (CB_LIST_INIT (x));
1810  }
1811  if (cb_field_variable_size (f) == NULL) {
1812  sprintf (buff, "%d", cb_field_size (x));
1813  return cb_build_numeric_literal (0, buff, 0);
1814  }
1815  }
1816  temp = cb_build_index (cb_build_filler (), NULL, 0, NULL);
1817  CB_FIELD (cb_ref (temp))->usage = CB_USAGE_LENGTH;
1818  CB_FIELD (cb_ref (temp))->count++;
1820  return temp;
1821 }
cb_tree cb_build_any_intrinsic(cb_tree args)
Definition: tree.c:3295
#define CB_REFERENCE_P(x)
Definition: tree.h:902
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
cb_tree cb_build_filler(void)
Definition: tree.c:2591
unsigned int flag_any_length
Definition: tree.h:712
#define CB_LITERAL(x)
Definition: tree.h:601
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
cb_tree cb_build_index(cb_tree x, cb_tree values, const unsigned int indexed_by, struct cb_field *qual)
Definition: typeck.c:1337
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
#define CB_LITERAL_P(x)
Definition: tree.h:602
cb_tree cb_build_numeric_literal(const int sign, const void *data, const int scale)
Definition: tree.c:1681
Definition: tree.h:643
static cb_tree cb_build_length_1(cb_tree x)
Definition: typeck.c:1696
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
#define CB_INTRINSIC_P(x)
Definition: tree.h:1002
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
#define CB_LIST_INIT(x)
Definition: tree.h:1851
#define cb_emit(x)
Definition: typeck.c:75
cob_u32_t size
Definition: tree.h:594
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_length_1 ( cb_tree  x)
static

Definition at line 1696 of file typeck.c.

References cb_build_binary_op(), cb_build_field_reference(), CB_FIELD, cb_field_size(), cb_field_variable_size(), cb_int(), cb_ref(), cb_field::children, cb_field::depending, cb_field::flag_odo_relative, NULL, cb_field::occurs_max, cb_field::sister, and cb_field::size.

Referenced by cb_build_length().

1697 {
1698  struct cb_field *f;
1699  cb_tree e;
1700  cb_tree size;
1701 
1702  f = CB_FIELD (cb_ref (x));
1703 
1704  if (cb_field_variable_size (f) == NULL) {
1705  /* Constant size */
1706  return cb_int (cb_field_size (x));
1707  }
1708  /* Variable size */
1709  e = NULL;
1710  for (f = f->children; f; f = f->sister) {
1712  if (f->depending) {
1713  if (!cb_flag_odoslide && f->flag_odo_relative) {
1714  size = cb_build_binary_op (size, '*',
1715  cb_int (f->occurs_max));
1716  } else {
1717  size = cb_build_binary_op (size, '*',
1718  f->depending);
1719  }
1720  } else if (f->occurs_max > 1) {
1721  size = cb_build_binary_op (size, '*',
1722  cb_int (f->occurs_max));
1723  }
1724  e = e ? cb_build_binary_op (e, '+', size) : size;
1725  }
1726  return e;
1727 }
int occurs_max
Definition: tree.h:677
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
unsigned int flag_odo_relative
Definition: tree.h:731
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
cb_tree depending
Definition: tree.h:647
Definition: tree.h:643
static cb_tree cb_build_length_1(cb_tree x)
Definition: typeck.c:1696
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_memset ( cb_tree  x,
const int  c 
)
static

Definition at line 6726 of file typeck.c.

References CB_BUILD_CAST_ADDRESS, CB_BUILD_CAST_LENGTH, CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, cb_field_size(), cb_int(), and cb_literal::size.

Referenced by cb_build_move_high(), cb_build_move_low(), cb_build_move_num_zero(), cb_build_move_quote(), cb_build_move_space(), and cb_build_move_zero().

6727 {
6728  int size = cb_field_size (x);
6729 
6730  if (size == 1) {
6731  return CB_BUILD_FUNCALL_2 ("$E", x, cb_int (c));
6732  }
6733  return CB_BUILD_FUNCALL_3 ("memset",
6735  cb_int (c), CB_BUILD_CAST_LENGTH (x));
6736 }
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
#define CB_BUILD_CAST_LENGTH(x)
Definition: tree.h:1843

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_move ( cb_tree  src,
cb_tree  dst 
)

Definition at line 7333 of file typeck.c.

References CB_ALPHABET_NAME_P, cb_build_assign(), cb_build_cast_int(), CB_BUILD_FUNCALL_2, cb_build_move_field(), cb_build_move_high(), cb_build_move_literal(), cb_build_move_low(), cb_build_move_quote(), cb_build_move_space(), cb_build_move_zero(), CB_CATEGORY_NUMERIC, CB_CATEGORY_NUMERIC_EDITED, CB_CLASS_POINTER, cb_error_node, cb_high, CB_INDEX_P, CB_INTRINSIC_P, CB_LITERAL_P, cb_low, cb_null, cb_quote, CB_REFERENCE, CB_REFERENCE_P, cb_space, CB_TREE, CB_TREE_CATEGORY, CB_TREE_CLASS, cb_zero, check, cobc_parse_malloc(), cb_reference::flag_receiving, validate_move(), and value.

Referenced by cb_build_add(), cb_build_div(), cb_build_mul(), cb_build_sub(), cb_check_field_debug(), cb_emit_close(), cb_emit_move(), cb_emit_open(), cb_emit_read(), cb_emit_release(), cb_emit_return(), cb_emit_rewrite(), cb_emit_set_false(), cb_emit_set_to(), cb_emit_set_true(), cb_emit_write(), emit_move_corresponding(), and output_move().

7334 {
7335  struct cb_reference *x;
7336 
7337  if (src == cb_error_node || dst == cb_error_node) {
7338  return cb_error_node;
7339  }
7340 
7341  if (validate_move (src, dst, 0) < 0) {
7342  return cb_error_node;
7343  }
7344 
7345 #if 0 /* Flag receiving */
7346  if (CB_REFERENCE_P (src)) {
7347  CB_REFERENCE (src)->flag_receiving = 0;
7348  }
7349 #endif
7350 
7351  if (CB_REFERENCE_P (dst)) {
7352  /* Clone reference */
7353  x = cobc_parse_malloc (sizeof(struct cb_reference));
7354  *x = *CB_REFERENCE (dst);
7355  x->flag_receiving = 1;
7356  dst = CB_TREE (x);
7357  }
7358 
7359  if ((src == cb_space || src == cb_low ||
7360  src == cb_high || src == cb_quote) &&
7363  src = cb_zero;
7364  }
7365 
7366  if (CB_TREE_CLASS (dst) == CB_CLASS_POINTER ||
7367  CB_TREE_CLASS (src) == CB_CLASS_POINTER) {
7368  return cb_build_assign (dst, src);
7369  }
7370 
7371  if (CB_REFERENCE_P (src) &&
7373  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7374  }
7375  if (CB_INDEX_P (dst)) {
7376  if (src == cb_null) {
7377  return cb_build_assign (dst, cb_zero);
7378  }
7379  return cb_build_assign (dst, src);
7380  }
7381 
7382  if (CB_INDEX_P (src)) {
7383  return CB_BUILD_FUNCALL_2 ("cob_set_int", dst,
7384  cb_build_cast_int (src));
7385  }
7386 
7387  if (CB_INTRINSIC_P (src) || CB_INTRINSIC_P (dst)) {
7388  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7389  }
7390 
7391  if (CB_REFERENCE_P (src) && CB_REFERENCE (src)->check) {
7392  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7393  }
7394  if (CB_REFERENCE_P (dst) && CB_REFERENCE (dst)->check) {
7395  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7396  }
7397 
7398  /* Output optimal code */
7399  if (src == cb_zero) {
7400  return cb_build_move_zero (dst);
7401  } else if (src == cb_space) {
7402  return cb_build_move_space (dst);
7403  } else if (src == cb_high) {
7404  return cb_build_move_high (dst);
7405  } else if (src == cb_low) {
7406  return cb_build_move_low (dst);
7407  } else if (src == cb_quote) {
7408  return cb_build_move_quote (dst);
7409  } else if (CB_LITERAL_P (src)) {
7410  return cb_build_move_literal (src, dst);
7411  }
7412  return cb_build_move_field (src, dst);
7413 }
#define CB_TREE(x)
Definition: tree.h:440
static cb_tree cb_build_move_field(cb_tree src, cb_tree dst)
Definition: typeck.c:7271
#define CB_REFERENCE_P(x)
Definition: tree.h:902
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack check
Definition: flag.def:99
void * cobc_parse_malloc(const size_t size)
Definition: cobc.c:809
static cb_tree cb_build_move_zero(cb_tree x)
Definition: typeck.c:6843
cb_tree cb_zero
Definition: tree.c:125
cb_tree cb_quote
Definition: tree.c:132
cb_tree cb_space
Definition: tree.c:127
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_TREE_CLASS(x)
Definition: tree.h:442
static cb_tree cb_build_move_literal(cb_tree src, cb_tree dst)
Definition: typeck.c:7038
int validate_move(cb_tree src, cb_tree dst, const unsigned int is_value)
Definition: typeck.c:6167
static cb_tree cb_build_move_quote(cb_tree x)
Definition: typeck.c:6904
strict implicit external value
Definition: warning.def:54
#define CB_INDEX_P(x)
Definition: tree.h:750
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
static cb_tree cb_build_move_high(cb_tree x)
Definition: typeck.c:6866
#define CB_REFERENCE(x)
Definition: tree.h:901
static cb_tree cb_build_move_space(cb_tree x)
Definition: typeck.c:6827
cb_tree cb_error_node
Definition: tree.c:140
#define CB_INTRINSIC_P(x)
Definition: tree.h:1002
unsigned int flag_receiving
Definition: tree.h:887
static cb_tree cb_build_move_low(cb_tree x)
Definition: typeck.c:6885
cb_tree cb_null
Definition: tree.c:124
cb_tree cb_high
Definition: tree.c:129
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
#define CB_ALPHABET_NAME_P(x)
Definition: tree.h:551
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
cb_tree cb_low
Definition: tree.c:128

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_copy ( cb_tree  src,
cb_tree  dst 
)
static

Definition at line 6739 of file typeck.c.

References CB_BUILD_CAST_ADDRESS, CB_BUILD_CAST_LENGTH, CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_FIELD_PTR, cb_field_size(), CB_STORAGE_LINKAGE, overlapping, and cb_literal::size.

Referenced by cb_build_move_field().

6740 {
6741  int size;
6742 
6743  size = cb_field_size (dst);
6744  if (size == 1) {
6745  return CB_BUILD_FUNCALL_2 ("$F", dst, src);
6746  }
6747  if (overlapping
6748  || CB_FIELD_PTR (src)->storage == CB_STORAGE_LINKAGE
6749  || CB_FIELD_PTR (dst)->storage == CB_STORAGE_LINKAGE
6750  || CB_FIELD_PTR (src)->flag_item_based
6751  || CB_FIELD_PTR (dst)->flag_item_based) {
6752  overlapping = 0;
6753  return CB_BUILD_FUNCALL_3 ("memmove",
6754  CB_BUILD_CAST_ADDRESS (dst),
6755  CB_BUILD_CAST_ADDRESS (src),
6756  CB_BUILD_CAST_LENGTH (dst));
6757  } else {
6758  return CB_BUILD_FUNCALL_3 ("memcpy",
6759  CB_BUILD_CAST_ADDRESS (dst),
6760  CB_BUILD_CAST_ADDRESS (src),
6761  CB_BUILD_CAST_LENGTH (dst));
6762  }
6763 }
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t overlapping
Definition: typeck.c:103
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_BUILD_CAST_LENGTH(x)
Definition: tree.h:1843

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_field ( cb_tree  src,
cb_tree  dst 
)
static

Definition at line 7271 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_move_copy(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, cb_field_size(), cb_field_variable_size(), CB_TREE_CATEGORY, CB_USAGE_DISPLAY, cb_picture::digits, cb_field::flag_any_length, cb_field::flag_binary_swap, cb_field::flag_justified, cb_field::flag_sign_leading, cb_field::flag_sign_separate, cb_picture::have_sign, cb_field::pic, cb_picture::scale, cb_picture::size, and cb_field::usage.

Referenced by cb_build_move().

7272 {
7273  struct cb_field *src_f;
7274  struct cb_field *dst_f;
7275  int src_size;
7276  int dst_size;
7277 
7278  src_f = CB_FIELD_PTR (src);
7279  src_size = cb_field_size (src);
7280  dst_f = CB_FIELD_PTR (dst);
7281  dst_size = cb_field_size (dst);
7282 
7283  if (dst_f->flag_any_length || src_f->flag_any_length) {
7284  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7285  }
7286  if (src_size > 0 && dst_size > 0 && src_size >= dst_size &&
7287  !cb_field_variable_size (src_f) &&
7288  !cb_field_variable_size (dst_f)) {
7289  switch (CB_TREE_CATEGORY (src)) {
7293  if (dst_f->flag_justified == 0) {
7294  return cb_build_move_copy (src, dst);
7295  }
7296  }
7297  break;
7300  if (dst_f->flag_justified == 0) {
7301  return cb_build_move_copy (src, dst);
7302  }
7303  }
7304  break;
7305  case CB_CATEGORY_NUMERIC:
7306  if (CB_TREE_CATEGORY (dst) == CB_CATEGORY_NUMERIC &&
7307  src_f->usage == dst_f->usage &&
7308  src_f->pic->size == dst_f->pic->size &&
7309  src_f->pic->digits == dst_f->pic->digits &&
7310  src_f->pic->scale == dst_f->pic->scale &&
7311  src_f->pic->have_sign == dst_f->pic->have_sign &&
7312  src_f->flag_binary_swap == dst_f->flag_binary_swap &&
7313  src_f->flag_sign_leading == dst_f->flag_sign_leading &&
7314  src_f->flag_sign_separate == dst_f->flag_sign_separate) {
7315  return cb_build_move_copy (src, dst);
7316  } else if (CB_TREE_CATEGORY (dst) == CB_CATEGORY_ALPHANUMERIC
7317  && src_f->usage == CB_USAGE_DISPLAY
7318  && src_f->pic->have_sign == 0
7319  && !src_f->flag_sign_leading
7320  && !src_f->flag_sign_separate) {
7321  return cb_build_move_copy (src, dst);
7322  }
7323  break;
7324  default:
7325  break;
7326  }
7327  }
7328 
7329  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7330 }
unsigned int flag_justified
Definition: tree.h:706
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
int size
Definition: tree.h:622
int scale
Definition: tree.h:626
unsigned int flag_any_length
Definition: tree.h:712
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
cob_u32_t digits
Definition: tree.h:625
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
unsigned int flag_sign_leading
Definition: tree.h:704
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
unsigned int flag_binary_swap
Definition: tree.h:707
cob_u32_t have_sign
Definition: tree.h:627
unsigned int flag_sign_separate
Definition: tree.h:703
static cb_tree cb_build_move_copy(cb_tree src, cb_tree dst)
Definition: typeck.c:6739
enum cb_usage usage
Definition: tree.h:693

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_high ( cb_tree  x)
static

Definition at line 6866 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_memset(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, cb_high, cb_norm_high, CB_TREE_CATEGORY, and cb_field::flag_any_length.

Referenced by cb_build_move().

6867 {
6868  switch (CB_TREE_CATEGORY (x)) {
6869  case CB_CATEGORY_NUMERIC:
6872  if (CB_FIELD_PTR (x)->flag_any_length) {
6873  return CB_BUILD_FUNCALL_2 ("cob_move", cb_high, x);
6874  }
6875  if (cb_high == cb_norm_high) {
6876  return cb_build_memset (x, 255);
6877  }
6878  /* Fall through */
6879  default:
6880  return CB_BUILD_FUNCALL_2 ("cob_move", cb_high, x);
6881  }
6882 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
unsigned int flag_any_length
Definition: tree.h:712
cb_tree cb_norm_high
Definition: tree.c:131
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_high
Definition: tree.c:129
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_literal ( cb_tree  src,
cb_tree  dst 
)
static

Definition at line 7038 of file typeck.c.

References cb_literal::all, cb_build_assign(), CB_BUILD_CAST_ADDRESS, CB_BUILD_CAST_LENGTH, cb_build_cast_llint(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, cb_build_move_num_zero(), cb_build_string(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_CATEGORY_NUMERIC_EDITED, CB_FIELD_PTR, cb_field_variable_size(), cb_fits_int(), cb_get_int(), cb_int(), CB_LITERAL, CB_STORAGE_LINKAGE, CB_TREE_CATEGORY, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_6, CB_USAGE_COMP_X, CB_USAGE_DISPLAY, CB_USAGE_PACKED, cob_put_sign_ascii(), cob_put_sign_ebcdic(), cobc_parse_free(), cobc_parse_malloc(), cb_literal::data, cb_field::flag_binary_swap, cb_field::flag_blank_zero, cb_field::flag_justified, cb_field::flag_sign_leading, cb_field::flag_sign_separate, cb_picture::have_sign, cb_field::indexes, cb_field::offset, optim_table::optim_val, optimize_defs, cb_field::pic, cb_literal::scale, cb_picture::scale, cb_literal::sign, cb_literal::size, cb_field::size, cb_field::storage, and cb_field::usage.

Referenced by cb_build_move().

7039 {
7040  struct cb_literal *l;
7041  struct cb_field *f;
7042  unsigned char *buff;
7043  unsigned char *p;
7044  enum cb_category cat;
7045  int i;
7046  int diff;
7047  int val;
7048  int n;
7049  unsigned char bbyte;
7050 
7051  l = CB_LITERAL (src);
7052  f = CB_FIELD_PTR (dst);
7053  cat = CB_TREE_CATEGORY (dst);
7054 
7055  if (l->all) {
7056  if (cat == CB_CATEGORY_NUMERIC ||
7057  cat == CB_CATEGORY_NUMERIC_EDITED) {
7058  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7059  }
7060  if (l->size == 1) {
7061  return CB_BUILD_FUNCALL_3 ("memset",
7062  CB_BUILD_CAST_ADDRESS (dst),
7063  cb_int (l->data[0]),
7064  CB_BUILD_CAST_LENGTH (dst));
7065  }
7066  bbyte = l->data[0];
7067  for (i = 0; i < (int)l->size; i++) {
7068  if (bbyte != l->data[i]) {
7069  break;
7070  }
7071  bbyte = l->data[i];
7072  }
7073  if (i == (int)l->size) {
7074  return CB_BUILD_FUNCALL_3 ("memset",
7075  CB_BUILD_CAST_ADDRESS (dst),
7076  cb_int (l->data[0]),
7077  CB_BUILD_CAST_LENGTH (dst));
7078  }
7079  if (f->size > 128) {
7080  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7081  }
7082  buff = cobc_parse_malloc ((size_t)f->size);
7083  for (i = 0; i < f->size; i++) {
7084  buff[i] = l->data[i % l->size];
7085  }
7086  return CB_BUILD_FUNCALL_3 ("memcpy",
7087  CB_BUILD_CAST_ADDRESS (dst),
7088  cb_build_string (buff, (size_t)f->size),
7089  CB_BUILD_CAST_LENGTH (dst));
7090  }
7091 
7092  if (cat == CB_CATEGORY_NUMERIC_EDITED) {
7093  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7094  }
7095 
7096  if ((cat == CB_CATEGORY_NUMERIC &&
7097  f->usage == CB_USAGE_DISPLAY &&
7098  f->pic->scale == l->scale &&
7100  !f->flag_blank_zero) ||
7101  ((cat == CB_CATEGORY_ALPHABETIC ||
7102  cat == CB_CATEGORY_ALPHANUMERIC) &&
7103  f->size < (int) (l->size + 16) &&
7104  !cb_field_variable_size (f))) {
7105  buff = cobc_parse_malloc ((size_t)f->size);
7106  diff = (int) (f->size - l->size);
7107  if (cat == CB_CATEGORY_NUMERIC) {
7108  if (diff <= 0) {
7109  memcpy (buff, l->data - diff, (size_t)f->size);
7110  } else {
7111  memset (buff, '0', (size_t)diff);
7112  memcpy (buff + diff, l->data, (size_t)l->size);
7113  }
7114  /* Check all zeros */
7115  n = 0;
7116  for (p = buff; p < buff + f->size; p++) {
7117  if (*p != '0') {
7118  n = 1;
7119  break;
7120  }
7121  }
7122  if (f->pic->have_sign) {
7123  p = &buff[f->size - 1];
7124  if (!n) {
7125  /* Zeros */
7126  /* EBCDIC - store sign otherwise nothing */
7127  if (cb_ebcdic_sign) {
7128  cob_put_sign_ebcdic (p, 1);
7129  }
7130  } else if (cb_ebcdic_sign) {
7131  cob_put_sign_ebcdic (p, l->sign);
7132  } else if (l->sign < 0) {
7133 #ifdef COB_EBCDIC_MACHINE
7134  cob_put_sign_ascii (p);
7135 #else
7136  *p += 0x40;
7137 #endif
7138  }
7139  }
7140  } else {
7141  if (f->flag_justified) {
7142  if (diff <= 0) {
7143  memcpy (buff, l->data - diff, (size_t)f->size);
7144  } else {
7145  memset (buff, ' ', (size_t)diff);
7146  memcpy (buff + diff, l->data, (size_t)l->size);
7147  }
7148  } else {
7149  if (diff <= 0) {
7150  memcpy (buff, l->data, (size_t)f->size);
7151  } else {
7152  memcpy (buff, l->data, (size_t)l->size);
7153  memset (buff + l->size, ' ', (size_t)diff);
7154  }
7155  }
7156  }
7157  bbyte = *buff;
7158  if (f->size == 1) {
7159  cobc_parse_free (buff);
7160  return CB_BUILD_FUNCALL_2 ("$E", dst, cb_int (bbyte));
7161  }
7162  for (i = 0; i < f->size; i++) {
7163  if (bbyte != buff[i]) {
7164  break;
7165  }
7166  }
7167  if (i == f->size) {
7168  cobc_parse_free (buff);
7169  return CB_BUILD_FUNCALL_3 ("memset",
7170  CB_BUILD_CAST_ADDRESS (dst),
7171  cb_int (bbyte),
7172  CB_BUILD_CAST_LENGTH (dst));
7173  }
7174  return CB_BUILD_FUNCALL_3 ("memcpy",
7175  CB_BUILD_CAST_ADDRESS (dst),
7176  cb_build_string (buff, (size_t)f->size),
7177  CB_BUILD_CAST_LENGTH (dst));
7178  }
7179 
7180  if ((f->usage == CB_USAGE_BINARY ||
7181  f->usage == CB_USAGE_COMP_5 ||
7182  f->usage == CB_USAGE_COMP_X) &&
7183  cb_fits_int (src) && f->size <= 8) {
7184  val = cb_get_int (src);
7185  n = f->pic->scale - l->scale;
7186  if ((l->size + n) > 9) {
7187  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7188  }
7189  for (; n > 0; n--) {
7190  val *= 10;
7191  }
7192  for (; n < 0; n++) {
7193  val /= 10;
7194  }
7195  if (val == 0) {
7196  return cb_build_move_num_zero (dst);
7197  }
7198  if (val < 0 && !f->pic->have_sign) {
7199  val = -val;
7200  }
7201  if (f->size == 1) {
7202  return cb_build_assign (dst, cb_int (val));
7203  }
7204  if (f->flag_binary_swap) {
7205  i = (f->size - 1) + (8 * (f->pic->have_sign ? 1 : 0));
7207  return CB_BUILD_FUNCALL_2 (bin_set_funcs[i].optim_name,
7208  CB_BUILD_CAST_ADDRESS (dst),
7209  cb_int (val));
7210  }
7211  switch (f->size) {
7212  case 2:
7213 #ifdef COB_SHORT_BORK
7214  if (f->storage != CB_STORAGE_LINKAGE && f->indexes == 0 &&
7215  (f->offset % 4 == 0)) {
7216  return cb_build_assign (dst, cb_int (val));
7217  }
7218  break;
7219 #endif
7220  case 4:
7221  case 8:
7222 #ifdef COB_NON_ALIGNED
7223  if (f->storage != CB_STORAGE_LINKAGE && f->indexes == 0 &&
7224  (f->offset % f->size == 0)) {
7225  return cb_build_assign (dst, cb_int (val));
7226  }
7227  break;
7228 #else
7229  return cb_build_assign (dst, cb_int (val));
7230 #endif
7231  default:
7232  break;
7233  }
7234  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7235  }
7236 
7237  if ((f->usage == CB_USAGE_PACKED || f->usage == CB_USAGE_COMP_6) &&
7238  cb_fits_int (src)) {
7239  if (f->pic->scale < 0) {
7240  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7241  }
7242  val = cb_get_int (src);
7243  n = f->pic->scale - l->scale;
7244  if ((l->size + n) > 9) {
7245  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7246  }
7247  for (; n > 0; n--) {
7248  val *= 10;
7249  }
7250  for (; n < 0; n++) {
7251  val /= 10;
7252  }
7253  if (val == 0) {
7254  return cb_build_move_num_zero (dst);
7255  }
7256  if (val < 0 && !f->pic->have_sign) {
7257  val = -val;
7258  }
7259 #if 1 /* RXWRXW - Set packed */
7260  return CB_BUILD_FUNCALL_2 ("cob_set_packed_int", dst,
7261  cb_int (val));
7262 #else
7263  return CB_BUILD_FUNCALL_2 ("cob_set_packed_int", dst,
7264  cb_build_cast_llint (src));
7265 #endif
7266  }
7267  return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
7268 }
unsigned int flag_justified
Definition: tree.h:706
int indexes
Definition: tree.h:678
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
short sign
Definition: tree.h:597
int scale
Definition: tree.h:626
void * cobc_parse_malloc(const size_t size)
Definition: cobc.c:809
static void cob_put_sign_ebcdic(unsigned char *p, const int sign)
Definition: typeck.c:6959
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
struct cb_picture * pic
Definition: tree.h:659
static cb_tree cb_build_move_num_zero(cb_tree x)
Definition: typeck.c:6766
enum cb_optim optim_val
Definition: typeck.c:53
cb_category
Definition: tree.h:226
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
cb_tree cb_build_string(const void *data, const size_t size)
Definition: tree.c:1526
short all
Definition: tree.h:598
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int offset
Definition: tree.h:675
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
unsigned int flag_sign_leading
Definition: tree.h:704
void cobc_parse_free(void *prevptr)
Definition: cobc.c:885
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
int scale
Definition: tree.h:595
cb_tree cb_build_cast_llint(const cb_tree val)
Definition: tree.c:2975
unsigned int flag_binary_swap
Definition: tree.h:707
int cb_fits_int(const cb_tree x)
Definition: tree.c:914
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
unsigned char * data
Definition: tree.h:593
unsigned int flag_blank_zero
Definition: tree.h:705
cob_u32_t have_sign
Definition: tree.h:627
unsigned int flag_sign_separate
Definition: tree.h:703
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
static void cob_put_sign_ascii(unsigned char *p)
Definition: common.c:699
#define CB_BUILD_CAST_LENGTH(x)
Definition: tree.h:1843
static const struct optim_table bin_set_funcs[]
Definition: typeck.c:289
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
cob_u32_t size
Definition: tree.h:594
enum cb_usage usage
Definition: tree.h:693
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_low ( cb_tree  x)
static

Definition at line 6885 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_memset(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, cb_low, cb_norm_low, CB_TREE_CATEGORY, and cb_field::flag_any_length.

Referenced by cb_build_move().

6886 {
6887  switch (CB_TREE_CATEGORY (x)) {
6888  case CB_CATEGORY_NUMERIC:
6891  if (CB_FIELD_PTR (x)->flag_any_length) {
6892  return CB_BUILD_FUNCALL_2 ("cob_move", cb_low, x);
6893  }
6894  if (cb_low == cb_norm_low) {
6895  return cb_build_memset (x, 0);
6896  }
6897  /* Fall through */
6898  default:
6899  return CB_BUILD_FUNCALL_2 ("cob_move", cb_low, x);
6900  }
6901 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
unsigned int flag_any_length
Definition: tree.h:712
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_norm_low
Definition: tree.c:130
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726
cb_tree cb_low
Definition: tree.c:128

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_num_zero ( cb_tree  x)
static

Definition at line 6766 of file typeck.c.

References cb_build_assign(), CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_2, cb_build_memset(), CB_FIELD_PTR, cb_int0, CB_STORAGE_LINKAGE, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_6, CB_USAGE_COMP_X, CB_USAGE_DISPLAY, CB_USAGE_PACKED, cb_zero, cb_field::flag_binary_swap, cb_picture::have_sign, cb_field::indexes, cb_field::offset, cb_field::pic, cb_field::size, cb_field::storage, and cb_field::usage.

Referenced by cb_build_move_literal(), and cb_build_move_zero().

6767 {
6768  struct cb_field *f;
6769 
6770  f = CB_FIELD_PTR (x);
6771  switch (f->usage) {
6772  case CB_USAGE_BINARY:
6773  case CB_USAGE_COMP_5:
6774  case CB_USAGE_COMP_X:
6775  if (f->flag_binary_swap) {
6776  return cb_build_memset (x, 0);
6777  }
6778  switch (f->size) {
6779 #ifdef COB_NON_ALIGNED
6780  case 1:
6781  return cb_build_assign (x, cb_int0);
6782  case 2:
6783 #ifdef COB_SHORT_BORK
6784  if (f->storage != CB_STORAGE_LINKAGE && f->indexes == 0 &&
6785  (f->offset % 4 == 0)) {
6786  return cb_build_assign (x, cb_int0);
6787  }
6788  break;
6789 #endif
6790  case 4:
6791  case 8:
6792  if (f->storage != CB_STORAGE_LINKAGE && f->indexes == 0 &&
6793  (f->offset % f->size == 0)) {
6794  return cb_build_assign (x, cb_int0);
6795  }
6796  break;
6797 #else
6798  case 1:
6799  case 2:
6800  case 4:
6801  case 8:
6802  return cb_build_assign (x, cb_int0);
6803 #endif
6804  default:
6805  break;
6806  }
6807  return cb_build_memset (x, 0);
6808  case CB_USAGE_DISPLAY:
6809  if (!cb_ebcdic_sign) {
6810  return cb_build_memset (x, '0');
6811  }
6812  if (f->pic && !f->pic->have_sign) {
6813  return cb_build_memset (x, '0');
6814  }
6815  break;
6816  case CB_USAGE_PACKED:
6817  return CB_BUILD_FUNCALL_1 ("cob_set_packed_zero", x);
6818  case CB_USAGE_COMP_6:
6819  return cb_build_memset (x, 0);
6820  default:
6821  break;
6822  }
6823  return CB_BUILD_FUNCALL_2 ("cob_move", cb_zero, x);
6824 }
int indexes
Definition: tree.h:678
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
cb_tree cb_zero
Definition: tree.c:125
int offset
Definition: tree.h:675
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int0
Definition: tree.c:133
unsigned int flag_binary_swap
Definition: tree.h:707
int size
Definition: tree.h:672
cob_u32_t have_sign
Definition: tree.h:627
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
enum cb_usage usage
Definition: tree.h:693
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_quote ( cb_tree  x)
static

Definition at line 6904 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_memset(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, cb_quote, CB_TREE_CATEGORY, and cb_field::flag_any_length.

Referenced by cb_build_move().

6905 {
6906  switch (CB_TREE_CATEGORY (x)) {
6907  case CB_CATEGORY_NUMERIC:
6910  if (!CB_FIELD_PTR (x)->flag_any_length) {
6911  return cb_build_memset (x, cb_flag_apostrophe ? '\'' : '"');
6912  }
6913  /* Fall through */
6914  default:
6915  return CB_BUILD_FUNCALL_2 ("cob_move", cb_quote, x);
6916  }
6917 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
unsigned int flag_any_length
Definition: tree.h:712
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_quote
Definition: tree.c:132
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_space ( cb_tree  x)
static

Definition at line 6827 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_memset(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, cb_space, CB_TREE_CATEGORY, and cb_field::flag_any_length.

Referenced by cb_build_move(), and cb_build_move_zero().

6828 {
6829  switch (CB_TREE_CATEGORY (x)) {
6830  case CB_CATEGORY_NUMERIC:
6833  if (!CB_FIELD_PTR (x)->flag_any_length) {
6834  return cb_build_memset (x, ' ');
6835  }
6836  /* Fall through */
6837  default:
6838  return CB_BUILD_FUNCALL_2 ("cob_move", cb_space, x);
6839  }
6840 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
unsigned int flag_any_length
Definition: tree.h:712
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_space
Definition: tree.c:127
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_move_zero ( cb_tree  x)
static

Definition at line 6843 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_build_memset(), cb_build_move_num_zero(), cb_build_move_space(), CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NUMERIC, CB_FIELD_PTR, CB_TREE_CATEGORY, cb_zero, cb_field::flag_any_length, cb_field::flag_blank_zero, and cb_field::flag_sign_separate.

Referenced by cb_build_move().

6844 {
6845  switch (CB_TREE_CATEGORY (x)) {
6846  case CB_CATEGORY_NUMERIC:
6847  if (CB_FIELD_PTR (x)->flag_blank_zero) {
6848  return cb_build_move_space (x);
6849  } else if (CB_FIELD_PTR (x)->flag_sign_separate) {
6850  return CB_BUILD_FUNCALL_2 ("cob_move", cb_zero, x);
6851  } else {
6852  return cb_build_move_num_zero (x);
6853  }
6856  if (!CB_FIELD_PTR (x)->flag_any_length) {
6857  return cb_build_memset (x, '0');
6858  }
6859  /* Fall through */
6860  default:
6861  return CB_BUILD_FUNCALL_2 ("cob_move", cb_zero, x);
6862  }
6863 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
unsigned int flag_any_length
Definition: tree.h:712
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_zero
Definition: tree.c:125
static cb_tree cb_build_move_num_zero(cb_tree x)
Definition: typeck.c:6766
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
static cb_tree cb_build_move_space(cb_tree x)
Definition: typeck.c:6827
unsigned int flag_blank_zero
Definition: tree.h:705
unsigned int flag_sign_separate
Definition: tree.h:703
static cb_tree cb_build_memset(cb_tree x, const int c)
Definition: typeck.c:6726

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_mul ( cb_tree  v,
cb_tree  n,
cb_tree  round_opt 
)
static

Definition at line 3368 of file typeck.c.

References build_store_option(), cb_build_binary_op(), CB_BUILD_FUNCALL_3, cb_build_move(), CB_FIELD_PTR, CB_INDEX_P, CB_REF_OR_FIELD_P, and cb_field::count.

Referenced by cb_emit_arithmetic().

3369 {
3370  cb_tree opt;
3371  struct cb_field *f;
3372 
3373  if (CB_INDEX_P (v)) {
3374  return cb_build_move (cb_build_binary_op (v, '*', n), v);
3375  }
3376 
3377  if (CB_REF_OR_FIELD_P (v)) {
3378  f = CB_FIELD_PTR (v);
3379  f->count++;
3380  }
3381  if (CB_REF_OR_FIELD_P (n)) {
3382  f = CB_FIELD_PTR (n);
3383  f->count++;
3384  }
3385  opt = build_store_option (v, round_opt);
3386  return CB_BUILD_FUNCALL_3 ("cob_mul", v, n, opt);
3387 }
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_INDEX_P(x)
Definition: tree.h:750
Definition: tree.h:643
int count
Definition: tree.h:680
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_optim_add ( cb_tree  v,
cb_tree  n 
)
static

Definition at line 3876 of file typeck.c.

References cb_build_assign(), cb_build_binary_op(), CB_BUILD_CAST_ADDRESS, cb_build_cast_int(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_FIELD_PTR, cb_int0, CB_REF_OR_FIELD_P, CB_STORAGE_LINKAGE, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_X, CB_USAGE_PACKED, COB_ADD_PACKED_INT, cb_picture::digits, cb_field::flag_binary_swap, cb_picture::have_sign, cb_field::indexes, cb_field::offset, optim_table::optim_val, optimize_defs, cb_field::pic, cb_picture::scale, cb_field::size, cb_field::storage, and cb_field::usage.

Referenced by cb_build_add().

3877 {
3878  size_t z;
3879  const char *s;
3880  struct cb_field *f;
3881 
3882  if (CB_REF_OR_FIELD_P (v)) {
3883  f = CB_FIELD_PTR (v);
3884  if (!f->pic) {
3885  return CB_BUILD_FUNCALL_3 ("cob_add_int", v,
3886  cb_build_cast_int (n),
3887  cb_int0);
3888  }
3889  if (!f->pic->scale && (f->usage == CB_USAGE_BINARY ||
3890  f->usage == CB_USAGE_COMP_5 ||
3891  f->usage == CB_USAGE_COMP_X)) {
3892  z = (f->size - 1) + (8 * (f->pic->have_sign ? 1 : 0)) +
3893  (16 * (f->flag_binary_swap ? 1 : 0));
3894 #if defined(COB_NON_ALIGNED) && !defined(_MSC_VER)
3895  switch (f->size) {
3896  case 2:
3897 #ifdef COB_SHORT_BORK
3899  s = bin_add_funcs[z].optim_name;
3900  break;
3901 #endif
3902  case 4:
3903  case 8:
3904  if (f->storage != CB_STORAGE_LINKAGE &&
3905  f->indexes == 0 &&
3906  (f->offset % f->size) == 0) {
3907  optimize_defs[align_bin_add_funcs[z].optim_val] = 1;
3908  s = align_bin_add_funcs[z].optim_name;
3909  } else {
3910  optimize_defs[bin_add_funcs[z].optim_val] = 1;
3911  s = bin_add_funcs[z].optim_name;
3912  }
3913  break;
3914  default:
3915  optimize_defs[bin_add_funcs[z].optim_val] = 1;
3916  s = bin_add_funcs[z].optim_name;
3917  break;
3918  }
3919 #else
3920  if (f->usage == CB_USAGE_COMP_5) {
3921  switch (f->size) {
3922  case 1:
3923  case 2:
3924  case 4:
3925  case 8:
3926  return cb_build_assign (v, cb_build_binary_op (v, '+', n));
3927  default:
3928  break;
3929  }
3930  }
3931  optimize_defs[bin_add_funcs[z].optim_val] = 1;
3932  s = bin_add_funcs[z].optim_name;
3933 #endif
3934  if (s) {
3935  return CB_BUILD_FUNCALL_2 (s,
3937  cb_build_cast_int (n));
3938  }
3939  } else if (!f->pic->scale && f->usage == CB_USAGE_PACKED &&
3940  f->pic->digits < 10) {
3942  return CB_BUILD_FUNCALL_2 ("cob_add_packed_int",
3943  v, cb_build_cast_int (n));
3944  }
3945  }
3946  return CB_BUILD_FUNCALL_3 ("cob_add_int", v,
3947  cb_build_cast_int (n), cb_int0);
3948 }
int indexes
Definition: tree.h:678
int scale
Definition: tree.h:626
static const struct optim_table bin_add_funcs[]
Definition: typeck.c:343
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
cob_u32_t digits
Definition: tree.h:625
enum cb_optim optim_val
Definition: typeck.c:53
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int offset
Definition: tree.h:675
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int0
Definition: tree.c:133
unsigned int flag_binary_swap
Definition: tree.h:707
int size
Definition: tree.h:672
cob_u32_t have_sign
Definition: tree.h:627
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_optim_cond ( struct cb_binary_op p)
static

Definition at line 3558 of file typeck.c.

References CB_BUILD_CAST_ADDRESS, cb_build_cast_int(), cb_build_cast_llint(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_4, CB_FIELD_PTR, cb_fits_long_long(), cb_int(), CB_REF_OR_FIELD_P, CB_STORAGE_LINKAGE, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_6, CB_USAGE_COMP_X, CB_USAGE_DISPLAY, CB_USAGE_INDEX, CB_USAGE_PACKED, COB_CMP_PACKED_INT, cb_picture::digits, cb_field::flag_any_numeric, cb_field::flag_binary_swap, cb_field::flag_sign_leading, cb_field::flag_sign_separate, cb_picture::have_sign, cb_field::indexes, cb_field::offset, optim_table::optim_val, optimize_defs, cb_field::pic, cb_picture::scale, cb_field::size, cb_field::special_index, cb_field::storage, cb_field::usage, cb_binary_op::x, and cb_binary_op::y.

Referenced by cb_build_cond().

3559 {
3560  struct cb_field *f;
3561  const char *s;
3562  size_t n;
3563 
3564 #if 0 /* RXWRXW - US */
3565  struct cb_field *fy;
3566  if (CB_REF_OR_FIELD_P (p->y)) {
3567  fy = CB_FIELD_PTR (p->y);
3568  if (!fy->pic->have_sign && (fy->usage == CB_USAGE_BINARY ||
3569  fy->usage == CB_USAGE_COMP_5 ||
3570  fy->usage == CB_USAGE_COMP_X)) {
3571  return CB_BUILD_FUNCALL_2 ("cob_cmp_uint", p->x,
3572  cb_build_cast_int (p->y));
3573  }
3574  }
3575 #endif
3576 
3577  if (!CB_REF_OR_FIELD_P (p->x)) {
3578  return CB_BUILD_FUNCALL_2 ("cob_cmp_llint", p->x,
3579  cb_build_cast_llint (p->y));
3580  }
3581 
3582  f = CB_FIELD_PTR (p->x);
3583 #if 0 /* RXWRXW - SI */
3584  if (f->special_index) {
3585  return CB_BUILD_FUNCALL_2 ("cob_cmp_special",
3586  cb_build_cast_int (p->x),
3587  cb_build_cast_int (p->y));
3588  }
3589 #endif
3590  if (f->pic->scale || f->flag_any_numeric) {
3591  return CB_BUILD_FUNCALL_2 ("cob_cmp_llint", p->x,
3592  cb_build_cast_llint (p->y));
3593  }
3594  if (f->usage == CB_USAGE_PACKED) {
3595  if (f->pic->digits < 19) {
3597  return CB_BUILD_FUNCALL_2 ("cob_cmp_packed_int",
3598  p->x,
3599  cb_build_cast_llint (p->y));
3600  } else {
3601  return CB_BUILD_FUNCALL_2 ("cob_cmp_packed",
3602  p->x,
3603  cb_build_cast_llint (p->y));
3604  }
3605  }
3606  if (f->usage == CB_USAGE_COMP_6) {
3607  return CB_BUILD_FUNCALL_2 ("cob_cmp_packed",
3608  p->x,
3609  cb_build_cast_llint (p->y));
3610  }
3611  if (f->usage == CB_USAGE_DISPLAY &&
3613  if (cb_fits_long_long (p->x)) {
3614  return CB_BUILD_FUNCALL_4 ("cob_cmp_numdisp",
3615  CB_BUILD_CAST_ADDRESS (p->x),
3616  cb_int (f->size),
3617  cb_build_cast_llint (p->y),
3618  cb_int (f->pic->have_sign ? 1 : 0));
3619  }
3620  return CB_BUILD_FUNCALL_2 ("cob_cmp_llint", p->x,
3621  cb_build_cast_llint (p->y));
3622  }
3623  if (f->usage == CB_USAGE_BINARY ||
3624  f->usage == CB_USAGE_COMP_5 ||
3625  f->usage == CB_USAGE_INDEX ||
3626  f->usage == CB_USAGE_COMP_X) {
3627  n = (f->size - 1) + (8 * (f->pic->have_sign ? 1 : 0)) +
3628  (16 * (f->flag_binary_swap ? 1 : 0));
3629 #if defined(COB_NON_ALIGNED) && !defined(_MSC_VER)
3630  switch (f->size) {
3631  case 2:
3632 #ifdef COB_SHORT_BORK
3634  s = bin_compare_funcs[n].optim_name;
3635  break;
3636 #endif
3637  case 4:
3638  case 8:
3639  if (f->storage != CB_STORAGE_LINKAGE &&
3640  f->indexes == 0 && (f->offset % f->size) == 0) {
3641  optimize_defs[align_bin_compare_funcs[n].optim_val] = 1;
3642  s = align_bin_compare_funcs[n].optim_name;
3643  } else {
3644  optimize_defs[bin_compare_funcs[n].optim_val] = 1;
3645  s = bin_compare_funcs[n].optim_name;
3646  }
3647  break;
3648  default:
3649  optimize_defs[bin_compare_funcs[n].optim_val] = 1;
3650  s = bin_compare_funcs[n].optim_name;
3651  break;
3652  }
3653 #else
3654  optimize_defs[bin_compare_funcs[n].optim_val] = 1;
3655  s = bin_compare_funcs[n].optim_name;
3656 #endif
3657  if (s) {
3658  return CB_BUILD_FUNCALL_2 (s,
3659  CB_BUILD_CAST_ADDRESS (p->x),
3660  cb_build_cast_llint (p->y));
3661  }
3662  }
3663  return CB_BUILD_FUNCALL_2 ("cob_cmp_llint", p->x,
3664  cb_build_cast_llint (p->y));
3665 }
int indexes
Definition: tree.h:678
int scale
Definition: tree.h:626
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
struct cb_picture * pic
Definition: tree.h:659
cob_u32_t digits
Definition: tree.h:625
enum cb_optim optim_val
Definition: typeck.c:53
cob_u32_t special_index
Definition: tree.h:690
int cb_fits_long_long(const cb_tree x)
Definition: tree.c:991
int offset
Definition: tree.h:675
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
unsigned int flag_sign_leading
Definition: tree.h:704
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_build_cast_llint(const cb_tree val)
Definition: tree.c:2975
unsigned int flag_binary_swap
Definition: tree.h:707
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
static const struct optim_table bin_compare_funcs[]
Definition: typeck.c:308
unsigned int flag_any_numeric
Definition: tree.h:736
cb_tree y
Definition: tree.h:931
cob_u32_t have_sign
Definition: tree.h:627
unsigned int flag_sign_separate
Definition: tree.h:703
cb_tree x
Definition: tree.h:930
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_optim_sub ( cb_tree  v,
cb_tree  n 
)
static

Definition at line 3951 of file typeck.c.

References cb_build_assign(), cb_build_binary_op(), CB_BUILD_CAST_ADDRESS, cb_build_cast_int(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_FIELD_PTR, cb_int0, CB_REF_OR_FIELD_P, CB_STORAGE_LINKAGE, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_X, cb_field::flag_binary_swap, cb_picture::have_sign, cb_field::indexes, cb_field::offset, optim_table::optim_val, optimize_defs, cb_field::pic, cb_picture::scale, cb_field::size, cb_field::storage, and cb_field::usage.

Referenced by cb_build_sub().

3952 {
3953  size_t z;
3954  const char *s;
3955  struct cb_field *f;
3956 
3957  if (CB_REF_OR_FIELD_P (v)) {
3958  f = CB_FIELD_PTR (v);
3959  if (!f->pic->scale && (f->usage == CB_USAGE_BINARY ||
3960  f->usage == CB_USAGE_COMP_5 ||
3961  f->usage == CB_USAGE_COMP_X)) {
3962  z = (f->size - 1) + (8 * (f->pic->have_sign ? 1 : 0)) +
3963  (16 * (f->flag_binary_swap ? 1 : 0));
3964 #if defined(COB_NON_ALIGNED) && !defined(_MSC_VER)
3965  switch (f->size) {
3966  case 2:
3967 #ifdef COB_SHORT_BORK
3969  s = bin_sub_funcs[z].optim_name;
3970  break;
3971 #endif
3972  case 4:
3973  case 8:
3974  if (f->storage != CB_STORAGE_LINKAGE &&
3975  f->indexes == 0 && (f->offset % f->size) == 0) {
3976  optimize_defs[align_bin_sub_funcs[z].optim_val] = 1;
3977  s = align_bin_sub_funcs[z].optim_name;
3978  } else {
3979  optimize_defs[bin_sub_funcs[z].optim_val] = 1;
3980  s = bin_sub_funcs[z].optim_name;
3981  }
3982  break;
3983  default:
3984  optimize_defs[bin_sub_funcs[z].optim_val] = 1;
3985  s = bin_sub_funcs[z].optim_name;
3986  break;
3987  }
3988 #else
3989  if (f->usage == CB_USAGE_COMP_5) {
3990  switch (f->size) {
3991  case 1:
3992  case 2:
3993  case 4:
3994  case 8:
3995  return cb_build_assign (v, cb_build_binary_op (v, '-', n));
3996  default:
3997  break;
3998  }
3999  }
4000  optimize_defs[bin_sub_funcs[z].optim_val] = 1;
4001  s = bin_sub_funcs[z].optim_name;
4002 #endif
4003  if (s) {
4004  return CB_BUILD_FUNCALL_2 (s,
4006  cb_build_cast_int (n));
4007  }
4008  }
4009  }
4010  return CB_BUILD_FUNCALL_3 ("cob_sub_int", v,
4011  cb_build_cast_int (n), cb_int0);
4012 }
int indexes
Definition: tree.h:678
static const struct optim_table bin_sub_funcs[]
Definition: typeck.c:378
int scale
Definition: tree.h:626
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
enum cb_optim optim_val
Definition: typeck.c:53
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int offset
Definition: tree.h:675
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int0
Definition: tree.c:133
unsigned int flag_binary_swap
Definition: tree.h:707
int size
Definition: tree.h:672
cob_u32_t have_sign
Definition: tree.h:627
cb_tree cb_build_assign(const cb_tree var, const cb_tree val)
Definition: tree.c:3014
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_perform_exit ( struct cb_label label)

Definition at line 7574 of file typeck.c.

References cb_build_perform(), CB_PERFORM, CB_PERFORM_EXIT, and CB_TREE.

Referenced by yyparse().

7575 {
7576  cb_tree x;
7577 
7579  CB_PERFORM (x)->data = CB_TREE (label);
7580  return x;
7581 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_PERFORM(x)
Definition: tree.h:1118
cb_tree cb_build_perform(const enum cb_perform_type type)
Definition: tree.c:3149

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_perform_forever ( cb_tree  body)

Definition at line 7561 of file typeck.c.

References cb_build_perform(), cb_error_node, CB_PERFORM, and CB_PERFORM_FOREVER.

Referenced by yyparse().

7562 {
7563  cb_tree x;
7564 
7565  if (body == cb_error_node) {
7566  return cb_error_node;
7567  }
7569  CB_PERFORM (x)->body = body;
7570  return x;
7571 }
#define CB_PERFORM(x)
Definition: tree.h:1118
cb_tree cb_error_node
Definition: tree.c:140
cb_tree cb_build_perform(const enum cb_perform_type type)
Definition: tree.c:3149

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_perform_once ( cb_tree  body)

Definition at line 7523 of file typeck.c.

References cb_build_perform(), cb_error_node, CB_PERFORM, and CB_PERFORM_ONCE.

Referenced by cb_emit_sort_input(), cb_emit_sort_output(), and yyparse().

7524 {
7525  cb_tree x;
7526 
7527  if (body == cb_error_node) {
7528  return cb_error_node;
7529  }
7531  CB_PERFORM (x)->body = body;
7532  return x;
7533 }
#define CB_PERFORM(x)
Definition: tree.h:1118
cb_tree cb_error_node
Definition: tree.c:140
cb_tree cb_build_perform(const enum cb_perform_type type)
Definition: tree.c:3149

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_perform_times ( cb_tree  times)

Definition at line 7536 of file typeck.c.

References cb_build_perform(), cb_check_integer_value(), cb_error_node, CB_PERFORM, and CB_PERFORM_TIMES.

Referenced by yyparse().

7537 {
7538  cb_tree x;
7539 
7540  if (cb_check_integer_value (times) == cb_error_node) {
7541  return cb_error_node;
7542  }
7543 
7545  CB_PERFORM (x)->data = times;
7546  return x;
7547 }
#define CB_PERFORM(x)
Definition: tree.h:1118
cb_tree cb_error_node
Definition: tree.c:140
static cb_tree cb_check_integer_value(cb_tree x)
Definition: typeck.c:666
cb_tree cb_build_perform(const enum cb_perform_type type)
Definition: tree.c:3149

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_perform_until ( cb_tree  condition,
cb_tree  varying 
)

Definition at line 7550 of file typeck.c.

References cb_build_perform(), CB_PERFORM, and CB_PERFORM_UNTIL.

Referenced by yyparse().

7551 {
7552  cb_tree x;
7553 
7555  CB_PERFORM (x)->test = condition;
7556  CB_PERFORM (x)->varying = varying;
7557  return x;
7558 }
#define CB_PERFORM(x)
Definition: tree.h:1118
cb_tree cb_build_perform(const enum cb_perform_type type)
Definition: tree.c:3149

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_ppointer ( cb_tree  x)

Definition at line 1824 of file typeck.c.

References CB_BUILD_CAST_PPOINTER, cb_error_node, CB_FIELD_PTR, cb_ref(), CB_REFERENCE_P, and cb_field::count.

Referenced by yyparse().

1825 {
1826  struct cb_field *f;
1827 
1828  if (x == cb_error_node ||
1829  (CB_REFERENCE_P (x) && cb_ref (x) == cb_error_node)) {
1830  return cb_error_node;
1831  }
1832 
1833  if (CB_REFERENCE_P (x)) {
1834  f = CB_FIELD_PTR (cb_ref(x));
1835  f->count++;
1836  }
1837  return CB_BUILD_CAST_PPOINTER (x);
1838 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_BUILD_CAST_PPOINTER(x)
Definition: tree.h:1844
Definition: tree.h:643
int count
Definition: tree.h:680
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

char* cb_build_program_id ( cb_tree  name,
cb_tree  alt_name,
const cob_u32_t  is_func 
)

Definition at line 1190 of file typeck.c.

References cb_encode_program_id(), CB_LITERAL, CB_LITERAL_P, CB_NAME, cob_u8_t, cobc_check_valid_name(), cobc_strdup(), current_program, cb_program::orig_program_id, and cb_program::program_name.

Referenced by set_up_program(), and yyparse().

1191 {
1192  const char *name_str;
1193  char *s;
1194  unsigned char *p;
1195 
1196  /* Set the program name */
1197  if (CB_LITERAL_P (name)) {
1198  current_program->program_name = (char *)CB_LITERAL (name)->data;
1199  } else {
1201  }
1202 
1203  /* Set and encode the PROGRAM-ID */
1204  if (alt_name) {
1205  name_str = (const char *)CB_LITERAL (alt_name)->data;
1206  } else if (CB_LITERAL_P (name)) {
1207  name_str = (const char *)CB_LITERAL (name)->data;
1208  } else {
1209  name_str = CB_NAME (name);
1210  }
1212  s = cb_encode_program_id (name_str);
1213 
1215 
1216  /* Convert function names to upper case */
1217  if (is_func) {
1218  for (p = (unsigned char *)s; *p; ++p) {
1219  if (islower ((int)*p)) {
1220  *p = (cob_u8_t)toupper ((int)*p);
1221  }
1222  }
1223  }
1224  return s;
1225 }
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define cob_u8_t
Definition: common.h:27
char * cb_encode_program_id(const char *name)
Definition: typeck.c:1132
#define CB_NAME(x)
Definition: tree.h:904
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669
const char * program_name
Definition: tree.h:1243
struct cb_program * current_program
Definition: parser.c:168
size_t cobc_check_valid_name(const char *name, const unsigned int prechk)
Definition: cobc.c:1142
char * orig_program_id
Definition: tree.h:1246

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_build_registers ( void  )

Definition at line 1051 of file typeck.c.

References cb_build_alphanumeric_literal(), cb_build_constant(), cb_build_field(), cb_build_index(), cb_build_picture(), cb_build_reference(), cb_program::cb_call_params, CB_FIELD_ADD, CB_FIELD_PTR, cb_intr_whencomp, CB_LIST_INIT, CB_PICTURE, cb_program::cb_return_code, cb_program::cb_sort_return, CB_USAGE_BINARY, cb_validate_field(), cb_zero, current_program, cb_program::nested_level, NULL, and cb_program::working_storage.

Referenced by set_up_program(), and yyparse().

1052 {
1053 #if !defined(__linux__) && !defined(__CYGWIN__) && defined(HAVE_TIMEZONE)
1054  long contz;
1055 #endif
1056  cb_tree r;
1057  cb_tree x;
1058  struct tm *tlt;
1059  time_t t;
1060  char buff[48];
1061 
1062  /* RETURN-CODE */
1063  if (!current_program->nested_level) {
1064  x = cb_build_index (cb_build_reference ("RETURN-CODE"),
1065  cb_zero, 0, NULL);
1066  CB_FIELD_PTR (x)->special_index = 1;
1068  }
1069 
1070  /* SORT-RETURN */
1071  x = cb_build_index (cb_build_reference ("SORT-RETURN"),
1072  cb_zero, 0, NULL);
1073  CB_FIELD_PTR (x)->flag_no_init = 1;
1075 
1076  /* NUMBER-OF-CALL-PARAMETERS */
1077  x = cb_build_index (cb_build_reference ("NUMBER-OF-CALL-PARAMETERS"),
1078  cb_zero, 0, NULL);
1079  CB_FIELD_PTR (x)->flag_no_init = 1;
1080  CB_FIELD_PTR (x)->flag_local = 1;
1081  CB_FIELD_PTR (x)->special_index = 2;
1083 
1084  /* TALLY */
1085  if (current_program->nested_level == 0) {
1086  r = cb_build_reference ("TALLY");
1087  x = cb_build_field (r);
1088  CB_FIELD_PTR (x)->usage = CB_USAGE_BINARY;
1089  CB_FIELD_PTR (x)->pic = CB_PICTURE (cb_build_picture ("9(5)"));
1091  CB_FIELD_PTR (x)->values = CB_LIST_INIT (cb_zero);
1092  CB_FIELD_PTR (x)->flag_no_init = 1;
1093  CB_FIELD_PTR (x)->flag_is_global = 1;
1095  }
1096 
1097  t = time (NULL);
1098  tlt = localtime (&t);
1099  /* Leap seconds ? */
1100  if (tlt->tm_sec >= 60) {
1101  tlt->tm_sec = 59;
1102  }
1103 
1104  /* WHEN-COMPILED */
1105  memset (buff, 0, sizeof (buff));
1106  strftime (buff, (size_t)17, "%m/%d/%y%H.%M.%S", tlt);
1107  cb_build_constant (cb_build_reference ("WHEN-COMPILED"),
1108  cb_build_alphanumeric_literal (buff, (size_t)16));
1109 
1110  /* FUNCTION WHEN-COMPILED */
1111  memset (buff, 0, sizeof (buff));
1112 #if defined(__linux__) || defined(__CYGWIN__)
1113  strftime (buff, (size_t)22, "%Y%m%d%H%M%S00%z", tlt);
1114 #elif defined(HAVE_TIMEZONE)
1115  strftime (buff, (size_t)17, "%Y%m%d%H%M%S00", tlt);
1116  if (timezone <= 0) {
1117  contz = -timezone;
1118  buff[16] = '+';
1119  } else {
1120  contz = timezone;
1121  buff[16] = '-';
1122  }
1123  sprintf (&buff[17], "%2.2ld%2.2ld", contz / 3600, contz % 60);
1124 #else
1125  strftime (buff, (size_t)22, "%Y%m%d%H%M%S0000000", tlt);
1126 #endif
1127  cb_intr_whencomp = cb_build_alphanumeric_literal (buff, (size_t)21);
1128 
1129 }
cb_tree cb_intr_whencomp
Definition: tree.c:142
cb_tree cb_build_constant(cb_tree name, cb_tree value)
Definition: tree.c:2189
#define CB_FIELD_ADD(x, y)
Definition: tree.h:1856
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int nested_level
Definition: tree.h:1295
cb_tree cb_build_field(cb_tree name)
Definition: tree.c:2159
cb_tree cb_build_index(cb_tree x, cb_tree values, const unsigned int indexed_by, struct cb_field *qual)
Definition: typeck.c:1337
cb_tree cb_zero
Definition: tree.c:125
#define CB_PICTURE(x)
Definition: tree.h:631
cb_tree cb_build_picture(const char *str)
Definition: tree.c:1800
cb_tree cb_build_alphanumeric_literal(const void *data, const size_t size)
Definition: tree.c:1716
cb_tree cb_call_params
Definition: tree.h:1267
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_return_code
Definition: tree.h:1265
cb_tree cb_sort_return
Definition: tree.h:1266
cb_tree cb_build_reference(const char *name)
Definition: tree.c:2572
struct cb_program * current_program
Definition: parser.c:168
#define CB_LIST_INIT(x)
Definition: tree.h:1851
struct cb_field * working_storage
Definition: tree.h:1276
void cb_validate_field(struct cb_field *f)
Definition: field.c:1338

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_replacing_all ( cb_tree  x,
cb_tree  y,
cb_tree  l 
)

Definition at line 5926 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_list_add(), and validate_inspect().

Referenced by yyparse().

5927 {
5928  validate_inspect (x, y, 1);
5929  return cb_list_add (l, CB_BUILD_FUNCALL_2 ("cob_inspect_all", y, x));
5930 }
static void validate_inspect(cb_tree x, cb_tree y, const unsigned int replconv)
Definition: typeck.c:5714
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_replacing_characters ( cb_tree  x,
cb_tree  l 
)

Definition at line 5916 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, cb_error_x(), cb_list_add(), CB_LITERAL, CB_LITERAL_P, CB_TREE, and current_statement.

Referenced by yyparse().

5917 {
5918  if (CB_LITERAL_P (x) && CB_LITERAL(x)->size != 1) {
5920  _("Operand has wrong size"));
5921  }
5922  return cb_list_add (l, CB_BUILD_FUNCALL_1 ("cob_inspect_characters", x));
5923 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define _(s)
Definition: cobcrun.c:59
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_replacing_first ( cb_tree  x,
cb_tree  y,
cb_tree  l 
)

Definition at line 5940 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_list_add(), and validate_inspect().

Referenced by yyparse().

5941 {
5942  validate_inspect (x, y, 1);
5943  return cb_list_add (l, CB_BUILD_FUNCALL_2 ("cob_inspect_first", y, x));
5944 }
static void validate_inspect(cb_tree x, cb_tree y, const unsigned int replconv)
Definition: typeck.c:5714
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_replacing_leading ( cb_tree  x,
cb_tree  y,
cb_tree  l 
)

Definition at line 5933 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_list_add(), and validate_inspect().

Referenced by yyparse().

5934 {
5935  validate_inspect (x, y, 1);
5936  return cb_list_add (l, CB_BUILD_FUNCALL_2 ("cob_inspect_leading", y, x));
5937 }
static void validate_inspect(cb_tree x, cb_tree y, const unsigned int replconv)
Definition: typeck.c:5714
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_replacing_trailing ( cb_tree  x,
cb_tree  y,
cb_tree  l 
)

Definition at line 5947 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_list_add(), and validate_inspect().

Referenced by yyparse().

5948 {
5949  validate_inspect (x, y, 1);
5950  return cb_list_add (l, CB_BUILD_FUNCALL_2 ("cob_inspect_trailing", y, x));
5951 }
static void validate_inspect(cb_tree x, cb_tree y, const unsigned int replconv)
Definition: typeck.c:5714
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_build_search_all ( cb_tree  table,
cb_tree  cond 
)
static

Definition at line 7923 of file typeck.c.

References cb_build_binary_op(), cb_build_cond(), CB_FIELD_PTR, COB_ASCENDING, cb_key::dir, cb_field::keys, cb_field::nkeys, NULL, cb_key::ref, search_set_keys(), and cb_key::val.

Referenced by cb_emit_search_all().

7924 {
7925  cb_tree c1;
7926  cb_tree c2;
7927  struct cb_field *f;
7928  int i;
7929 
7930  f = CB_FIELD_PTR (table);
7931  /* Set keys */
7932  for (i = 0; i < f->nkeys; i++) {
7933  f->keys[i].ref = NULL;
7934  }
7935  if (search_set_keys (f, cond)) {
7936  return NULL;
7937  }
7938  c1 = NULL;
7939 
7940  /* Build condition */
7941  for (i = 0; i < f->nkeys; i++) {
7942  if (f->keys[i].ref) {
7943  if (f->keys[i].dir == COB_ASCENDING) {
7944  c2 = cb_build_binary_op (f->keys[i].ref, '=',
7945  f->keys[i].val);
7946  } else {
7947  c2 = cb_build_binary_op (f->keys[i].val, '=',
7948  f->keys[i].ref);
7949  }
7950  if (c1 == NULL) {
7951  c1 = c2;
7952  } else {
7953  c1 = cb_build_binary_op (c1, '&', c2);
7954  }
7955  }
7956  }
7957 
7958  if (!c1) {
7959  return NULL;
7960  }
7961  return cb_build_cond (c1);
7962 }
cb_tree val
Definition: tree.h:639
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree ref
Definition: tree.h:638
Definition: tree.h:643
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
int dir
Definition: tree.h:640
cb_tree cb_build_cond(cb_tree x)
Definition: typeck.c:3737
static unsigned int search_set_keys(struct cb_field *f, cb_tree x)
Definition: typeck.c:7852
#define COB_ASCENDING
Definition: common.h:735
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
struct cb_key * keys
Definition: tree.h:658
int nkeys
Definition: tree.h:682

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_section_name ( cb_tree  name,
const int  sect_or_para 
)

Definition at line 1251 of file typeck.c.

References cb_error_node, CB_LABEL, CB_LABEL_P, CB_VALUE, CB_WORD_COUNT, CB_WORD_ITEMS, and redefinition_error().

Referenced by yyparse().

1252 {
1253  cb_tree x;
1254 
1255  if (name == cb_error_node) {
1256  return cb_error_node;
1257  }
1258 
1259  if (CB_WORD_COUNT (name) > 0) {
1260  x = CB_VALUE (CB_WORD_ITEMS (name));
1261  /* Used as a non-label name or used as a section name.
1262  Duplicate paragraphs are allowed if not referenced;
1263  Checked in typeck.c */
1264  if (!CB_LABEL_P (x) || sect_or_para == 0 ||
1265  (sect_or_para && CB_LABEL_P (x) &&
1266  CB_LABEL (x)->flag_section)) {
1267  redefinition_error (name);
1268  return cb_error_node;
1269  }
1270  }
1271 
1272  return name;
1273 }
const char * name
Definition: tree.h:645
#define CB_LABEL(x)
Definition: tree.h:801
#define CB_LABEL_P(x)
Definition: tree.h:802
#define CB_WORD_ITEMS(x)
Definition: tree.h:906
#define CB_VALUE(x)
Definition: tree.h:1193
void redefinition_error(cb_tree x)
Definition: error.c:284
cb_tree cb_error_node
Definition: tree.c:140
#define CB_WORD_COUNT(x)
Definition: tree.h:905

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_sub ( cb_tree  v,
cb_tree  n,
cb_tree  round_opt 
)

Definition at line 4058 of file typeck.c.

References build_store_option(), cb_build_binary_op(), CB_BUILD_FUNCALL_3, cb_build_move(), cb_build_optim_sub(), CB_CLASS_POINTER, CB_FIELD_PTR, cb_fits_int(), CB_INDEX_P, cb_int0, cb_int1, CB_REF_OR_FIELD_P, CB_TREE_CLASS, COB_POINTER_MANIP, cb_field::count, and optimize_defs.

Referenced by cb_emit_arithmetic(), cb_emit_set_up_down(), and yyparse().

4059 {
4060  cb_tree opt;
4061  struct cb_field *f;
4062 
4063 #ifdef COB_NON_ALIGNED
4064  if (CB_INDEX_P (v)) {
4065  return cb_build_move (cb_build_binary_op (v, '-', n), v);
4066  }
4067  if (CB_TREE_CLASS (v) == CB_CLASS_POINTER) {
4069  return CB_BUILD_FUNCALL_3 ("cob_pointer_manip", v, n, cb_int1);
4070  }
4071 #else
4072  if (CB_INDEX_P (v) || CB_TREE_CLASS (v) == CB_CLASS_POINTER) {
4073  return cb_build_move (cb_build_binary_op (v, '-', n), v);
4074  }
4075 #endif
4076 
4077  if (CB_REF_OR_FIELD_P (v)) {
4078  f = CB_FIELD_PTR (v);
4079  f->count++;
4080  }
4081  if (CB_REF_OR_FIELD_P (n)) {
4082  f = CB_FIELD_PTR (n);
4083  f->count++;
4084  }
4085  opt = build_store_option (v, round_opt);
4086  if (opt == cb_int0 && cb_fits_int (n)) {
4087  return cb_build_optim_sub (v, n);
4088  }
4089  return CB_BUILD_FUNCALL_3 ("cob_sub", v, n, opt);
4090 }
static cb_tree cb_build_optim_sub(cb_tree v, cb_tree n)
Definition: typeck.c:3951
cb_tree cb_int1
Definition: tree.c:134
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define CB_INDEX_P(x)
Definition: tree.h:750
Definition: tree.h:643
cb_tree cb_int0
Definition: tree.c:133
int count
Definition: tree.h:680
int cb_fits_int(const cb_tree x)
Definition: tree.c:914
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_tallying_all ( void  )

Definition at line 5874 of file typeck.c.

References _, cb_error_x(), CB_TREE, current_statement, inspect_func, and NULL.

Referenced by yyparse().

5875 {
5876  if (inspect_data == NULL) {
5878  _("Data name expected before ALL"));
5879  }
5880  inspect_func = "cob_inspect_all";
5881  return NULL;
5882 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_tallying_characters ( cb_tree  l)

Definition at line 5863 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, cb_error_x(), cb_list_add(), CB_TREE, current_statement, inspect_func, and NULL.

Referenced by yyparse().

5864 {
5865  if (inspect_data == NULL) {
5867  _("Data name expected before CHARACTERS"));
5868  }
5869  inspect_func = NULL;
5870  return cb_list_add (l, CB_BUILD_FUNCALL_1 ("cob_inspect_characters", inspect_data));
5871 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_tallying_data ( cb_tree  x)

Definition at line 5856 of file typeck.c.

References NULL.

Referenced by yyparse().

5857 {
5858  inspect_data = x;
5859  return NULL;
5860 }
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97

Here is the caller graph for this function:

cb_tree cb_build_tallying_leading ( void  )

Definition at line 5885 of file typeck.c.

References _, cb_error_x(), CB_TREE, current_statement, inspect_func, and NULL.

Referenced by yyparse().

5886 {
5887  if (inspect_data == NULL) {
5889  _("Data name expected before LEADING"));
5890  }
5891  inspect_func = "cob_inspect_leading";
5892  return NULL;
5893 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_tallying_trailing ( void  )

Definition at line 5896 of file typeck.c.

References _, cb_error_x(), CB_TREE, current_statement, inspect_func, and NULL.

Referenced by yyparse().

5897 {
5898  if (inspect_data == NULL) {
5900  _("Data name expected before TRAILING"));
5901  }
5902  inspect_func = "cob_inspect_trailing";
5903  return NULL;
5904 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_tallying_value ( cb_tree  x,
cb_tree  l 
)

Definition at line 5907 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, cb_error_x(), cb_list_add(), cb_name(), inspect_func, and NULL.

Referenced by yyparse().

5908 {
5909  if (inspect_func == NULL) {
5910  cb_error_x (x, _("ALL, LEADING or TRAILING expected before '%s'"), cb_name (x));
5911  }
5913 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
char * cb_name(cb_tree x)
Definition: tree.c:735
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_unstring_delimited ( cb_tree  all,
cb_tree  value 
)

Definition at line 8578 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_error_node, and cb_validate_one().

Referenced by yyparse().

8579 {
8580  if (cb_validate_one (value)) {
8581  return cb_error_node;
8582  }
8583  return CB_BUILD_FUNCALL_2 ("cob_unstring_delimited", value, all);
8584 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_unstring_into ( cb_tree  name,
cb_tree  delimiter,
cb_tree  count 
)

Definition at line 8587 of file typeck.c.

References CB_BUILD_FUNCALL_3, cb_error_node, cb_int0, cb_validate_one(), and NULL.

Referenced by yyparse().

8588 {
8589  if (cb_validate_one (name)) {
8590  return cb_error_node;
8591  }
8592  if (delimiter == NULL) {
8593  delimiter = cb_int0;
8594  }
8595  if (count == NULL) {
8596  count = cb_int0;
8597  }
8598  return CB_BUILD_FUNCALL_3 ("cob_unstring_into", name, delimiter, count);
8599 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int0
Definition: tree.c:133
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_write_advancing_lines ( cb_tree  pos,
cb_tree  lines 
)

Definition at line 8685 of file typeck.c.

References CB_BEFORE, cb_build_binary_op(), cb_build_cast_int(), cb_get_int(), cb_int(), cb_int_hex(), CB_LITERAL_P, COB_WRITE_AFTER, COB_WRITE_BEFORE, and COB_WRITE_LINES.

Referenced by yyparse().

8686 {
8687  cb_tree e;
8688  int opt;
8689 
8690  opt = (pos == CB_BEFORE) ? COB_WRITE_BEFORE : COB_WRITE_AFTER;
8691  opt |= COB_WRITE_LINES;
8692  if (CB_LITERAL_P (lines)) {
8693  opt |= cb_get_int (lines);
8694  return cb_int_hex (opt);
8695  }
8696  e = cb_build_binary_op (cb_int (opt), '+', lines);
8697  return cb_build_cast_int (e);
8698 }
#define COB_WRITE_LINES
Definition: common.h:802
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
#define COB_WRITE_AFTER
Definition: common.h:805
#define CB_LITERAL_P(x)
Definition: tree.h:602
cb_tree cb_int_hex(const int n)
Definition: tree.c:1514
#define CB_BEFORE
Definition: tree.h:25
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define COB_WRITE_BEFORE
Definition: common.h:806
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_write_advancing_mnemonic ( cb_tree  pos,
cb_tree  mnemonic 
)

Definition at line 8701 of file typeck.c.

References _, CB_BEFORE, cb_error_node, cb_error_x(), CB_FEATURE_C01, CB_FEATURE_C02, CB_FEATURE_C03, CB_FEATURE_C04, CB_FEATURE_C05, CB_FEATURE_C06, CB_FEATURE_C07, CB_FEATURE_C08, CB_FEATURE_C09, CB_FEATURE_C10, CB_FEATURE_C11, CB_FEATURE_C12, CB_FEATURE_FORMFEED, cb_int0, cb_int_hex(), cb_ref(), CB_SYSTEM_NAME, COB_WRITE_AFTER, COB_WRITE_BEFORE, COB_WRITE_CHANNEL, and COB_WRITE_PAGE.

Referenced by yyparse().

8702 {
8703  int opt;
8704  int token;
8705 
8706  if (mnemonic == cb_error_node) {
8707  return cb_int0;
8708  }
8709  if (cb_ref (mnemonic) == cb_error_node) {
8710  return cb_int0;
8711  }
8712  token = CB_SYSTEM_NAME (cb_ref (mnemonic))->token;
8713  switch (token) {
8714  case CB_FEATURE_FORMFEED:
8715  opt = (pos == CB_BEFORE) ? COB_WRITE_BEFORE : COB_WRITE_AFTER;
8716  return cb_int_hex (opt | COB_WRITE_PAGE);
8717  case CB_FEATURE_C01:
8718  case CB_FEATURE_C02:
8719  case CB_FEATURE_C03:
8720  case CB_FEATURE_C04:
8721  case CB_FEATURE_C05:
8722  case CB_FEATURE_C06:
8723  case CB_FEATURE_C07:
8724  case CB_FEATURE_C08:
8725  case CB_FEATURE_C09:
8726  case CB_FEATURE_C10:
8727  case CB_FEATURE_C11:
8728  case CB_FEATURE_C12:
8729  opt = (pos == CB_BEFORE) ? COB_WRITE_BEFORE : COB_WRITE_AFTER;
8730  return cb_int_hex (opt | COB_WRITE_CHANNEL | COB_WRITE_PAGE | token);
8731  default:
8732  cb_error_x (mnemonic, _("Invalid mnemonic name"));
8733  return cb_int0;
8734  }
8735 }
#define CB_FEATURE_C01
Definition: tree.h:198
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
#define CB_FEATURE_C07
Definition: tree.h:204
#define CB_FEATURE_C10
Definition: tree.h:207
#define CB_FEATURE_C09
Definition: tree.h:206
#define CB_FEATURE_FORMFEED
Definition: tree.h:196
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_WRITE_AFTER
Definition: common.h:805
#define CB_FEATURE_C02
Definition: tree.h:199
#define COB_WRITE_PAGE
Definition: common.h:803
#define _(s)
Definition: cobcrun.c:59
#define CB_FEATURE_C11
Definition: tree.h:208
#define CB_FEATURE_C03
Definition: tree.h:200
cb_tree cb_int_hex(const int n)
Definition: tree.c:1514
#define COB_WRITE_CHANNEL
Definition: common.h:804
cb_tree cb_int0
Definition: tree.c:133
#define CB_BEFORE
Definition: tree.h:25
cb_tree cb_error_node
Definition: tree.c:140
#define COB_WRITE_BEFORE
Definition: common.h:806
#define CB_FEATURE_C04
Definition: tree.h:201
#define CB_FEATURE_C12
Definition: tree.h:209
#define CB_FEATURE_C05
Definition: tree.h:202
#define CB_FEATURE_C06
Definition: tree.h:203
#define CB_FEATURE_C08
Definition: tree.h:205

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_build_write_advancing_page ( cb_tree  pos)

Definition at line 8738 of file typeck.c.

References CB_BEFORE, cb_int_hex(), COB_WRITE_AFTER, COB_WRITE_BEFORE, and COB_WRITE_PAGE.

Referenced by yyparse().

8739 {
8740  int opt = (pos == CB_BEFORE) ? COB_WRITE_BEFORE : COB_WRITE_AFTER;
8741 
8742  return cb_int_hex (opt | COB_WRITE_PAGE);
8743 }
#define COB_WRITE_AFTER
Definition: common.h:805
#define COB_WRITE_PAGE
Definition: common.h:803
cb_tree cb_int_hex(const int n)
Definition: tree.c:1514
#define CB_BEFORE
Definition: tree.h:25
#define COB_WRITE_BEFORE
Definition: common.h:806

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_check_data_incompat ( cb_tree  x)
static

Definition at line 719 of file typeck.c.

References CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_2, CB_BUILD_STRING0, CB_CATEGORY_NUMERIC, cb_emit, cb_error_node, CB_EXCEPTION_ENABLE, CB_FIELD_PTR, CB_REF_OR_FIELD_P, CB_TREE_CATEGORY, CB_USAGE_COMP_6, CB_USAGE_DISPLAY, CB_USAGE_PACKED, COB_EC_DATA_INCOMPATIBLE, cb_field::name, and cb_field::usage.

Referenced by cb_emit_arithmetic(), cb_emit_goto(), cb_emit_move(), and cb_emit_set_to().

720 {
721  struct cb_field *f;
722 
723  if (!x || x == cb_error_node) {
724  return;
725  }
726  if (!CB_REF_OR_FIELD_P (x) ||
728  return;
729  }
730  f = CB_FIELD_PTR (x);
731  if (cb_flag_correct_numeric && f->usage == CB_USAGE_DISPLAY) {
732  cb_emit (CB_BUILD_FUNCALL_1 ("cob_correct_numeric", x));
733  }
735  if (f->usage == CB_USAGE_DISPLAY ||
736  f->usage == CB_USAGE_PACKED ||
737  f->usage == CB_USAGE_COMP_6) {
738  cb_emit (CB_BUILD_FUNCALL_2 ("cob_check_numeric",
739  x,
740  CB_BUILD_STRING0 (f->name)));
741  }
742  }
743 }
const char * name
Definition: tree.h:645
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_error_node
Definition: tree.c:140
#define CB_BUILD_STRING0(str)
Definition: tree.h:1849
#define CB_EXCEPTION_ENABLE(id)
Definition: cobc.h:243
#define cb_emit(x)
Definition: typeck.c:75
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693

Here is the caller graph for this function:

void cb_check_field_debug ( cb_tree  fld)

Definition at line 904 of file typeck.c.

References CB_BUILD_CAST_ADDRESS, CB_BUILD_CAST_LENGTH, cb_build_debug(), cb_build_debug_call(), CB_BUILD_FUNCALL_3, cb_build_move(), CB_CHAIN, cb_error_node, CB_FIELD, CB_FIELD_P, cb_int(), cb_list_add(), cb_list_reverse(), CB_PURPOSE, cb_ref(), CB_REFERENCE, CB_VALUE, CB_WORD_COUNT, CB_WORD_ITEMS, COB_MINI_BUFF, current_program, current_statement, cb_statement::debug_check, cb_program::debug_list, cb_statement::debug_nodups, cb_field::debug_section, cb_field::flag_all_debug, cb_field::name, NULL, and cb_field::size.

Referenced by yyparse().

905 {
906  cb_tree l;
907  cb_tree x;
908  cb_tree z;
909  size_t size;
910  size_t found;
911  char buff[COB_MINI_BUFF];
912 
913  /* Basic reference check */
914  if (CB_WORD_COUNT (fld) > 0) {
915  if (!CB_WORD_ITEMS (fld)) {
916  return;
917  }
918  z = CB_VALUE(CB_WORD_ITEMS (fld));
919  if (!CB_FIELD_P (z)) {
920  return;
921  }
922  x = cb_ref (fld);
923  if (x == cb_error_node) {
924  return;
925  }
926  } else {
927  return;
928  }
929 
930  found = 0;
931  /* Check if reference is being debugged */
932  for (l = current_program->debug_list; l; l = CB_CHAIN (l)) {
933  if (!CB_PURPOSE (l)) {
934  continue;
935  }
936  if (x == CB_PURPOSE (l)) {
937  if (CB_REFERENCE (fld)->flag_target ||
939  found = 1;
940  }
941  break;
942  }
943  }
944  if (!found) {
945  return;
946  }
947 
948  found = 0;
949  /* Found it - check if it is already in the statement list */
950  for (l = current_statement->debug_nodups; l; l = CB_CHAIN (l)) {
951  if (CB_VALUE (l) == x) {
952  found = 1;
953  break;
954  }
955  }
956  if (found) {
957  return;
958  }
959 
960  /* Set up debug info */
961  strcpy (buff, CB_FIELD(x)->name);
962  size = strlen (buff);
963  for (l = CB_REFERENCE (fld)->chain; l; l = CB_REFERENCE (l)->chain) {
964  z = cb_ref (l);
965  if (z != cb_error_node) {
966  size += strlen (CB_FIELD (z)->name);
967  size += 4;
968  if (size >= sizeof(buff)) {
969  break;
970  }
971  strcat (buff, " OF ");
972  strcat (buff, CB_FIELD (z)->name);
973  }
974  }
983  found = 0;
984  CB_REFERENCE (fld)->subs = cb_list_reverse (CB_REFERENCE (fld)->subs);
985  l = CB_REFERENCE (fld)->subs;
986  for (; l && found < 3; l = CB_CHAIN (l), ++found) {
987  switch (found) {
988  case 0:
991  cb_build_move (CB_VALUE (l),
992  cb_debug_sub_1));
993  break;
994  case 1:
997  cb_build_move (CB_VALUE (l),
998  cb_debug_sub_2));
999  break;
1000  case 2:
1003  cb_build_move (CB_VALUE (l),
1004  cb_debug_sub_3));
1005  break;
1006  default:
1007  break;
1008  }
1009  }
1010  CB_REFERENCE (fld)->subs = cb_list_reverse (CB_REFERENCE (fld)->subs);
1011 
1012  for (; found < 3; ++found) {
1013  switch (found) {
1014  case 0:
1017  CB_BUILD_FUNCALL_3 ("memset",
1019  cb_int (' '),
1021  break;
1022  case 1:
1025  CB_BUILD_FUNCALL_3 ("memset",
1027  cb_int (' '),
1029  break;
1030  case 2:
1033  CB_BUILD_FUNCALL_3 ("memset",
1035  cb_int (' '),
1037  break;
1038  default:
1039  break;
1040  }
1041  }
1042 
1046 }
const char * name
Definition: tree.h:645
cb_tree cb_debug_sub_2
Definition: typeck.c:86
cb_tree debug_check
Definition: tree.h:1145
cb_tree cb_debug_name
Definition: typeck.c:84
struct cb_label * debug_section
Definition: tree.h:661
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_MINI_BUFF
Definition: common.h:539
#define CB_PURPOSE(x)
Definition: tree.h:1192
#define CB_WORD_ITEMS(x)
Definition: tree.h:906
cb_tree debug_list
Definition: tree.h:1264
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
unsigned int flag_all_debug
Definition: tree.h:734
#define CB_FIELD_P(x)
Definition: tree.h:741
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
cb_tree cb_debug_sub_1
Definition: typeck.c:85
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
cb_tree cb_error_node
Definition: tree.c:140
cb_tree cb_debug_sub_3
Definition: typeck.c:87
struct cb_program * current_program
Definition: parser.c:168
#define CB_WORD_COUNT(x)
Definition: tree.h:905
cb_tree cb_debug_contents
Definition: typeck.c:88
#define CB_BUILD_CAST_LENGTH(x)
Definition: tree.h:1843
cb_tree debug_nodups
Definition: tree.h:1146
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
struct cb_statement * current_statement
Definition: parser.c:169
#define CB_FIELD(x)
Definition: tree.h:740
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_check_group_name ( cb_tree  x)
static

Definition at line 592 of file typeck.c.

References _, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_P, cb_name(), cb_ref(), CB_REFERENCE, CB_REFERENCE_P, cb_field::children, NULL, and cb_field::offset.

Referenced by cb_emit_corresponding(), and cb_emit_move_corresponding().

593 {
594  cb_tree y;
595 
596  if (x == cb_error_node) {
597  return cb_error_node;
598  }
599 
600  if (CB_REFERENCE_P (x)) {
601  y = cb_ref (x);
602  if (y == cb_error_node) {
603  return cb_error_node;
604  }
605  if (CB_FIELD_P (y) && CB_FIELD (y)->children != NULL &&
606  CB_REFERENCE (x)->offset == NULL) {
607  return x;
608  }
609  }
610 
611  cb_error_x (x, _("'%s' is not group name"), cb_name (x));
612  return cb_error_node;
613 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
struct cb_field * children
Definition: tree.h:652
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
int offset
Definition: tree.h:675
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

size_t cb_check_index_p ( cb_tree  x)

Definition at line 887 of file typeck.c.

References CB_FIELD_PTR, CB_REF_OR_FIELD_P, CB_USAGE_INDEX, cb_field::children, and cb_field::usage.

888 {
889  struct cb_field *f;
890 
891  if (!CB_REF_OR_FIELD_P (x)) {
892  return 0;
893  }
894  f = CB_FIELD_PTR (x);
895  if (f->usage == CB_USAGE_INDEX && !f->children) {
896  return 1;
897  }
898  return 0;
899 }
struct cb_field * children
Definition: tree.h:652
#define CB_FIELD_PTR(x)
Definition: tree.h:745
Definition: tree.h:643
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693
static cb_tree cb_check_integer_value ( cb_tree  x)
static

Definition at line 666 of file typeck.c.

References _, CB_CATEGORY_NUMERIC, cb_error_node, cb_error_x(), CB_FIELD, CB_LITERAL, cb_name(), cb_ref(), CB_TAG_BINARY_OP, CB_TAG_CONST, CB_TAG_INTRINSIC, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE_CATEGORY, CB_TREE_TAG, cb_zero, cb_field::pic, cb_literal::scale, cb_picture::scale, and cb_literal::sign.

Referenced by cb_build_identifier(), and cb_build_perform_times().

667 {
668  struct cb_literal *l;
669  struct cb_field *f;
670  cb_tree y;
671 
672  if (x == cb_error_node) {
673  return cb_error_node;
674  }
675 
677  goto invalid;
678  }
679 
680  switch (CB_TREE_TAG (x)) {
681  case CB_TAG_CONST:
682  if (x != cb_zero) {
683  goto invalid;
684  }
685  return x;
686  case CB_TAG_LITERAL:
687  l = CB_LITERAL (x);
688  if (l->sign < 0 || l->scale > 0) {
689  goto invliteral;
690  }
691  return x;
692  case CB_TAG_REFERENCE:
693  y = cb_ref (x);
694  if (y == cb_error_node) {
695  return cb_error_node;
696  }
697  f = CB_FIELD (y);
698  if (f->pic->scale > 0) {
699  goto invalid;
700  }
701  return x;
702  case CB_TAG_BINARY_OP:
703  /* TODO: need to check */
704  return x;
705  case CB_TAG_INTRINSIC:
706  /* TODO: need to check */
707  return x;
708  default:
709 invalid:
710  cb_error_x (x, _("'%s' is not an integer value"), cb_name (x));
711  return cb_error_node;
712  }
713 invliteral:
714  cb_error_x (x, _("A positive numeric integer is required here"));
715  return cb_error_node;
716 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
short sign
Definition: tree.h:597
int scale
Definition: tree.h:626
#define CB_LITERAL(x)
Definition: tree.h:601
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
struct cb_picture * pic
Definition: tree.h:659
cb_tree cb_zero
Definition: tree.c:125
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
int scale
Definition: tree.h:595
#define CB_TREE_TAG(x)
Definition: tree.h:441
cb_tree cb_error_node
Definition: tree.c:140
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_check_lit_subs ( struct cb_reference r,
const int  numsubs,
const int  numindex 
)
static

Definition at line 746 of file typeck.c.

References CB_BUILD_CHAIN, cb_build_numsize_literal(), CB_CHAIN, cb_error_node, CB_LITERAL, CB_LITERAL_P, CB_VALUE, current_program, cb_literal::data, cb_program::decimal_point, cb_literal::scale, cb_literal::sign, cb_literal::size, and cb_reference::subs.

Referenced by cb_build_identifier().

748 {
749  cb_tree l;
750  cb_tree v;
751  struct cb_literal *lt;
752  int size;
753 
754  /* Check for DPC and non-standard separator usage */
755  if (!cb_relaxed_syntax_check ||
756  current_program->decimal_point != ',') {
757  return;
758  }
759  if (numsubs > numindex) {
760  return;
761  }
762 
763  for (l = r->subs; l; l = CB_CHAIN (l)) {
764  v = CB_VALUE (l);
765  if (v == cb_error_node) {
766  continue;
767  }
768  if (!CB_LITERAL_P (v)) {
769  continue;
770  }
771  lt = CB_LITERAL (v);
772  if (!lt->scale) {
773  continue;
774  }
775  if (lt->scale == (int)lt->size) {
776  lt->scale = 0;
777  continue;
778  }
779  size = lt->size - lt->scale;
780  v = cb_build_numsize_literal (&lt->data[size],
781  (size_t)lt->scale, lt->sign);
782  CB_VALUE (l) = v;
783  v = cb_build_numsize_literal (lt->data, (size_t)size, 0);
784  CB_CHAIN (l) = CB_BUILD_CHAIN (v, CB_CHAIN (l));
785  }
786  return;
787 }
short sign
Definition: tree.h:597
#define CB_LITERAL(x)
Definition: tree.h:601
cb_tree cb_build_numsize_literal(const void *data, const size_t size, const int sign)
Definition: tree.c:1699
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_CHAIN(x)
Definition: tree.h:1194
int scale
Definition: tree.h:595
unsigned char * data
Definition: tree.h:593
cb_tree cb_error_node
Definition: tree.c:140
#define CB_BUILD_CHAIN(x, y)
Definition: tree.h:1852
struct cb_program * current_program
Definition: parser.c:168
cb_tree subs
Definition: tree.h:877
cob_u32_t size
Definition: tree.h:594
unsigned char decimal_point
Definition: tree.h:1300

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_check_needs_break ( cb_tree  stmt)
static

Definition at line 523 of file typeck.c.

References cb_build_direct(), CB_CHAIN, CB_GOTO_P, cb_list_add(), CB_STATEMENT, CB_STATEMENT_P, and CB_VALUE.

Referenced by cb_build_if_check_break(), cb_emit_search(), and cb_emit_search_all().

524 {
525  cb_tree l;
526 
527  /* Check if last statement is GO TO */
528  for (l = stmt; l; l = CB_CHAIN (l)) {
529  if (!CB_CHAIN(l)) {
530  break;
531  }
532  }
533  if (l && CB_VALUE (l) && CB_STATEMENT_P (CB_VALUE (l))) {
534  l = CB_STATEMENT(CB_VALUE(l))->body;
535  if (l && CB_VALUE (l) && !CB_GOTO_P (CB_VALUE(l))) {
536  /* Append a break */
537  l = cb_build_direct ("break;", 0);
538  return cb_list_add (stmt, l);
539  }
540  }
541  return stmt;
542 }
#define CB_STATEMENT_P(x)
Definition: tree.h:1156
#define CB_VALUE(x)
Definition: tree.h:1193
cb_tree cb_build_direct(const char *str, const unsigned int flagnl)
Definition: tree.c:1553
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_STATEMENT(x)
Definition: tree.h:1155
#define CB_GOTO_P(x)
Definition: tree.h:1080
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_check_numeric_edited_name ( cb_tree  x)
static

Definition at line 633 of file typeck.c.

References _, CB_CATEGORY_NUMERIC, CB_CATEGORY_NUMERIC_EDITED, cb_error_node, cb_error_x(), CB_FIELD_P, cb_name(), cb_ref(), CB_REFERENCE_P, and CB_TREE_CATEGORY.

Referenced by cb_emit_arithmetic(), and cb_emit_divide().

634 {
635  if (x == cb_error_node) {
636  return cb_error_node;
637  }
638 
639  if (CB_REFERENCE_P (x) &&
640  CB_FIELD_P (cb_ref (x)) &&
643  return x;
644  }
645 
646  cb_error_x (x, _("'%s' is not numeric or numeric-edited name"), cb_name (x));
647  return cb_error_node;
648 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_check_numeric_name ( cb_tree  x)
static

Definition at line 616 of file typeck.c.

References _, CB_CATEGORY_NUMERIC, cb_error_node, cb_error_x(), CB_FIELD_P, cb_name(), cb_ref(), CB_REFERENCE_P, and CB_TREE_CATEGORY.

Referenced by cb_emit_arithmetic().

617 {
618  if (x == cb_error_node) {
619  return cb_error_node;
620  }
621 
622  if (CB_REFERENCE_P (x) &&
623  CB_FIELD_P (cb_ref (x)) &&
625  return x;
626  }
627 
628  cb_error_x (x, _("'%s' is not a numeric name"), cb_name (x));
629  return cb_error_node;
630 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

cb_tree cb_check_numeric_value ( cb_tree  x)

Definition at line 651 of file typeck.c.

References _, CB_CATEGORY_NUMERIC, cb_error_node, cb_error_x(), cb_name(), and CB_TREE_CATEGORY.

Referenced by cb_build_binary_op(), cb_emit_arithmetic(), and cb_emit_goto().

652 {
653  if (x == cb_error_node) {
654  return cb_error_node;
655  }
656 
658  return x;
659  }
660 
661  cb_error_x (x, _("'%s' is not a numeric value"), cb_name (x));
662  return cb_error_node;
663 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
char * cb_name(cb_tree x)
Definition: tree.c:735
#define _(s)
Definition: cobcrun.c:59
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t cb_check_overlapping ( cb_tree  src,
cb_tree  dst,
struct cb_field src_f,
struct cb_field dst_f 
)
static

Definition at line 6078 of file typeck.c.

References _, cb_field_founder(), cb_field_size(), cb_field_variable_size(), cb_get_int(), CB_LITERAL_P, CB_REFERENCE, cb_warning_x(), cb_field::children, f1, cb_field::flag_occurs, cb_field::mem_offset, cb_field::offset, cb_reference::offset, cb_field::redefines, cb_field::sister, cb_tree_common::source_line, and suppress_warn.

Referenced by validate_move().

6080 {
6081  struct cb_field *f1;
6082  struct cb_field *ff1;
6083  struct cb_field *ff2;
6084  struct cb_reference *r;
6085  cb_tree loc;
6086  int src_size;
6087  int dst_size;
6088  int src_off;
6089  int dst_off;
6090 
6091  /* Check basic overlapping */
6092  for (f1 = src_f->children; f1; f1 = f1->sister) {
6093  if (f1 == dst_f) {
6094  goto overlapret;
6095  }
6096  }
6097  for (f1 = dst_f->children; f1; f1 = f1->sister) {
6098  if (f1 == src_f) {
6099  goto overlapret;
6100  }
6101  }
6102  ff1 = cb_field_founder (src_f);
6103  ff2 = cb_field_founder (dst_f);
6104  if (ff1->redefines) {
6105  ff1 = ff1->redefines;
6106  }
6107  if (ff2->redefines) {
6108  ff2 = ff2->redefines;
6109  }
6110  if (ff1 != ff2) {
6111  return 0;
6112  }
6113 
6114  src_size = cb_field_size (src);
6115  dst_size = cb_field_size (dst);
6116 
6117  if (src_size <= 0 || dst_size <= 0 ||
6118  cb_field_variable_size (src_f) ||
6119  cb_field_variable_size (dst_f)) {
6120  return 1; /* overlapping possible, would need more checks */
6121  }
6122  /* Check literal occurs? */
6123  if ((src_f->flag_occurs && !src_f->mem_offset) ||
6124  (dst_f->flag_occurs && !dst_f->mem_offset)) {
6125  return 1; /* overlapping possible, would need more checks */
6126  }
6127 
6128  /* Same field - Check offsets */
6129  src_off = src_f->offset;
6130  dst_off = dst_f->offset;
6131 
6132  /* Adjusting offsets by occurs and reference modification */
6133  src_off += src_f->mem_offset ;
6134  r = CB_REFERENCE (src);
6135  if (r->offset) {
6136  if (CB_LITERAL_P (r->offset)) {
6137  src_off += cb_get_int (r->offset) - 1;
6138  } else {
6139  goto overlapret;
6140  }
6141  }
6142  dst_off += dst_f->mem_offset;
6143  r = CB_REFERENCE (dst);
6144  if (r->offset) {
6145  if (CB_LITERAL_P (r->offset)) {
6146  dst_off += cb_get_int (r->offset) - 1;
6147  } else {
6148  goto overlapret;
6149  }
6150  }
6151  if (src_off >= dst_off && src_off < (dst_off + dst_size)) {
6152  goto overlapret;
6153  }
6154  if (src_off < dst_off && (src_off + src_size) > dst_off) {
6155  goto overlapret;
6156  }
6157  return 0;
6158 overlapret:
6159  loc = src->source_line ? src : dst;
6160  if (cb_warn_overlap && !suppress_warn) {
6161  cb_warning_x (loc, _("Overlapping MOVE may produce unpredictable results"));
6162  }
6163  return 1;
6164 }
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
#define CB_LITERAL_P(x)
Definition: tree.h:602
int offset
Definition: tree.h:675
int source_line
Definition: tree.h:432
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
cb_tree offset
Definition: tree.h:878
cob_field f1
Definition: cobxref.c.l.h:54
unsigned int flag_occurs
Definition: tree.h:702
#define CB_REFERENCE(x)
Definition: tree.h:901
int mem_offset
Definition: tree.h:681
size_t suppress_warn
Definition: typeck.c:90
struct cb_field * redefines
Definition: tree.h:654
struct cb_field * cb_field_founder(const struct cb_field *f)
Definition: tree.c:2227

Here is the call graph for this function:

Here is the caller graph for this function:

static int cb_chk_alpha_cond ( cb_tree  x)
static

Definition at line 3712 of file typeck.c.

References cb_program::alphabet_name_list, CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_FIELD_PTR, cb_field_size(), cb_field_variable_size(), CB_LITERAL_P, CB_REF_OR_FIELD_P, CB_TREE_CATEGORY, and current_program.

Referenced by cb_build_cond().

3713 {
3715  return 0;
3716  }
3717  if (CB_LITERAL_P (x)) {
3718  return 1;
3719  }
3720  if (!CB_REF_OR_FIELD_P (x)) {
3721  return 0;
3722  }
3725  return 0;
3726  }
3728  return 0;
3729  }
3730  if (cb_field_size (x) < 0) {
3731  return 0;
3732  }
3733  return 1;
3734 }
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_field * cb_field_variable_size(const struct cb_field *f)
Definition: tree.c:2239
#define CB_LITERAL_P(x)
Definition: tree.h:602
cb_tree alphabet_name_list
Definition: tree.h:1256
struct cb_program * current_program
Definition: parser.c:168
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743

Here is the call graph for this function:

Here is the caller graph for this function:

static int cb_chk_num_cond ( cb_tree  x,
cb_tree  y 
)
static

Definition at line 3668 of file typeck.c.

References CB_CATEGORY_NUMERIC, CB_CLASS_NUMERIC, CB_FIELD_PTR, CB_REF_OR_FIELD_P, CB_TREE_CATEGORY, CB_TREE_CLASS, CB_USAGE_DISPLAY, cb_picture::have_sign, cb_field::pic, cb_picture::scale, cb_field::size, and cb_field::usage.

Referenced by cb_build_cond().

3669 {
3670  struct cb_field *fx;
3671  struct cb_field *fy;
3672 
3673  if (!CB_REF_OR_FIELD_P (x)) {
3674  return 0;
3675  }
3676  if (!CB_REF_OR_FIELD_P (y)) {
3677  return 0;
3678  }
3680  return 0;
3681  }
3683  return 0;
3684  }
3685  if (CB_TREE_CLASS (x) != CB_CLASS_NUMERIC) {
3686  return 0;
3687  }
3688  if (CB_TREE_CLASS (y) != CB_CLASS_NUMERIC) {
3689  return 0;
3690  }
3691  fx = CB_FIELD_PTR (x);
3692  fy = CB_FIELD_PTR (y);
3693  if (fx->usage != CB_USAGE_DISPLAY) {
3694  return 0;
3695  }
3696  if (fy->usage != CB_USAGE_DISPLAY) {
3697  return 0;
3698  }
3699  if (fx->pic->have_sign || fy->pic->have_sign) {
3700  return 0;
3701  }
3702  if (fx->size != fy->size) {
3703  return 0;
3704  }
3705  if (fx->pic->scale != fy->pic->scale) {
3706  return 0;
3707  }
3708  return 1;
3709 }
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
int scale
Definition: tree.h:626
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
#define CB_TREE_CLASS(x)
Definition: tree.h:442
Definition: tree.h:643
int size
Definition: tree.h:672
cob_u32_t have_sign
Definition: tree.h:627
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
enum cb_usage usage
Definition: tree.h:693

Here is the caller graph for this function:

cb_tree cb_define_switch_name ( cb_tree  name,
cb_tree  sname,
const int  flag 
)

Definition at line 1228 of file typeck.c.

References _, cb_build_constant(), CB_BUILD_FUNCALL_1, CB_BUILD_NEGATION, cb_error_node, cb_error_x(), cb_int(), CB_SWITCH_NAME, CB_SYSTEM_NAME, NULL, and value.

Referenced by yyparse().

1229 {
1230  cb_tree switch_id;
1231  cb_tree value;
1232 
1233  if (!name || name == cb_error_node) {
1234  return NULL;
1235  }
1236  if (!sname || sname == cb_error_node ||
1237  CB_SYSTEM_NAME (sname)->category != CB_SWITCH_NAME) {
1238  cb_error_x (name, _("ON/OFF usage requires a SWITCH name"));
1239  return NULL;
1240  }
1241  switch_id = cb_int (CB_SYSTEM_NAME (sname)->token);
1242  value = CB_BUILD_FUNCALL_1 ("cob_get_switch", switch_id);
1243  if (flag == 0) {
1244  value = CB_BUILD_NEGATION (value);
1245  }
1246  cb_build_constant (name, value);
1247  return value;
1248 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
cb_tree cb_build_constant(cb_tree name, cb_tree value)
Definition: tree.c:2189
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
strict implicit external value
Definition: warning.def:54
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int(const int n)
Definition: tree.c:1488
cb_tree cb_error_node
Definition: tree.c:140

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept ( cb_tree  var,
cb_tree  pos,
struct cb_attr_struct attr_ptr 
)

Definition at line 4341 of file typeck.c.

References _, cb_attr_struct::bgc, CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_10, CB_BUILD_FUNCALL_4, cb_emit, cb_error_x(), CB_FIELD, CB_FIELD_PTR, cb_gen_field_accept(), cb_int(), CB_LIST_P, CB_LITERAL, CB_LITERAL_P, cb_null, CB_PAIR_X, CB_PAIR_Y, cb_ref(), CB_REF_OR_FIELD_P, CB_STORAGE_SCREEN, cb_validate_one(), cb_program::crt_status, current_program, cb_attr_struct::dispattrs, cb_attr_struct::fgc, cb_program::flag_screen, gen_screen_ptr, line, NULL, output_screen_from(), output_screen_to(), cb_attr_struct::prompt, cb_attr_struct::scroll, cb_field::size, cb_attr_struct::size_is, cb_field::storage, cb_attr_struct::timeout, and valid_screen_pos().

Referenced by yyparse().

4342 {
4343  cb_tree line;
4344  cb_tree column;
4345  cb_tree fgc;
4346  cb_tree bgc;
4347  cb_tree scroll;
4348  cb_tree timeout;
4349  cb_tree prompt;
4350  cb_tree size_is; /* WITH SIZE IS */
4351  int dispattrs;
4352 
4353  if (cb_validate_one (var)) {
4354  return;
4355  }
4356 
4357  if (attr_ptr) {
4358  fgc = attr_ptr->fgc;
4359  bgc = attr_ptr->bgc;
4360  scroll = attr_ptr->scroll;
4361  timeout = attr_ptr->timeout;
4362  prompt = attr_ptr->prompt;
4363  size_is = attr_ptr->size_is;
4364  dispattrs = attr_ptr->dispattrs;
4365  if (cb_validate_one (pos)) {
4366  return;
4367  }
4368  if (cb_validate_one (fgc)) {
4369  return;
4370  }
4371  if (cb_validate_one (bgc)) {
4372  return;
4373  }
4374  if (cb_validate_one (scroll)) {
4375  return;
4376  }
4377  if (cb_validate_one (timeout)) {
4378  return;
4379  }
4380  if (cb_validate_one (prompt)) {
4381  return;
4382  }
4383  if (cb_validate_one (size_is)) {
4384  return;
4385  }
4386  } else {
4387  fgc = NULL;
4388  bgc = NULL;
4389  scroll = NULL;
4390  timeout = NULL;
4391  prompt = NULL;
4392  size_is = NULL;
4393  dispattrs = 0;
4394  }
4395 
4396  if (prompt) {
4397  /* PROMPT character - 1 character identifier or literal */
4398  if (CB_LITERAL_P (prompt)) {
4399  if (CB_LITERAL (prompt)->size != 1) {
4400  cb_error_x (prompt, _("Invalid PROMPT literal"));
4401  return;
4402  }
4403  } else {
4404  if (CB_FIELD_PTR (prompt)->size != 1) {
4405  cb_error_x (prompt, _("Invalid PROMPT identifier"));
4406  return;
4407  }
4408  }
4409  }
4410 
4411 #if 0 /* RXWRXW - Screen */
4412  if ((CB_REF_OR_FIELD_P (var)) &&
4413  CB_FIELD (cb_ref (var))->storage == CB_STORAGE_SCREEN) {
4415  }
4416 #endif
4417 
4419  /* Bump ref count to force CRT STATUS field generation */
4420  if (current_program->crt_status) {
4422  }
4423  if ((CB_REF_OR_FIELD_P (var)) &&
4424  CB_FIELD (cb_ref (var))->storage == CB_STORAGE_SCREEN) {
4425  output_screen_from (CB_FIELD (cb_ref (var)), 0);
4426  gen_screen_ptr = 1;
4427  if (pos) {
4428  if (CB_LIST_P (pos)) {
4429  line = CB_PAIR_X (pos);
4430  column = CB_PAIR_Y (pos);
4431  cb_emit (CB_BUILD_FUNCALL_4 ("cob_screen_accept",
4432  var, line, column, timeout));
4433  } else if (valid_screen_pos (pos)) {
4434  cb_emit (CB_BUILD_FUNCALL_4 ("cob_screen_accept",
4435  var, pos, NULL, timeout));
4436  }
4437  } else {
4438  cb_emit (CB_BUILD_FUNCALL_4 ("cob_screen_accept",
4439  var, NULL, NULL, timeout));
4440  }
4441  gen_screen_ptr = 0;
4442  output_screen_to (CB_FIELD (cb_ref (var)), 0);
4443  } else {
4444  if (var == cb_null) {
4445  var = NULL;
4446  }
4447  if (pos || fgc || bgc || scroll || dispattrs) {
4448  cb_gen_field_accept (var, pos, fgc, bgc, scroll,
4449  timeout, prompt, size_is, dispattrs);
4450  } else {
4451  cb_emit (CB_BUILD_FUNCALL_10 ("cob_field_accept",
4452  var, NULL, NULL, fgc, bgc,
4453  scroll, timeout, prompt,
4454  size_is, cb_int (dispattrs)));
4455  }
4456  }
4457  } else if (pos || fgc || bgc || scroll || dispattrs) {
4458  /* Bump ref count to force CRT STATUS field generation */
4459  if (current_program->crt_status) {
4461  }
4462  if (var == cb_null) {
4463  var = NULL;
4464  }
4465  cb_gen_field_accept (var, pos, fgc, bgc, scroll,
4466  timeout, prompt, size_is, dispattrs);
4467  } else {
4468  if (var == cb_null) {
4469  var = NULL;
4470  }
4471  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept", var));
4472  }
4473 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static void output_screen_to(struct cb_field *p, const unsigned int sisters)
Definition: typeck.c:4222
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_PAIR_Y(x)
Definition: tree.h:1206
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
cb_tree scroll
Definition: tree.h:1126
cb_tree crt_status
Definition: tree.h:1287
cb_tree size_is
Definition: tree.h:1129
unsigned int flag_screen
Definition: tree.h:1309
cb_tree bgc
Definition: tree.h:1125
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static int valid_screen_pos(cb_tree pos)
Definition: typeck.c:4289
cb_tree timeout
Definition: tree.h:1127
static void output_screen_from(struct cb_field *p, const unsigned int sisters)
Definition: typeck.c:4199
cb_tree cb_int(const int n)
Definition: tree.c:1488
int size
Definition: tree.h:672
#define CB_BUILD_FUNCALL_10(f, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
Definition: tree.h:1835
unsigned int gen_screen_ptr
Definition: tree.c:146
static void cb_gen_field_accept(cb_tree var, cb_tree pos, cb_tree fgc, cb_tree bgc, cb_tree scroll, cb_tree timeout, cb_tree prompt, cb_tree size_is, int dispattrs)
Definition: typeck.c:4316
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
#define CB_LIST_P(x)
Definition: tree.h:1190
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_null
Definition: tree.c:124
cb_tree prompt
Definition: tree.h:1128
#define cb_emit(x)
Definition: typeck.c:75
int dispattrs
Definition: tree.h:1130
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree fgc
Definition: tree.h:1124
enum cb_storage storage
Definition: tree.h:692
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_arg_number ( cb_tree  var)

Definition at line 4596 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4597 {
4598  if (cb_validate_one (var)) {
4599  return;
4600  }
4601  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_arg_number", var));
4602 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_arg_value ( cb_tree  var)

Definition at line 4605 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4606 {
4607  if (cb_validate_one (var)) {
4608  return;
4609  }
4610  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_arg_value", var));
4611 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_command_line ( cb_tree  var)

Definition at line 4566 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4567 {
4568  if (cb_validate_one (var)) {
4569  return;
4570  }
4571  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_command_line", var));
4572 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_date ( cb_tree  var)

Definition at line 4512 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4513 {
4514  if (cb_validate_one (var)) {
4515  return;
4516  }
4517  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_date", var));
4518 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_date_yyyymmdd ( cb_tree  var)

Definition at line 4521 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4522 {
4523  if (cb_validate_one (var)) {
4524  return;
4525  }
4526  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_date_yyyymmdd", var));
4527 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_day ( cb_tree  var)

Definition at line 4530 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4531 {
4532  if (cb_validate_one (var)) {
4533  return;
4534  }
4535  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_day", var));
4536 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_day_of_week ( cb_tree  var)

Definition at line 4548 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4549 {
4550  if (cb_validate_one (var)) {
4551  return;
4552  }
4553  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_day_of_week", var));
4554 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_day_yyyyddd ( cb_tree  var)

Definition at line 4539 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4540 {
4541  if (cb_validate_one (var)) {
4542  return;
4543  }
4544  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_day_yyyyddd", var));
4545 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_environment ( cb_tree  var)

Definition at line 4587 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4588 {
4589  if (cb_validate_one (var)) {
4590  return;
4591  }
4592  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_environment", var));
4593 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_escape_key ( cb_tree  var)

Definition at line 4485 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4486 {
4487  if (cb_validate_one (var)) {
4488  return;
4489  }
4490  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_escape_key", var));
4491 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_exception_status ( cb_tree  var)

Definition at line 4494 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4495 {
4496  if (cb_validate_one (var)) {
4497  return;
4498  }
4499  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_exception_status", var));
4500 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_line_or_col ( cb_tree  var,
const int  l_or_c 
)

Definition at line 4476 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_emit, cb_int(), and cb_validate_one().

Referenced by yyparse().

4477 {
4478  if (cb_validate_one (var)) {
4479  return;
4480  }
4481  cb_emit (CB_BUILD_FUNCALL_2 ("cob_screen_line_col", var, cb_int (l_or_c)));
4482 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_mnemonic ( cb_tree  var,
cb_tree  mnemonic 
)

Definition at line 4614 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, CB_DEVICE_CONSOLE, CB_DEVICE_SYSIN, cb_emit, cb_error_node, cb_error_x(), cb_name(), cb_ref(), CB_SYSTEM_NAME, and cb_validate_one().

Referenced by yyparse().

4615 {
4616  if (cb_validate_one (var)) {
4617  return;
4618  }
4619  if (cb_ref (mnemonic) == cb_error_node) {
4620  return;
4621  }
4622  switch (CB_SYSTEM_NAME (cb_ref (mnemonic))->token) {
4623  case CB_DEVICE_CONSOLE:
4624  case CB_DEVICE_SYSIN:
4625  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept", var));
4626  break;
4627  default:
4628  cb_error_x (mnemonic, _("Invalid input device '%s'"),
4629  cb_name (mnemonic));
4630  break;
4631  }
4632 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define _(s)
Definition: cobcrun.c:59
#define CB_DEVICE_SYSIN
Definition: tree.h:153
cb_tree cb_error_node
Definition: tree.c:140
#define CB_DEVICE_CONSOLE
Definition: tree.h:156
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_name ( cb_tree  var,
cb_tree  name 
)

Definition at line 4635 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, CB_DEVICE_CONSOLE, CB_DEVICE_SYSIN, cb_emit, cb_error_x(), cb_name(), CB_NAME, CB_SYSTEM_NAME, cb_validate_one(), cb_warning_x(), and lookup_system_name().

Referenced by yyparse().

4636 {
4637  cb_tree sys;
4638 
4639  if (cb_validate_one (var)) {
4640  return;
4641  }
4642 
4643  /* Allow direct reference to a device name */
4644  sys = lookup_system_name (CB_NAME (name));
4645  if (sys) {
4646  switch (CB_SYSTEM_NAME (sys)->token) {
4647  case CB_DEVICE_CONSOLE:
4648  case CB_DEVICE_SYSIN:
4649  if (!cb_relaxed_syntax_check) {
4650  cb_warning_x (name, _("'%s' is not defined in SPECIAL-NAMES"), CB_NAME (name));
4651  }
4652  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept", var));
4653  return;
4654  default:
4655  cb_error_x (name, _("Invalid input device '%s'"),
4656  cb_name (name));
4657  return;
4658  }
4659  }
4660 
4661  cb_error_x (name, _("'%s' is not defined in SPECIAL-NAMES"),
4662  CB_NAME (name));
4663 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define _(s)
Definition: cobcrun.c:59
cb_tree lookup_system_name(const char *name)
Definition: reserved.c:2860
#define CB_DEVICE_SYSIN
Definition: tree.h:153
#define CB_NAME(x)
Definition: tree.h:904
#define CB_DEVICE_CONSOLE
Definition: tree.h:156
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_time ( cb_tree  var)

Definition at line 4557 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4558 {
4559  if (cb_validate_one (var)) {
4560  return;
4561  }
4562  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_time", var));
4563 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_accept_user_name ( cb_tree  var)

Definition at line 4503 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

4504 {
4505  if (cb_validate_one (var)) {
4506  return;
4507  }
4508  cb_emit (CB_BUILD_FUNCALL_1 ("cob_accept_user_name", var));
4509 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_allocate ( cb_tree  target1,
cb_tree  target2,
cb_tree  size,
cb_tree  initialize 
)

Definition at line 4668 of file typeck.c.

References _, CB_BUILD_CAST_ADDR_OF_ADDR, CB_BUILD_FUNCALL_4, cb_build_initialize(), cb_build_numeric_literal(), cb_category_is_alpha(), CB_CLASS_NUMERIC, CB_CLASS_POINTER, cb_emit, cb_error_x(), CB_FIELD_PTR, CB_REFERENCE_P, CB_TREE, CB_TREE_CLASS, cb_true, cb_validate_one(), current_statement, cb_field::flag_item_based, cb_statement::handler2, cb_field::memory_size, and NULL.

Referenced by yyparse().

4670 {
4671  cb_tree x;
4672  char buff[32];
4673 
4674  if (cb_validate_one (target1)) {
4675  return;
4676  }
4677  if (cb_validate_one (target2)) {
4678  return;
4679  }
4680  if (cb_validate_one (size)) {
4681  return;
4682  }
4683  if (cb_validate_one (initialize)) {
4684  return;
4685  }
4686  if (target1) {
4687  if (!(CB_REFERENCE_P(target1) &&
4688  CB_FIELD_PTR (target1)->flag_item_based)) {
4690  _("Target of ALLOCATE is not a BASED item"));
4691  return;
4692  }
4693  }
4694  if (target2) {
4695  if (!(CB_REFERENCE_P(target2) &&
4696  CB_TREE_CLASS (target2) == CB_CLASS_POINTER)) {
4698  _("Target of RETURNING is not a data pointer"));
4699  return;
4700  }
4701  }
4702  if (size) {
4703  if (CB_TREE_CLASS (size) != CB_CLASS_NUMERIC) {
4705  _("The CHARACTERS field of ALLOCATE must be numeric"));
4706  return;
4707  }
4708  }
4709  if (target1) {
4710  sprintf (buff, "%d", CB_FIELD_PTR (target1)->memory_size);
4711  x = cb_build_numeric_literal (0, buff, 0);
4712  cb_emit (CB_BUILD_FUNCALL_4 ("cob_allocate",
4713  CB_BUILD_CAST_ADDR_OF_ADDR (target1),
4714  target2, x, NULL));
4715  } else {
4716  if (initialize && !cb_category_is_alpha (initialize)) {
4718  _("INITIALIZED TO item is not alphanumeric"));
4719  }
4720  cb_emit (CB_BUILD_FUNCALL_4 ("cob_allocate",
4721  NULL, target2, size, initialize));
4722  }
4723  if (initialize && target1) {
4725  cb_build_initialize (target1, cb_true, NULL, 1, 0, 0);
4726  }
4727 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_true
Definition: tree.c:122
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
#define CB_TREE_CLASS(x)
Definition: tree.h:442
cb_tree cb_build_numeric_literal(const int sign, const void *data, const int scale)
Definition: tree.c:1681
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_BUILD_CAST_ADDR_OF_ADDR(x)
Definition: tree.h:1842
cb_tree cb_build_initialize(const cb_tree var, const cb_tree val, const cb_tree rep, const unsigned int def, const unsigned int is_statement, const unsigned int no_filler_init)
Definition: tree.c:3028
int cb_category_is_alpha(cb_tree x)
Definition: tree.c:843
int memory_size
Definition: tree.h:674
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree handler2
Definition: tree.h:1142
unsigned int flag_item_based
Definition: tree.h:713

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_alter ( cb_tree  source,
cb_tree  target 
)

Definition at line 4733 of file typeck.c.

References cb_build_alter(), cb_emit, cb_error_node, and CB_REFERENCE.

Referenced by yyparse().

4734 {
4735  if (source == cb_error_node) {
4736  return;
4737  }
4738  if (target == cb_error_node) {
4739  return;
4740  }
4741  CB_REFERENCE(source)->flag_alter_code = 1;
4742  cb_emit (cb_build_alter (source, target));
4743 }
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
cb_tree cb_build_alter(const cb_tree source, const cb_tree target)
Definition: tree.c:3101
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_arg_number ( cb_tree  value)

Definition at line 5124 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

5125 {
5126  if (cb_validate_one (value)) {
5127  return;
5128  }
5129  cb_emit (CB_BUILD_FUNCALL_1 ("cob_display_arg_number", value));
5130 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_arithmetic ( cb_tree  vars,
const int  op,
cb_tree  val 
)

Definition at line 3465 of file typeck.c.

References build_decimal_assign(), CB_BINARY_OP_P, cb_build_add(), cb_build_div(), cb_build_mul(), cb_build_sub(), CB_CHAIN, cb_check_data_incompat(), cb_check_numeric_edited_name(), cb_check_numeric_name(), cb_check_numeric_value(), cb_emit_list, cb_error_node, cb_list_map(), CB_PURPOSE, cb_validate_list(), cb_validate_one(), and CB_VALUE.

Referenced by yyparse().

3466 {
3467  cb_tree l;
3468  cb_tree x;
3469 
3470  x = cb_check_numeric_value (val);
3471 
3472  if (op) {
3474  } else {
3476  }
3477 
3478  if (cb_validate_one (x)) {
3479  return;
3480  }
3481  if (cb_validate_list (vars)) {
3482  return;
3483  }
3484 
3485  if (!CB_BINARY_OP_P (x)) {
3486  if (op == '+' || op == '-' || op == '*' || op == '/') {
3488  for (l = vars; l; l = CB_CHAIN (l)) {
3490  switch (op) {
3491  case '+':
3492  CB_VALUE (l) = cb_build_add (CB_VALUE (l), x, CB_PURPOSE (l));
3493  break;
3494  case '-':
3495  CB_VALUE (l) = cb_build_sub (CB_VALUE (l), x, CB_PURPOSE (l));
3496  break;
3497  case '*':
3498  CB_VALUE (l) = cb_build_mul (CB_VALUE (l), x, CB_PURPOSE (l));
3499  break;
3500  case '/':
3501  CB_VALUE (l) = cb_build_div (CB_VALUE (l), x, CB_PURPOSE (l));
3502  break;
3503  }
3504  }
3505  cb_emit_list (vars);
3506  return;
3507  }
3508  }
3509  if (x == cb_error_node) {
3510  return;
3511  }
3512 
3513  cb_emit_list (build_decimal_assign (vars, op, x));
3514 }
static cb_tree cb_check_numeric_edited_name(cb_tree x)
Definition: typeck.c:633
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_build_add(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:4015
static cb_tree cb_build_mul(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:3368
#define CB_PURPOSE(x)
Definition: tree.h:1192
cb_tree cb_build_sub(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:4058
#define cb_emit_list(l)
Definition: typeck.c:77
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BINARY_OP_P(x)
Definition: tree.h:937
static void cb_check_data_incompat(cb_tree x)
Definition: typeck.c:719
#define CB_CHAIN(x)
Definition: tree.h:1194
static cb_tree cb_build_div(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:3390
cb_tree cb_error_node
Definition: tree.c:140
static cb_tree build_decimal_assign(cb_tree vars, const int op, cb_tree val)
Definition: typeck.c:3412
void cb_list_map(cb_tree(*func)(cb_tree x), cb_tree l)
Definition: tree.c:1357
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
cb_tree cb_check_numeric_value(cb_tree x)
Definition: typeck.c:651
static cb_tree cb_check_numeric_name(cb_tree x)
Definition: typeck.c:616

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_call ( cb_tree  prog,
cb_tree  par_using,
cb_tree  returning,
cb_tree  on_exception,
cb_tree  not_on_exception,
cb_tree  convention 
)

Definition at line 4748 of file typeck.c.

References _, cb_build_call(), CB_CALL_BY_REFERENCE, CB_CALL_BY_VALUE, CB_CATEGORY_ALPHANUMERIC, CB_CHAIN, CB_CLASS_NUMERIC, CB_CLASS_POINTER, CB_CONST_P, CB_CONV_STATIC_LINK, CB_CONV_STDCALL, cb_emit, cb_error_node, cb_error_x(), CB_FIELD_P, CB_FIELD_PTR, cb_get_int(), cb_get_long_long(), CB_INTEGER, CB_INTEGER_P, CB_INTRINSIC, CB_INTRINSIC_P, cb_list_length(), CB_LITERAL, CB_LITERAL_P, CB_NAME, cb_null, CB_NUMERIC_LITERAL_P, CB_PURPOSE_INT, CB_REFERENCE, CB_REFERENCE_P, CB_SIZE_1, CB_SIZE_2, CB_SIZE_4, CB_SIZE_8, CB_SIZE_AUTO, CB_SIZES_INT, CB_SIZES_INT_UNSIGNED, CB_TREE, CB_TREE_CLASS, CB_VALUE, cb_warning(), cb_warning_x(), cob_s64_t, cob_u32_t, current_program, current_statement, cb_field::flag_any_length, cb_field::level, cb_program::max_call_param, NULL, sign, system_table::syst_name, system_table::syst_params, value, and warningopt.

Referenced by yyparse().

4751 {
4752  cb_tree l;
4753  cb_tree x;
4754  struct cb_field *f;
4755  const struct system_table *psyst;
4756  const char *p;
4757  const char *entry;
4758  cob_s64_t val;
4759  cob_s64_t valmin;
4760  cob_s64_t valmax;
4761  cob_u32_t is_sys_call;
4762  cob_u32_t is_sys_idx;
4763  int error_ind;
4764  int call_conv;
4765  int numargs;
4766 
4767  if (CB_INTRINSIC_P (prog)) {
4768  if (CB_INTRINSIC(prog)->intr_tab->category != CB_CATEGORY_ALPHANUMERIC) {
4770  _("Only alphanumeric FUNCTION types are allowed here"));
4771  return;
4772  }
4773  }
4774  if (returning && returning != cb_null) {
4775  if (CB_TREE_CLASS(returning) != CB_CLASS_NUMERIC &&
4776  CB_TREE_CLASS(returning) != CB_CLASS_POINTER) {
4778  _("Invalid RETURNING field"));
4779  return;
4780  }
4781  }
4782 
4783  error_ind = 0;
4784  numargs = 0;
4785 
4786  if (convention) {
4787  if (CB_INTEGER_P (convention)) {
4788  call_conv = CB_INTEGER (convention)->val;
4789  } else {
4790  call_conv = cb_get_int (convention);
4791  }
4792  } else {
4793  call_conv = 0;
4794  }
4795 #ifndef _WIN32
4796  if (call_conv & CB_CONV_STDCALL) {
4797  call_conv &= ~CB_CONV_STDCALL;
4798  if (warningopt) {
4799  cb_warning (_("STDCALL not available on this platform"));
4800  }
4801  }
4802 #elif defined(_WIN64)
4803  if (call_conv & CB_CONV_STDCALL) {
4804  if (warningopt) {
4805  cb_warning (_("STDCALL used on 64-bit Windows platform"));
4806  }
4807  }
4808 #endif
4809  if ((call_conv & CB_CONV_STATIC_LINK) && !CB_LITERAL_P (prog)) {
4811  _("STATIC CALL convention requires a literal program name"));
4812  error_ind = 1;
4813  }
4814 
4815  for (l = par_using; l; l = CB_CHAIN (l), numargs++) {
4816  x = CB_VALUE (l);
4817  if (x == cb_error_node) {
4818  error_ind = 1;
4819  continue;
4820  }
4821  if (CB_NUMERIC_LITERAL_P (x)) {
4822  if (CB_PURPOSE_INT (l) != CB_CALL_BY_VALUE) {
4823  continue;
4824  }
4825  if (CB_SIZES_INT_UNSIGNED(l) &&
4826  CB_LITERAL (x)->sign < 0) {
4827  cb_error_x (x, _("Numeric literal is negative"));
4828  error_ind = 1;
4829  continue;
4830  }
4831  val = 0;
4832  valmin = 0;
4833  valmax = 0;
4834  switch (CB_SIZES_INT (l)) {
4835  case CB_SIZE_1:
4836  val = cb_get_long_long (x);
4837  if (CB_SIZES_INT_UNSIGNED(l)) {
4838  valmin = 0;
4839  valmax = UCHAR_MAX;
4840  } else {
4841  valmin = CHAR_MIN;
4842  valmax = CHAR_MAX;
4843  }
4844  break;
4845  case CB_SIZE_2:
4846  val = cb_get_long_long (x);
4847  if (CB_SIZES_INT_UNSIGNED(l)) {
4848  valmin = 0;
4849  valmax = USHRT_MAX;
4850  } else {
4851  valmin = SHRT_MIN;
4852  valmax = SHRT_MAX;
4853  }
4854  break;
4855  case CB_SIZE_4:
4856  val = cb_get_long_long (x);
4857  if (CB_SIZES_INT_UNSIGNED(l)) {
4858  valmin = 0;
4859  valmax = UINT_MAX;
4860  } else {
4861  valmin = INT_MIN;
4862  valmax = INT_MAX;
4863  }
4864  break;
4865  case CB_SIZE_8:
4866  case CB_SIZE_AUTO:
4867  if (CB_SIZES_INT_UNSIGNED(l)) {
4868  if (CB_LITERAL (x)->size < 20) {
4869  break;
4870  }
4871  if (CB_LITERAL (x)->size > 20) {
4872  valmin = 1;
4873  break;
4874  }
4875  if (memcmp (CB_LITERAL (x)->data,
4876  "18446744073709551615",
4877  (size_t)20) > 0) {
4878  valmin = 1;
4879  break;
4880  }
4881  } else {
4882  if (CB_LITERAL (x)->size < 19) {
4883  break;
4884  }
4885  if (CB_LITERAL (x)->size > 19) {
4886  valmin = 1;
4887  break;
4888  }
4889  if (memcmp (CB_LITERAL (x)->data,
4890  "9223372036854775807",
4891  (size_t)19) > 0) {
4892  valmin = 1;
4893  break;
4894  }
4895  }
4896  break;
4897  default:
4898  break;
4899  }
4900  if (!valmin && !valmax) {
4901  continue;
4902  }
4903  if (val < valmin || val > valmax) {
4904  cb_error_x (x, _("Numeric literal exceeds size limits"));
4905  error_ind = 1;
4906  }
4907  continue;
4908  }
4909  if (CB_CONST_P (x) && x != cb_null) {
4910  cb_error_x (x, _("Figurative constant invalid here"));
4911  error_ind = 1;
4912  continue;
4913  }
4914  if ((CB_REFERENCE_P (x) && CB_FIELD_P(CB_REFERENCE(x)->value)) ||
4915  CB_FIELD_P (x)) {
4916  f = CB_FIELD_PTR (x);
4917  if (f->level == 88) {
4918  cb_error_x (x, _("'%s' is not a valid data name"), CB_NAME (x));
4919  error_ind = 1;
4920  continue;
4921  }
4922  if (f->flag_any_length &&
4924  cb_error_x (x, _("'%s' ANY LENGTH item not passed BY REFERENCE"), CB_NAME (x));
4925  error_ind = 1;
4926  continue;
4927  }
4928  if (cb_warn_call_params &&
4930  if (f->level != 01 && f->level != 77) {
4931  cb_warning_x (x, _("'%s' is not a 01 or 77 level item"), CB_NAME (x));
4932  }
4933  }
4934  }
4935  }
4936 
4937  is_sys_call = 0;
4938  if (CB_LITERAL_P(prog)) {
4939  entry = NULL;
4940  p = (const char *)CB_LITERAL(prog)->data;
4941  for (; *p; ++p) {
4942  if (*p == '/' || *p == '\\') {
4943  entry = p + 1;
4944  }
4945  }
4946  if (!entry) {
4947  entry = (const char *)CB_LITERAL(prog)->data;
4948  }
4949  is_sys_idx = 1;
4950  for (psyst = system_tab; psyst->syst_name; psyst++, is_sys_idx++) {
4951  if (!strcmp(entry, (const char *)psyst->syst_name)) {
4952  if (psyst->syst_params > cb_list_length (par_using)) {
4954  _("Wrong number of CALL parameters for '%s'"),
4955  (char *)psyst->syst_name);
4956  return;
4957  }
4958  is_sys_call = is_sys_idx;
4959  break;
4960  }
4961  }
4962  }
4963 
4964  if (error_ind) {
4965  return;
4966  }
4967  if (numargs > current_program->max_call_param) {
4968  current_program->max_call_param = numargs;
4969  }
4970  cb_emit (cb_build_call (prog, par_using, on_exception, not_on_exception,
4971  returning, is_sys_call, call_conv));
4972 }
#define CB_NUMERIC_LITERAL_P(x)
Definition: tree.h:603
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_INTEGER(x)
Definition: tree.h:522
static const struct system_table system_tab[]
Definition: typeck.c:282
#define cob_u32_t
Definition: common.h:31
#define CB_CALL_BY_REFERENCE
Definition: tree.h:44
#define CB_CONST_P(x)
Definition: tree.h:477
unsigned int flag_any_length
Definition: tree.h:712
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
cb_tree cb_build_call(const cb_tree name, const cb_tree args, const cb_tree stmt1, const cb_tree stmt2, const cb_tree returning, const cob_u32_t is_system_call, const int convention)
Definition: tree.c:3067
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_INTRINSIC(x)
Definition: tree.h:1001
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_CONV_STDCALL
Definition: tree.h:135
#define CB_SIZE_8
Definition: tree.h:52
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
int warningopt
Definition: cobc.c:176
#define CB_PURPOSE_INT(x)
Definition: tree.h:1197
#define CB_SIZE_2
Definition: tree.h:50
int max_call_param
Definition: tree.h:1298
int level
Definition: tree.h:673
#define CB_SIZES_INT(x)
Definition: tree.h:1199
#define cob_s64_t
Definition: common.h:51
#define CB_SIZE_4
Definition: tree.h:51
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_SIZE_AUTO
Definition: tree.h:48
int cb_list_length(cb_tree l)
Definition: tree.c:1342
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define CB_SIZE_1
Definition: tree.h:49
#define _(s)
Definition: cobcrun.c:59
const int syst_params
Definition: typeck.c:48
Definition: tree.h:643
#define CB_CALL_BY_VALUE
Definition: tree.h:46
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
if sign
Definition: flag.def:42
#define CB_NAME(x)
Definition: tree.h:904
#define CB_REFERENCE(x)
Definition: tree.h:901
#define CB_CONV_STATIC_LINK
Definition: tree.h:132
cb_tree cb_error_node
Definition: tree.c:140
#define CB_INTRINSIC_P(x)
Definition: tree.h:1002
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_null
Definition: tree.c:124
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
#define CB_SIZES_INT_UNSIGNED(x)
Definition: tree.h:1200
const char * syst_name
Definition: codegen.c:66
#define cb_emit(x)
Definition: typeck.c:75
cob_s64_t cb_get_long_long(const cb_tree x)
Definition: tree.c:1175
#define CB_INTEGER_P(x)
Definition: tree.h:523
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_cancel ( cb_tree  prog)

Definition at line 4977 of file typeck.c.

References cb_build_cancel(), cb_emit, and cb_validate_one().

Referenced by yyparse().

4978 {
4979  if (cb_validate_one (prog)) {
4980  return;
4981  }
4982  cb_emit (cb_build_cancel (prog));
4983 }
cb_tree cb_build_cancel(const cb_tree target)
Definition: tree.c:3088
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_close ( cb_tree  file,
cb_tree  opt 
)

Definition at line 4988 of file typeck.c.

References _, cb_build_debug(), cb_build_debug_call(), CB_BUILD_FUNCALL_4, cb_build_move(), cb_emit, cb_error_node, cb_error_x(), CB_FILE, cb_int0, cb_ref(), cb_space, CB_TREE, COB_ORG_SORT, current_program, current_statement, cb_file::debug_section, file, cb_statement::file, cb_file::file_status, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, cb_file::name, NULL, and cb_file::organization.

Referenced by yyparse().

4989 {
4990  struct cb_file *f;
4991 
4992  if (file == cb_error_node) {
4993  return;
4994  }
4995  file = cb_ref (file);
4996  if (file == cb_error_node) {
4997  return;
4998  }
5000  f = CB_FILE (file);
5001 
5002  if (f->organization == COB_ORG_SORT) {
5004  _("%s not allowed on %s files"), "CLOSE", "SORT");
5005  }
5006 
5007  cb_emit (CB_BUILD_FUNCALL_4 ("cob_close", file,
5008  f->file_status, opt, cb_int0));
5009 
5010  /* Check for file debugging */
5013  CB_FILE(file)->flag_fl_debug) {
5017  }
5018 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_debug_name
Definition: typeck.c:84
const char * name
Definition: tree.h:820
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
cb_tree cb_space
Definition: tree.c:127
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
struct cb_label * debug_section
Definition: tree.h:839
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int0
Definition: tree.c:133
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree file
Definition: tree.h:1140
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
cb_tree cb_debug_contents
Definition: typeck.c:88
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_command_line ( cb_tree  value)

Definition at line 5133 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

5134 {
5135  if (cb_validate_one (value)) {
5136  return;
5137  }
5138  cb_emit (CB_BUILD_FUNCALL_1 ("cob_display_command_line", value));
5139 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_commit ( void  )

Definition at line 5023 of file typeck.c.

References CB_BUILD_FUNCALL_0, and cb_emit.

Referenced by yyparse().

5024 {
5025  cb_emit (CB_BUILD_FUNCALL_0 ("cob_commit"));
5026 }
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_continue ( void  )

Definition at line 5031 of file typeck.c.

References cb_build_continue(), and cb_emit.

Referenced by yyparse().

5032 {
5034 }
cb_tree cb_build_continue(void)
Definition: tree.c:3214
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_corresponding ( cb_tree(*)(cb_tree f1, cb_tree f2, cb_tree f3 func,
cb_tree  x1,
cb_tree  x2,
cb_tree  opt 
)

Definition at line 4124 of file typeck.c.

References _, cb_check_group_name(), cb_validate_one(), cb_warning_x(), and emit_corresponding().

4126 {
4127  x1 = cb_check_group_name (x1);
4128  x2 = cb_check_group_name (x2);
4129 
4130  if (cb_validate_one (x1)) {
4131  return;
4132  }
4133  if (cb_validate_one (x2)) {
4134  return;
4135  }
4136 
4137  if (!emit_corresponding (func, x1, x2, opt)) {
4138  if (cb_warn_corresponding) {
4139  cb_warning_x (x2, _("No CORRESPONDING items found"));
4140  }
4141  }
4142 }
static cb_tree cb_check_group_name(cb_tree x)
Definition: typeck.c:592
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define _(s)
Definition: cobcrun.c:59
static unsigned int emit_corresponding(cb_tree(*func)(cb_tree f1, cb_tree f2, cb_tree f3), cb_tree x1, cb_tree x2, cb_tree opt)
Definition: typeck.c:4093

Here is the call graph for this function:

void cb_emit_delete ( cb_tree  file)

Definition at line 5039 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, cb_emit, cb_error_node, cb_error_x(), CB_FILE, cb_ref(), CB_TREE, COB_ORG_LINE_SEQUENTIAL, COB_ORG_SORT, current_program, current_statement, file, cb_statement::file, cb_file::file_status, cb_statement::flag_callback, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, and cb_file::organization.

Referenced by yyparse().

5040 {
5041  struct cb_file *f;
5042 
5043  if (file == cb_error_node) {
5044  return;
5045  }
5046  file = cb_ref (file);
5047  if (file == cb_error_node) {
5048  return;
5049  }
5051  f = CB_FILE (file);
5052 
5053  if (f->organization == COB_ORG_SORT) {
5055  _("%s not allowed on %s files"), "DELETE", "SORT");
5056  return;
5057  } else if (f->organization == COB_ORG_LINE_SEQUENTIAL) {
5059  _("%s not allowed on %s files"), "DELETE", "LINE SEQUENTIAL");
5060  return;
5061  }
5062 
5063  /* Check for file debugging */
5066  f->flag_fl_debug) {
5067  /* Gen callback after delete but before exception test */
5069  }
5070 
5071  cb_emit (CB_BUILD_FUNCALL_2 ("cob_delete", file,
5072  f->file_status));
5073 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree file
Definition: tree.h:1140
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
unsigned int flag_callback
Definition: tree.h:1152
#define COB_ORG_LINE_SEQUENTIAL
Definition: common.h:743
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_delete_file ( cb_tree  file)

Definition at line 5076 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, cb_emit, cb_error_node, cb_error_x(), CB_FILE, cb_ref(), CB_TREE, COB_ORG_SORT, current_program, current_statement, cb_file::file_status, cb_statement::flag_callback, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, and cb_file::organization.

Referenced by yyparse().

5077 {
5078  if (file == cb_error_node) {
5079  return;
5080  }
5081  file = cb_ref (file);
5082  if (file == cb_error_node) {
5083  return;
5084  }
5085  if (CB_FILE (file)->organization == COB_ORG_SORT) {
5087  _("%s not allowed on %s files"), "DELETE FILE", "SORT");
5088  return;
5089  }
5090 
5091  /* Check for file debugging */
5094  CB_FILE(file)->flag_fl_debug) {
5095  /* Gen callback after delete but before exception test */
5097  }
5098 
5099  cb_emit (CB_BUILD_FUNCALL_2 ("cob_delete_file", file,
5100  CB_FILE(file)->file_status));
5101 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_FILE(x)
Definition: tree.h:858
unsigned int flag_debugging
Definition: tree.h:1320
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_error_node
Definition: tree.c:140
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
unsigned int flag_callback
Definition: tree.h:1152
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_display ( cb_tree  values,
cb_tree  upon,
cb_tree  no_adv,
cb_tree  pos,
struct cb_attr_struct attr_ptr 
)

Definition at line 5236 of file typeck.c.

References _, CB_BUILD_FUNCALL_0, CB_BUILD_FUNCALL_3, CB_CHAIN, cb_emit, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_P, CB_FUNCALL, cb_list_length(), CB_LITERAL, CB_LITERAL_P, cb_low, cb_name(), cb_null, cb_ref(), CB_REF_OR_FIELD_P, CB_REFERENCE, cb_space, CB_STORAGE_SCREEN, CB_TAG_CONST, CB_TAG_INTEGER, CB_TAG_INTRINSIC, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TAG_STRING, CB_TREE_TAG, cb_validate_list(), CB_VALUE, COB_SCREEN_BELL, COB_SCREEN_ERASE_EOL, COB_SCREEN_ERASE_EOS, COB_SCREEN_NO_DISP, emit_field_display(), emit_screen_display(), gen_screen_ptr, initialize_attrs(), output_screen_from(), validate_attrs(), and value.

Referenced by emit_default_device_display(), emit_default_screen_display(), and yyparse().

5238 {
5239  cb_tree l;
5240  cb_tree x;
5241  cb_tree p;
5242  cb_tree fgc;
5243  cb_tree bgc;
5244  cb_tree scroll;
5245  cb_tree size_is; /* WITH SIZE IS */
5246  int dispattrs;
5247 
5248  if (cb_validate_list (values)) {
5249  return;
5250  }
5251 
5252  initialize_attrs (attr_ptr, &fgc, &bgc, &scroll, &size_is, &dispattrs);
5253  if (validate_attrs (pos, fgc, bgc, scroll, size_is)) {
5254  return;
5255  }
5256 
5257  for (l = values; l; l = CB_CHAIN (l)) {
5258  x = CB_VALUE (l);
5259  if (x == cb_error_node) {
5260  return;
5261  }
5262 
5263  switch (CB_TREE_TAG (x)) {
5264  case CB_TAG_LITERAL:
5265  case CB_TAG_INTRINSIC:
5266  case CB_TAG_CONST:
5267  case CB_TAG_STRING:
5268  case CB_TAG_INTEGER:
5269  break;
5270  case CB_TAG_REFERENCE:
5271  if (!CB_FIELD_P(CB_REFERENCE(x)->value)) {
5272  cb_error_x (x, _("'%s' is an invalid type for DISPLAY operand"), cb_name (x));
5273  return;
5274  }
5275  break;
5276  default:
5277  cb_error_x (x, _("Invalid type for DISPLAY operand"));
5278  return;
5279  }
5280  }
5281  if (upon == cb_error_node
5282  || !values /* <- silence warnings */) {
5283  return;
5284  }
5285 
5286 
5287  x = CB_VALUE (values);
5288  if ((CB_REF_OR_FIELD_P (x)) &&
5289  CB_FIELD (cb_ref (x))->storage == CB_STORAGE_SCREEN) {
5290  output_screen_from (CB_FIELD (cb_ref (x)), 0);
5291  gen_screen_ptr = 1;
5292  emit_screen_display (x, pos);
5293  gen_screen_ptr = 0;
5294  } else if (pos || fgc || bgc || scroll || size_is || dispattrs || upon == cb_null) {
5295  for (l = values; l; l = CB_CHAIN (l)) {
5296  x = CB_VALUE (l);
5297  /* low-values position cursor, size does not matter */
5298  if (x == cb_low) {
5299  dispattrs |= COB_SCREEN_NO_DISP;
5300  }
5301  /* no WITH SIZE then SPACE clears to end of screen */
5302  if (!(size_is)) {
5303  if (x == cb_space) {
5304  dispattrs |= COB_SCREEN_ERASE_EOS;
5305  dispattrs |= COB_SCREEN_NO_DISP;
5306  } else if (x == cb_low) {
5307  dispattrs |= COB_SCREEN_NO_DISP;
5308  } else if (CB_LITERAL_P (x) && CB_LITERAL (x)->all &&
5309  CB_LITERAL (x)->size == 1) {
5310  if (CB_LITERAL (x)->data[0] == 1) {
5311  dispattrs |= COB_SCREEN_ERASE_EOL;
5312  dispattrs |= COB_SCREEN_NO_DISP;
5313  } else if (CB_LITERAL (x)->data[0] == 2) {
5314  cb_emit (CB_BUILD_FUNCALL_0 ("cob_sys_clear_screen"));
5315  return;
5316  } else if (CB_LITERAL (x)->data[0] == 7) {
5317  dispattrs |= COB_SCREEN_BELL;
5318  dispattrs |= COB_SCREEN_NO_DISP;
5319  }
5320  }
5321  }
5322  emit_field_display (x, pos, fgc, bgc, scroll, size_is, dispattrs);
5323  }
5324  } else {
5325  /* DISPLAY x ... [UPON device-name] */
5326  p = CB_BUILD_FUNCALL_3 ("cob_display", upon, no_adv, values);
5327  CB_FUNCALL(p)->varcnt = cb_list_length (values);
5328  CB_FUNCALL(p)->nolitcast = 1;
5329  cb_emit (p);
5330  for (l = values; l; l = CB_CHAIN (l)) {
5331  x = CB_VALUE (l);
5332  if (CB_FIELD_P (x)) {
5333  CB_FIELD (cb_ref (x))->count++;
5334  }
5335  }
5336  }
5337 }
static int validate_attrs(cb_tree pos, cb_tree fgc, cb_tree bgc, cb_tree scroll, cb_tree size_is)
Definition: typeck.c:5142
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define COB_SCREEN_BELL
Definition: common.h:900
#define CB_LITERAL(x)
Definition: tree.h:601
static void emit_field_display(const cb_tree x, const cb_tree pos, const cb_tree fgc, const cb_tree bgc, const cb_tree scroll, const cb_tree size_is, const int dispattrs)
Definition: typeck.c:5202
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
cb_tree cb_space
Definition: tree.c:127
#define CB_FUNCALL(x)
Definition: tree.h:951
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
#define COB_SCREEN_ERASE_EOL
Definition: common.h:904
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int cb_list_length(cb_tree l)
Definition: tree.c:1342
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define CB_REFERENCE(x)
Definition: tree.h:901
static void output_screen_from(struct cb_field *p, const unsigned int sisters)
Definition: typeck.c:4199
cb_tree cb_error_node
Definition: tree.c:140
unsigned int gen_screen_ptr
Definition: tree.c:146
static void emit_screen_display(const cb_tree x, const cb_tree pos)
Definition: typeck.c:5192
#define COB_SCREEN_ERASE_EOS
Definition: common.h:905
cb_tree cb_null
Definition: tree.c:124
#define COB_SCREEN_NO_DISP
Definition: common.h:921
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
static void initialize_attrs(const struct cb_attr_struct *const attr_ptr, cb_tree *const fgc, cb_tree *const bgc, cb_tree *const scroll, cb_tree *const size_is, int *const dispattrs)
Definition: typeck.c:5152
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
cb_tree cb_low
Definition: tree.c:128
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_display_omitted ( cb_tree  pos,
struct cb_attr_struct attr_ptr 
)

Definition at line 5217 of file typeck.c.

References initialize_attrs(), and validate_attrs().

Referenced by yyparse().

5218 {
5219  cb_tree fgc;
5220  cb_tree bgc;
5221  cb_tree scroll;
5222  cb_tree size_is; /* WITH SIZE IS */
5223  int dispattrs;
5224 
5225  initialize_attrs (attr_ptr, &fgc, &bgc, &scroll, &size_is, &dispattrs);
5226  if (validate_attrs (pos, fgc, bgc, scroll, size_is)) {
5227  return;
5228  }
5229 
5230  /* TODO: Implement */
5231  /* Should we create a distinct omitted_display function in screenio.c? */
5232  /* emit_field_display (NULL, pos, fgc, bgc, scroll, size_is, dispattrs); */
5233 }
static int validate_attrs(cb_tree pos, cb_tree fgc, cb_tree bgc, cb_tree scroll, cb_tree size_is)
Definition: typeck.c:5142
static void initialize_attrs(const struct cb_attr_struct *const attr_ptr, cb_tree *const fgc, cb_tree *const bgc, cb_tree *const scroll, cb_tree *const size_is, int *const dispattrs)
Definition: typeck.c:5152

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_divide ( cb_tree  dividend,
cb_tree  divisor,
cb_tree  quotient,
cb_tree  remainder 
)

Definition at line 5399 of file typeck.c.

References build_store_option(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_4, cb_check_numeric_edited_name(), cb_emit, cb_int0, CB_PURPOSE, cb_validate_one(), and CB_VALUE.

Referenced by yyparse().

5401 {
5402  if (cb_validate_one (dividend)) {
5403  return;
5404  }
5405  if (cb_validate_one (divisor)) {
5406  return;
5407  }
5408  CB_VALUE (quotient) = cb_check_numeric_edited_name (CB_VALUE (quotient));
5409  CB_VALUE (remainder) = cb_check_numeric_edited_name (CB_VALUE (remainder));
5410 
5411  if (cb_validate_one (CB_VALUE (quotient))) {
5412  return;
5413  }
5414  if (cb_validate_one (CB_VALUE (remainder))) {
5415  return;
5416  }
5417 
5418  cb_emit (CB_BUILD_FUNCALL_4 ("cob_div_quotient", dividend, divisor,
5419  CB_VALUE (quotient),
5420  build_store_option (CB_VALUE (quotient),
5421  CB_PURPOSE (quotient))));
5422  cb_emit (CB_BUILD_FUNCALL_2 ("cob_div_remainder", CB_VALUE (remainder),
5423  build_store_option (CB_VALUE (remainder),
5424  cb_int0)));
5425 }
static cb_tree cb_check_numeric_edited_name(cb_tree x)
Definition: typeck.c:633
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
#define CB_PURPOSE(x)
Definition: tree.h:1192
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree cb_int0
Definition: tree.c:133
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_env_name ( cb_tree  value)

Definition at line 5106 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

5107 {
5108  if (cb_validate_one (value)) {
5109  return;
5110  }
5111  cb_emit (CB_BUILD_FUNCALL_1 ("cob_display_environment", value));
5112 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_env_value ( cb_tree  value)

Definition at line 5115 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_validate_one().

Referenced by yyparse().

5116 {
5117  if (cb_validate_one (value)) {
5118  return;
5119  }
5120  cb_emit (CB_BUILD_FUNCALL_1 ("cob_display_env_value", value));
5121 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_evaluate ( cb_tree  subject_list,
cb_tree  case_list 
)

Definition at line 5571 of file typeck.c.

References build_evaluate(), cb_build_comment(), cb_build_direct(), cb_emit, cb_id, CB_PREFIX_LABEL, and cobc_parse_strdup().

Referenced by yyparse().

5572 {
5573  cb_tree x;
5574  char sbuf[16];
5575 
5576  snprintf (sbuf, sizeof(sbuf), "goto %s%d;", CB_PREFIX_LABEL, cb_id);
5577  x = cb_build_direct (cobc_parse_strdup (sbuf), 0);
5578  build_evaluate (subject_list, case_list, x);
5579  snprintf (sbuf, sizeof(sbuf), "%s%d:;", CB_PREFIX_LABEL, cb_id);
5580  cb_emit (cb_build_comment ("End EVALUATE"));
5582  cb_id++;
5583 }
cb_tree cb_build_comment(const char *str)
Definition: tree.c:1540
#define CB_PREFIX_LABEL
Definition: tree.h:37
int cb_id
Definition: cobc.c:163
void * cobc_parse_strdup(const char *dupstr)
Definition: cobc.c:827
cb_tree cb_build_direct(const char *str, const unsigned int flagnl)
Definition: tree.c:1553
static void build_evaluate(cb_tree subject_list, cb_tree case_list, cb_tree labid)
Definition: typeck.c:5493
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_exit ( const unsigned int  goback)

Definition at line 5653 of file typeck.c.

References cb_build_goto(), cb_emit, cb_int1, and NULL.

Referenced by yyparse().

5654 {
5655  if (goback) {
5657  } else {
5659  }
5660 }
cb_tree cb_int1
Definition: tree.c:134
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_goto(const cb_tree target, const cb_tree depending)
Definition: tree.c:3118

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_free ( cb_tree  vars)

Definition at line 5588 of file typeck.c.

References _, CB_BUILD_CAST_ADDR_OF_ADDR, CB_BUILD_CAST_ADDRESS, CB_BUILD_FUNCALL_2, CB_CAST, CB_CAST_P, CB_CHAIN, CB_CLASS_POINTER, cb_emit, cb_error_x(), CB_FIELD_PTR, CB_REF_OR_FIELD_P, CB_TREE, CB_TREE_CLASS, cb_validate_list(), CB_VALUE, current_statement, cb_field::flag_item_based, and NULL.

Referenced by yyparse().

5589 {
5590  cb_tree l;
5591  struct cb_field *f;
5592  int i;
5593 
5594  if (cb_validate_list (vars)) {
5595  return;
5596  }
5597  for (l = vars, i = 1; l; l = CB_CHAIN (l), i++) {
5598  if (CB_TREE_CLASS (CB_VALUE (l)) == CB_CLASS_POINTER) {
5599  if (CB_CAST_P (CB_VALUE (l))) {
5600  f = CB_FIELD_PTR (CB_CAST (CB_VALUE(l))->val);
5601  if (!f->flag_item_based) {
5603  _("Target %d of FREE is not a BASED data item"), i);
5604  }
5605  cb_emit (CB_BUILD_FUNCALL_2 ("cob_free_alloc",
5607  } else {
5608  cb_emit (CB_BUILD_FUNCALL_2 ("cob_free_alloc",
5610  }
5611  } else if (CB_REF_OR_FIELD_P (CB_VALUE (l))) {
5612  f = CB_FIELD_PTR (CB_VALUE (l));
5613  if (!f->flag_item_based) {
5615  _("Target %d of FREE is not a BASED data item"), i);
5616  }
5617  cb_emit (CB_BUILD_FUNCALL_2 ("cob_free_alloc",
5619  } else {
5621  _("Target %d of FREE must be a data pointer"), i);
5622  }
5623  }
5624 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_CAST_P(x)
Definition: tree.h:963
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_CAST(x)
Definition: tree.h:962
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_BUILD_CAST_ADDR_OF_ADDR(x)
Definition: tree.h:1842
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
unsigned int flag_item_based
Definition: tree.h:713

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_get_environment ( cb_tree  envvar,
cb_tree  envval 
)

Definition at line 4575 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_emit, and cb_validate_one().

Referenced by yyparse().

4576 {
4577  if (cb_validate_one (envvar)) {
4578  return;
4579  }
4580  if (cb_validate_one (envval)) {
4581  return;
4582  }
4583  cb_emit (CB_BUILD_FUNCALL_2 ("cob_get_environment", envvar, envval));
4584 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_goto ( cb_tree  target,
cb_tree  depending 
)

Definition at line 5629 of file typeck.c.

References _, cb_build_goto(), CB_CHAIN, cb_check_data_incompat(), cb_check_numeric_value(), cb_emit, cb_error_node, cb_error_x(), CB_TREE, CB_VALUE, cb_verify(), current_statement, and NULL.

Referenced by yyparse().

5630 {
5631  if (target == cb_error_node) {
5632  return;
5633  }
5634  if (target == NULL) {
5635  cb_verify (cb_goto_statement_without_name, _("GO TO without procedure-name"));
5636  } else if (depending) {
5637  /* GO TO procedure-name ... DEPENDING ON identifier */
5638  if (cb_check_numeric_value (depending) == cb_error_node) {
5639  return;
5640  }
5641  cb_check_data_incompat (depending);
5642  cb_emit (cb_build_goto (target, depending));
5643  } else if (CB_CHAIN (target)) {
5645  _("GO TO with multiple procedure-names"));
5646  } else {
5647  /* GO TO procedure-name */
5648  cb_emit (cb_build_goto (CB_VALUE (target), NULL));
5649  }
5650 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
unsigned int cb_verify(const enum cb_support, const char *)
Definition: error.c:246
#define CB_VALUE(x)
Definition: tree.h:1193
static void cb_check_data_incompat(cb_tree x)
Definition: typeck.c:719
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_error_node
Definition: tree.c:140
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_check_numeric_value(cb_tree x)
Definition: typeck.c:651
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_build_goto(const cb_tree target, const cb_tree depending)
Definition: tree.c:3118

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_if ( cb_tree  cond,
cb_tree  stmt1,
cb_tree  stmt2 
)

Definition at line 5665 of file typeck.c.

References cb_build_if(), and cb_emit.

Referenced by yyparse().

5666 {
5667  cb_emit (cb_build_if (cond, stmt1, stmt2, 1));
5668 }
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_if(const cb_tree test, const cb_tree stmt1, const cb_tree stmt2, const unsigned int is_if)
Definition: tree.c:3132

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_initialize ( cb_tree  vars,
cb_tree  fillinit,
cb_tree  value,
cb_tree  replacing,
cb_tree  def 
)

Definition at line 5682 of file typeck.c.

References _, cb_build_initialize(), CB_CHAIN, cb_emit, cb_error_x(), CB_FIELD_P, CB_REFERENCE, CB_REFERENCE_P, CB_TREE, cb_true, cb_validate_list(), CB_VALUE, current_statement, and NULL.

Referenced by yyparse().

5684 {
5685  cb_tree l;
5686  unsigned int no_fill_init;
5687  unsigned int def_init;
5688  cb_tree x;
5689 
5690  if (cb_validate_list (vars)) {
5691  return;
5692  }
5693  if (value == NULL && replacing == NULL) {
5694  def = cb_true;
5695  }
5696  no_fill_init = (fillinit == NULL);
5697  def_init = (def != NULL);
5698  for (l = vars; l; l = CB_CHAIN (l)) {
5699  x = CB_VALUE (l);
5700  if (!(CB_REFERENCE_P (x) && CB_FIELD_P (CB_REFERENCE (x)->value)) &&
5701  !CB_FIELD_P (x)) {
5702  cb_error_x (CB_TREE (current_statement), _("Invalid INITIALIZE statement"));
5703  return;
5704  }
5705 
5706  cb_emit (cb_build_initialize (x , value, replacing,
5707  def_init, 1, no_fill_init));
5708  }
5709 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_true
Definition: tree.c:122
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_build_initialize(const cb_tree var, const cb_tree val, const cb_tree rep, const unsigned int def, const unsigned int is_statement, const unsigned int no_filler_init)
Definition: tree.c:3028
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_inspect ( cb_tree  var,
cb_tree  body,
cb_tree  replacing,
const unsigned int  replconv 
)

Definition at line 5805 of file typeck.c.

References _, CB_BUILD_FUNCALL_0, CB_BUILD_FUNCALL_2, CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_NATIONAL, cb_emit, cb_emit_list, cb_error_x(), CB_TAG_INTRINSIC, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE, CB_TREE_CATEGORY, CB_TREE_TAG, and current_statement.

Referenced by yyparse().

5807 {
5808  switch (CB_TREE_TAG(var)) {
5809  case CB_TAG_REFERENCE:
5810  break;
5811  case CB_TAG_INTRINSIC:
5812  if (replconv) {
5813  goto rep_error;
5814  }
5815  switch (CB_TREE_CATEGORY(var)) {
5818  case CB_CATEGORY_NATIONAL:
5819  break;
5820  default:
5822  _("Invalid target for %s"), "CONVERTING");
5823  return;
5824  }
5825  break;
5826  case CB_TAG_LITERAL:
5827  if (replconv) {
5828  goto rep_error;
5829  }
5830  break;
5831  default:
5832  goto rep_error;
5833  }
5834  cb_emit (CB_BUILD_FUNCALL_2 ("cob_inspect_init", var, replacing));
5835  cb_emit_list (body);
5836  cb_emit (CB_BUILD_FUNCALL_0 ("cob_inspect_finish"));
5837  return;
5838 rep_error:
5839  if (replconv == 1) {
5841  _("Invalid target for %s"), "REPLACING");
5842  } else {
5844  _("Invalid target for %s"), "CONVERTING");
5845  }
5846 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
#define cb_emit_list(l)
Definition: typeck.c:77
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_move ( cb_tree  src,
cb_tree  dsts 
)

Definition at line 7416 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, cb_build_move(), CB_CHAIN, cb_check_data_incompat(), CB_CONST_P, cb_emit, cb_error_x(), CB_INTRINSIC_P, cb_list_length(), CB_LITERAL_P, cb_name(), CB_REFERENCE, CB_REFERENCE_P, CB_TREE, cb_validate_list(), cb_validate_one(), CB_VALUE, current_statement, cb_reference::offset, and cb_reference::subs.

Referenced by yyparse().

7417 {
7418  cb_tree l;
7419  cb_tree x;
7420  cb_tree m;
7421  unsigned int tempval;
7422 
7423  if (cb_validate_one (src)) {
7424  return;
7425  }
7426  if (cb_validate_list (dsts)) {
7427  return;
7428  }
7429 
7430  cb_check_data_incompat (src);
7431 
7432  tempval = 0;
7433  if (cb_list_length (dsts) > 1) {
7434  if (CB_INTRINSIC_P (src) || (CB_REFERENCE_P (src) &&
7435  (CB_REFERENCE (src)->subs || CB_REFERENCE (src)->offset))) {
7436  tempval = 1;
7437  cb_emit (CB_BUILD_FUNCALL_1 ("cob_put_indirect_field",
7438  src));
7439  }
7440  }
7441 
7442  for (l = dsts; l; l = CB_CHAIN (l)) {
7443  x = CB_VALUE (l);
7444  if (CB_LITERAL_P (x) || CB_CONST_P (x)) {
7446  _("Invalid MOVE target - %s"), cb_name (x));
7447  continue;
7448  }
7449  if (!tempval) {
7450  m = cb_build_move (src, x);
7451  } else {
7452  m = CB_BUILD_FUNCALL_1 ("cob_get_indirect_field", x);
7453  }
7454  cb_emit (m);
7455  }
7456 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_CONST_P(x)
Definition: tree.h:477
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
int cb_list_length(cb_tree l)
Definition: tree.c:1342
int offset
Definition: tree.h:675
static void cb_check_data_incompat(cb_tree x)
Definition: typeck.c:719
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_REFERENCE(x)
Definition: tree.h:901
#define CB_INTRINSIC_P(x)
Definition: tree.h:1002
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_move_corresponding ( cb_tree  x1,
cb_tree  x2 
)

Definition at line 4175 of file typeck.c.

References _, CB_CHAIN, cb_check_group_name(), cb_validate_one(), CB_VALUE, cb_warning_x(), and emit_move_corresponding().

Referenced by yyparse().

4176 {
4177  cb_tree l;
4178  cb_tree v;
4179 
4180  x1 = cb_check_group_name (x1);
4181  if (cb_validate_one (x1)) {
4182  return;
4183  }
4184  for (l = x2; l; l = CB_CHAIN(l)) {
4185  v = CB_VALUE(l);
4186  v = cb_check_group_name (v);
4187  if (cb_validate_one (v)) {
4188  return;
4189  }
4190  if (!emit_move_corresponding (x1, v)) {
4191  if (cb_warn_corresponding) {
4192  cb_warning_x (v, _("No CORRESPONDING items found"));
4193  }
4194  }
4195  }
4196 }
static cb_tree cb_check_group_name(cb_tree x)
Definition: typeck.c:592
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
static unsigned int emit_move_corresponding(cb_tree x1, cb_tree x2)
Definition: typeck.c:4145
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_VALUE(x)
Definition: tree.h:1193
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_open ( cb_tree  file,
cb_tree  mode,
cb_tree  sharing 
)

Definition at line 7461 of file typeck.c.

References _, cb_build_debug(), cb_build_debug_call(), CB_BUILD_FUNCALL_4, cb_build_move(), cb_emit, cb_error_node, cb_error_x(), CB_FILE, cb_int(), cb_int0, cb_ref(), cb_space, CB_TREE, COB_OPEN_I_O, COB_ORG_LINE_SEQUENTIAL, COB_ORG_SORT, current_program, current_statement, cb_file::debug_section, file, cb_statement::file, cb_file::file_status, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, cb_file::name, NULL, cb_file::organization, and cb_file::sharing.

Referenced by yyparse().

7462 {
7463  struct cb_file *f;
7464 
7465  if (file == cb_error_node) {
7466  return;
7467  }
7468  file = cb_ref (file);
7469  if (file == cb_error_node) {
7470  return;
7471  }
7473  f = CB_FILE (file);
7474 
7475  if (f->organization == COB_ORG_SORT) {
7477  _("%s not allowed on %s files"), "OPEN", "SORT");
7478  return;
7479  } else if (f->organization == COB_ORG_LINE_SEQUENTIAL &&
7480  mode == cb_int (COB_OPEN_I_O)) {
7482  _("%s not allowed on %s files"), "OPEN I-O", "LINE SEQUENTIAL");
7483  return;
7484  }
7485  if (sharing == NULL) {
7486  if (f->sharing) {
7487  sharing = f->sharing;
7488  } else {
7489  sharing = cb_int0;
7490  }
7491  }
7492 
7493  cb_emit (CB_BUILD_FUNCALL_4 ("cob_open", file, mode,
7494  sharing, f->file_status));
7495 
7496  /* Check for file debugging */
7499  f->flag_fl_debug) {
7503  }
7504 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_debug_name
Definition: typeck.c:84
const char * name
Definition: tree.h:820
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
cb_tree cb_space
Definition: tree.c:127
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
struct cb_label * debug_section
Definition: tree.h:839
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int0
Definition: tree.c:133
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree cb_int(const int n)
Definition: tree.c:1488
cb_tree file
Definition: tree.h:1140
cb_tree sharing
Definition: tree.h:825
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
#define COB_OPEN_I_O
Definition: common.h:786
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
cb_tree cb_debug_contents
Definition: typeck.c:88
#define COB_ORG_LINE_SEQUENTIAL
Definition: common.h:743
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_perform ( cb_tree  perform,
cb_tree  body 
)

Definition at line 7509 of file typeck.c.

References cb_build_debug(), cb_emit, cb_error_node, CB_PAIR_P, CB_PERFORM, current_program, current_statement, cb_program::flag_debugging, cb_statement::flag_in_debug, and NULL.

Referenced by yyparse().

7510 {
7511  if (perform == cb_error_node) {
7512  return;
7513  }
7516  cb_emit (cb_build_debug (cb_debug_contents, "PERFORM LOOP", NULL));
7517  }
7518  CB_PERFORM (perform)->body = body;
7519  cb_emit (perform);
7520 }
#define CB_PAIR_P(x)
Definition: tree.h:1204
unsigned int flag_debugging
Definition: tree.h:1320
#define CB_PERFORM(x)
Definition: tree.h:1118
unsigned int flag_in_debug
Definition: tree.h:1150
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_error_node
Definition: tree.c:140
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_debug_contents
Definition: typeck.c:88
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_read ( cb_tree  ref,
cb_tree  next,
cb_tree  into,
cb_tree  key,
cb_tree  lock_opts 
)

Definition at line 7586 of file typeck.c.

References _, cb_file::access_mode, cb_build_debug(), cb_build_debug_call(), cb_build_field_reference(), CB_BUILD_FUNCALL_3, CB_BUILD_FUNCALL_4, cb_build_move(), cb_emit, cb_error_node, cb_error_x(), CB_FILE, cb_int(), cb_int1, cb_int2, cb_int3, cb_int4, cb_list_add(), CB_LIST_INIT, cb_ref(), CB_TREE, cb_warning(), COB_ACCESS_DYNAMIC, COB_ACCESS_SEQUENTIAL, COB_EC_I_O_AT_END, COB_ORG_INDEXED, COB_ORG_RELATIVE, COB_ORG_SORT, COB_READ_IGNORE_LOCK, COB_READ_LOCK, COB_READ_NEXT, COB_READ_NO_LOCK, COB_READ_PREVIOUS, COB_READ_WAIT_LOCK, current_program, current_statement, cb_file::debug_section, file, cb_statement::file, cb_file::file_status, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, cb_statement::handler3, cb_statement::handler_id, cb_file::key, cb_file::name, NULL, cb_file::organization, and cb_file::record.

Referenced by yyparse().

7588 {
7589  cb_tree file;
7590  cb_tree rec;
7591  cb_tree x;
7592  struct cb_file *f;
7593  int read_opts;
7594 
7595  read_opts = 0;
7596  if (lock_opts == cb_int1) {
7597  read_opts = COB_READ_LOCK;
7598  } else if (lock_opts == cb_int2) {
7599  read_opts = COB_READ_NO_LOCK;
7600  } else if (lock_opts == cb_int3) {
7601  read_opts = COB_READ_IGNORE_LOCK;
7602  } else if (lock_opts == cb_int4) {
7603  read_opts = COB_READ_WAIT_LOCK;
7604  }
7605  if (ref == cb_error_node) {
7606  return;
7607  }
7608  file = cb_ref (ref);
7609  if (file == cb_error_node) {
7610  return;
7611  }
7612  f = CB_FILE (file);
7613 
7614  rec = cb_build_field_reference (f->record, ref);
7615  if (f->organization == COB_ORG_SORT) {
7617  _("%s not allowed on %s files"), "READ", "SORT");
7618  return;
7619  }
7620  if (next == cb_int1 || next == cb_int2 ||
7622  /* READ NEXT/PREVIOUS */
7623  if (next == cb_int2) {
7624  switch (f->organization) {
7625  case COB_ORG_INDEXED:
7626  case COB_ORG_RELATIVE:
7627  break;
7628  default:
7630  _("READ PREVIOUS not allowed for this file type"));
7631  return;
7632  }
7633  read_opts |= COB_READ_PREVIOUS;
7634  } else {
7635  read_opts |= COB_READ_NEXT;
7636  }
7637  if (key) {
7638  cb_warning (_("KEY ignored with sequential READ"));
7639  }
7640  cb_emit (CB_BUILD_FUNCALL_3 ("cob_read_next", file,
7641  f->file_status,
7642  cb_int (read_opts)));
7643  } else {
7644  /* READ */
7645  /* DYNAMIC with [NOT] AT END */
7646  if (f->access_mode == COB_ACCESS_DYNAMIC &&
7648  read_opts |= COB_READ_NEXT;
7649  cb_emit (CB_BUILD_FUNCALL_3 ("cob_read_next", file,
7650  f->file_status,
7651  cb_int (read_opts)));
7652  } else if (key || f->key) {
7653  cb_emit (CB_BUILD_FUNCALL_4 ("cob_read",
7654  file, key ? key : f->key,
7655  f->file_status, cb_int (read_opts)));
7656  } else {
7657  cb_emit (CB_BUILD_FUNCALL_3 ("cob_read_next", file,
7658  f->file_status,
7659  cb_int (read_opts)));
7660  }
7661  }
7662  if (into) {
7663  current_statement->handler3 = cb_build_move (rec, into);
7664  }
7665 
7666  /* Check for file debugging */
7669  f->flag_fl_debug) {
7670  if (into) {
7673  }
7677  x = cb_build_move (rec, cb_debug_contents);
7683  }
7685 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_int1
Definition: tree.c:134
cb_tree cb_debug_name
Definition: typeck.c:84
const char * name
Definition: tree.h:820
#define COB_READ_NO_LOCK
Definition: common.h:818
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_ORG_INDEXED
Definition: common.h:745
int handler_id
Definition: tree.h:1148
#define COB_READ_PREVIOUS
Definition: common.h:814
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
struct cb_label * debug_section
Definition: tree.h:839
#define COB_ACCESS_DYNAMIC
Definition: common.h:752
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
#define COB_READ_WAIT_LOCK
Definition: common.h:820
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int4
Definition: tree.c:137
#define COB_ORG_RELATIVE
Definition: common.h:744
cb_tree cb_int3
Definition: tree.c:136
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree cb_int(const int n)
Definition: tree.c:1488
cb_tree file
Definition: tree.h:1140
#define COB_ACCESS_SEQUENTIAL
Definition: common.h:751
Definition: tree.h:818
#define COB_READ_IGNORE_LOCK
Definition: common.h:821
cb_tree cb_error_node
Definition: tree.c:140
int access_mode
Definition: tree.h:845
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
struct cb_field * record
Definition: tree.h:829
int organization
Definition: tree.h:844
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
#define CB_LIST_INIT(x)
Definition: tree.h:1851
#define COB_ORG_SORT
Definition: common.h:746
cb_tree cb_debug_contents
Definition: typeck.c:88
cb_tree handler3
Definition: tree.h:1143
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
#define COB_READ_NEXT
Definition: common.h:813
cb_tree key
Definition: tree.h:826
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_int2
Definition: tree.c:135
#define COB_READ_LOCK
Definition: common.h:817
cb_tree cb_list_add(cb_tree l, cb_tree x)
Definition: tree.c:1315

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_ready_trace ( void  )

Definition at line 7690 of file typeck.c.

References CB_BUILD_FUNCALL_0, and cb_emit.

Referenced by yyparse().

7691 {
7692  cb_emit (CB_BUILD_FUNCALL_0 ("cob_ready_trace"));
7693 }
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_release ( cb_tree  record,
cb_tree  from 
)

Definition at line 7780 of file typeck.c.

References _, CB_BUILD_FUNCALL_1, cb_build_move(), cb_emit, cb_error_x(), CB_FIELD_PTR, CB_FILE, cb_ref(), CB_REF_OR_FIELD_P, CB_STORAGE_FILE, CB_TREE, cb_validate_one(), COB_ORG_SORT, current_statement, file, cb_field::file, cb_statement::file, and cb_field::storage.

Referenced by yyparse().

7781 {
7782  struct cb_field *f;
7783  cb_tree file;
7784 
7785  if (cb_validate_one (record)) {
7786  return;
7787  }
7788  if (cb_validate_one (from)) {
7789  return;
7790  }
7791  if (!CB_REF_OR_FIELD_P (cb_ref (record))) {
7793  _("%s requires a record name as subject"), "RELEASE");
7794  return;
7795  }
7796  f = CB_FIELD_PTR (record);
7797  if (f->storage != CB_STORAGE_FILE) {
7799  _("%s subject does not refer to a record name"), "RELEASE");
7800  return;
7801  }
7802  file = CB_TREE (f->file);
7803  if (CB_FILE (file)->organization != COB_ORG_SORT) {
7805  _("RELEASE not allowed on this record item"));
7806  return;
7807  }
7809  if (from) {
7810  cb_emit (cb_build_move (from, record));
7811  }
7812  cb_emit (CB_BUILD_FUNCALL_1 ("cob_file_release", file));
7813 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
struct cb_file * file
Definition: tree.h:657
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
cb_tree file
Definition: tree.h:1140
#define COB_ORG_SORT
Definition: common.h:746
#define cb_emit(x)
Definition: typeck.c:75
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_reset_trace ( void  )

Definition at line 7699 of file typeck.c.

References CB_BUILD_FUNCALL_0, and cb_emit.

Referenced by yyparse().

7700 {
7701  cb_emit (CB_BUILD_FUNCALL_0 ("cob_reset_trace"));
7702 }
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_return ( cb_tree  ref,
cb_tree  into 
)

Definition at line 7818 of file typeck.c.

References cb_build_field_reference(), CB_BUILD_FUNCALL_1, cb_build_move(), cb_emit, cb_error_node, CB_FILE, cb_ref(), cb_validate_one(), current_statement, file, cb_statement::file, and cb_statement::handler3.

Referenced by yyparse().

7819 {
7820  cb_tree file;
7821  cb_tree rec;
7822 
7823  if (cb_validate_one (ref)) {
7824  return;
7825  }
7826  if (cb_validate_one (into)) {
7827  return;
7828  }
7829  file = cb_ref (ref);
7830  if (file == cb_error_node) {
7831  return;
7832  }
7833  rec = cb_build_field_reference (CB_FILE (file)->record, ref);
7834  cb_emit (CB_BUILD_FUNCALL_1 ("cob_file_return", file));
7835  if (into) {
7836  current_statement->handler3 = cb_build_move (rec, into);
7837  }
7839 }
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
cb_tree file
Definition: tree.h:1140
cb_tree cb_error_node
Definition: tree.c:140
cb_tree handler3
Definition: tree.h:1143
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_rewrite ( cb_tree  record,
cb_tree  from,
cb_tree  lockopt 
)

Definition at line 7707 of file typeck.c.

References _, cb_build_debug(), cb_build_debug_call(), CB_BUILD_FUNCALL_4, cb_build_move(), cb_emit, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_PTR, CB_FILE, cb_int(), cb_int1, cb_ref(), CB_REF_OR_FIELD_P, CB_STORAGE_FILE, CB_TREE, cb_validate_one(), COB_EC_I_O_INVALID_KEY, COB_LOCK_AUTOMATIC, COB_ORG_INDEXED, COB_ORG_LINE_SEQUENTIAL, COB_ORG_RELATIVE, COB_ORG_SORT, COB_WRITE_LOCK, current_program, current_statement, cb_file::debug_section, file, cb_statement::file, cb_file::file_status, cb_program::flag_debugging, cb_statement::flag_in_debug, cb_statement::handler_id, cb_file::lock_mode, cb_file::name, NULL, and cb_file::organization.

Referenced by yyparse().

7708 {
7709  cb_tree file;
7710  struct cb_file *f;
7711  int opts;
7712 
7713  if (cb_validate_one (record)) {
7714  return;
7715  }
7716  if (cb_validate_one (from)) {
7717  return;
7718  }
7719  if (!CB_REF_OR_FIELD_P (cb_ref (record))) {
7721  _("%s requires a record name as subject"), "REWRITE");
7722  return;
7723  }
7724  if (CB_FIELD_PTR (record)->storage != CB_STORAGE_FILE) {
7726  _("%s subject does not refer to a record name"), "REWRITE");
7727  return;
7728  }
7729 
7730  file = CB_TREE (CB_FIELD (cb_ref (record))->file);
7731  if (!file || file == cb_error_node) {
7732  return;
7733  }
7735  f = CB_FILE (file);
7736  opts = 0;
7737 
7738  if (f->organization == COB_ORG_SORT) {
7740  _("%s not allowed on %s files"), "REWRITE", "SORT");
7741  return;
7742  } else if (f->organization == COB_ORG_LINE_SEQUENTIAL) {
7744  _("%s not allowed on %s files"), "REWRITE", "LINE SEQUENTIAL");
7745  return;
7747  (f->organization != COB_ORG_RELATIVE &&
7748  f->organization != COB_ORG_INDEXED)) {
7750  _("INVALID KEY clause invalid with this file type"));
7751  return;
7752  } else if ((f->lock_mode & COB_LOCK_AUTOMATIC) && lockopt) {
7754  _("LOCK clause invalid with file LOCK AUTOMATIC"));
7755  return;
7756  } else if (lockopt == cb_int1) {
7757  opts = COB_WRITE_LOCK;
7758  }
7759 
7760  if (from) {
7761  cb_emit (cb_build_move (from, record));
7762  }
7763 
7764  /* Check debugging on record name */
7767  CB_FIELD_PTR (record)->flag_field_debug) {
7769  CB_FIELD_PTR (record)->name, NULL));
7772  }
7773  cb_emit (CB_BUILD_FUNCALL_4 ("cob_rewrite", file, record,
7774  cb_int (opts), f->file_status));
7775 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_int1
Definition: tree.c:134
cb_tree cb_debug_name
Definition: typeck.c:84
const char * name
Definition: tree.h:820
#define COB_LOCK_AUTOMATIC
Definition: common.h:775
int lock_mode
Definition: tree.h:846
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_ORG_INDEXED
Definition: common.h:745
int handler_id
Definition: tree.h:1148
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
struct cb_label * debug_section
Definition: tree.h:839
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define COB_ORG_RELATIVE
Definition: common.h:744
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree cb_int(const int n)
Definition: tree.c:1488
cb_tree file
Definition: tree.h:1140
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
cb_tree file_status
Definition: tree.h:824
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
cb_tree cb_debug_contents
Definition: typeck.c:88
#define COB_ORG_LINE_SEQUENTIAL
Definition: common.h:743
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
#define COB_WRITE_LOCK
Definition: common.h:808
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_rollback ( void  )

Definition at line 7844 of file typeck.c.

References CB_BUILD_FUNCALL_0, and cb_emit.

Referenced by yyparse().

7845 {
7846  cb_emit (CB_BUILD_FUNCALL_0 ("cob_rollback"));
7847 }
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_search ( cb_tree  table,
cb_tree  varying,
cb_tree  at_end,
cb_tree  whens 
)

Definition at line 7965 of file typeck.c.

References cb_build_search(), cb_check_needs_break(), cb_emit, cb_error_node, cb_list_reverse(), and cb_validate_one().

Referenced by yyparse().

7966 {
7967  if (cb_validate_one (table)) {
7968  return;
7969  }
7970  if (cb_validate_one (varying)) {
7971  return;
7972  }
7973  if (table == cb_error_node) {
7974  return;
7975  }
7976  if (whens == cb_error_node) {
7977  return;
7978  }
7979  whens = cb_list_reverse (whens);
7980  cb_emit (cb_build_search (0, table, varying,
7981  cb_check_needs_break (at_end), whens));
7982 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_build_search(const int flag_all, const cb_tree table, const cb_tree var, const cb_tree end_stmt, const cb_tree whens)
Definition: tree.c:3049
static cb_tree cb_check_needs_break(cb_tree stmt)
Definition: typeck.c:523
cb_tree cb_error_node
Definition: tree.c:140
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_search_all ( cb_tree  table,
cb_tree  at_end,
cb_tree  when,
cb_tree  stmts 
)

Definition at line 7985 of file typeck.c.

References cb_build_if(), cb_build_search(), cb_build_search_all(), cb_check_needs_break(), cb_emit, cb_error_node, cb_validate_one(), and NULL.

Referenced by yyparse().

7986 {
7987  cb_tree x;
7988  cb_tree stmt_lis;
7989 
7990  if (cb_validate_one (table)) {
7991  return;
7992  }
7993  if (table == cb_error_node) {
7994  return;
7995  }
7996  if (when == cb_error_node) {
7997  return;
7998  }
7999  x = cb_build_search_all (table, when);
8000  if (!x) {
8001  return;
8002  }
8003 
8004  stmt_lis = cb_check_needs_break (stmts);
8005  cb_emit (cb_build_search (1, table, NULL,
8006  cb_check_needs_break (at_end),
8007  cb_build_if (x, stmt_lis, NULL, 0)));
8008 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_build_search(const int flag_all, const cb_tree table, const cb_tree var, const cb_tree end_stmt, const cb_tree whens)
Definition: tree.c:3049
static cb_tree cb_check_needs_break(cb_tree stmt)
Definition: typeck.c:523
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_error_node
Definition: tree.c:140
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_if(const cb_tree test, const cb_tree stmt1, const cb_tree stmt2, const unsigned int is_if)
Definition: tree.c:3132
static cb_tree cb_build_search_all(cb_tree table, cb_tree cond)
Definition: typeck.c:7923

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_attribute ( cb_tree  x,
const int  val_on,
const int  val_off 
)

Definition at line 8207 of file typeck.c.

References _, cb_build_set_attribute(), cb_emit, cb_error_x(), CB_FIELD_PTR, cb_ref(), CB_REF_OR_FIELD_P, CB_STORAGE_SCREEN, CB_TREE, cb_validate_one(), current_statement, and cb_field::storage.

Referenced by yyparse().

8208 {
8209  struct cb_field *f;
8210 
8211  if (cb_validate_one (x)) {
8212  return;
8213  }
8214  if (!CB_REF_OR_FIELD_P (cb_ref (x))) {
8216  _("SET ATTRIBUTE requires a screen item as subject"));
8217  return;
8218  }
8219  f = CB_FIELD_PTR (x);
8220  if (f->storage != CB_STORAGE_SCREEN) {
8222  _("SET ATTRIBUTE subject does not refer to a screen item"));
8223  return;
8224  }
8225  cb_emit (cb_build_set_attribute (f, val_on, val_off));
8226 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
cb_tree cb_build_set_attribute(const struct cb_field *fld, const int val_on, const int val_off)
Definition: tree.c:3226
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define cb_emit(x)
Definition: typeck.c:75
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
enum cb_storage storage
Definition: tree.h:692

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_false ( cb_tree  l)

Definition at line 8171 of file typeck.c.

References _, cb_build_field_reference(), cb_build_move(), CB_CHAIN, cb_emit, cb_error_node, cb_error_x(), CB_FIELD_P, CB_FIELD_PTR, CB_PAIR_P, CB_PAIR_X, CB_REFERENCE, CB_REFERENCE_P, CB_VALUE, cb_field::false_88, cb_field::level, cb_field::parent, and value.

Referenced by yyparse().

8172 {
8173  cb_tree x;
8174  struct cb_field *f;
8175  cb_tree ref;
8176  cb_tree val;
8177 
8178  for (; l; l = CB_CHAIN (l)) {
8179  x = CB_VALUE (l);
8180  if (x == cb_error_node) {
8181  return;
8182  }
8183  if (!(CB_REFERENCE_P (x) && CB_FIELD_P(CB_REFERENCE(x)->value)) &&
8184  !CB_FIELD_P (x)) {
8185  cb_error_x (x, _("Invalid SET statement"));
8186  return;
8187  }
8188  f = CB_FIELD_PTR (x);
8189  if (f->level != 88) {
8190  cb_error_x (x, _("Invalid SET statement"));
8191  return;
8192  }
8193  if (!f->false_88) {
8194  cb_error_x (x, _("Field does not have FALSE clause"));
8195  return;
8196  }
8197  ref = cb_build_field_reference (f->parent, x);
8198  val = CB_VALUE (f->false_88);
8199  if (CB_PAIR_P (val)) {
8200  val = CB_PAIR_X (val);
8201  }
8202  cb_emit (cb_build_move (val, ref));
8203  }
8204 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_PAIR_P(x)
Definition: tree.h:1204
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
int level
Definition: tree.h:673
#define CB_VALUE(x)
Definition: tree.h:1193
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
struct cb_field * parent
Definition: tree.h:651
#define cb_emit(x)
Definition: typeck.c:75
cb_tree false_88
Definition: tree.h:649

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_last_exception_to_off ( void  )

Definition at line 8229 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, and cb_int0.

Referenced by yyparse().

8230 {
8231  cb_emit (CB_BUILD_FUNCALL_1 ("cob_set_exception", cb_int0));
8232 }
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
cb_tree cb_int0
Definition: tree.c:133
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_set_on_off ( cb_tree  l,
cb_tree  flag 
)

Definition at line 8124 of file typeck.c.

References CB_BUILD_FUNCALL_2, CB_CHAIN, cb_emit, cb_int(), cb_ref(), CB_SYSTEM_NAME, cb_validate_list(), CB_VALUE, and cb_system_name::token.

Referenced by yyparse().

8125 {
8126  struct cb_system_name *s;
8127 
8128  if (cb_validate_list (l)) {
8129  return;
8130  }
8131  for (; l; l = CB_CHAIN (l)) {
8132  s = CB_SYSTEM_NAME (cb_ref (CB_VALUE (l)));
8133  cb_emit (CB_BUILD_FUNCALL_2 ("cob_set_switch",
8134  cb_int (s->token), flag));
8135  }
8136 }
#define CB_SYSTEM_NAME(x)
Definition: tree.h:586
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
cb_tree cb_int(const int n)
Definition: tree.c:1488
int token
Definition: tree.h:583
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_to ( cb_tree  vars,
cb_tree  x 
)

Definition at line 8019 of file typeck.c.

References _, cb_cast::cast_type, cb_build_move(), CB_CAST, CB_CAST_ADDRESS, CB_CAST_P, CB_CAST_PROGRAM_POINTER, CB_CHAIN, cb_check_data_incompat(), CB_CLASS_INDEX, CB_CLASS_NUMERIC, CB_CLASS_POINTER, CB_CLASS_UNKNOWN, cb_emit, cb_error_node, cb_error_x(), CB_FIELD, cb_name(), cb_ref(), CB_REFERENCE_P, CB_STORAGE_LINKAGE, CB_TREE, CB_TREE_CLASS, cb_tree_class(), CB_USAGE_PROGRAM_POINTER, cb_validate_list(), cb_validate_one(), CB_VALUE, current_statement, and cb_cast::val.

Referenced by yyparse().

8020 {
8021  cb_tree l;
8022  cb_tree v;
8023  struct cb_cast *p;
8024  enum cb_class class;
8025 
8026  if (cb_validate_one (x)) {
8027  return;
8028  }
8029  if (cb_validate_list (vars)) {
8030  return;
8031  }
8032 
8033 #if 0 /* RXWRXW - target check */
8034  /* Determine class of targets */
8035  for (l = vars; l; l = CB_CHAIN (l)) {
8036  if (CB_TREE_CLASS (CB_VALUE (l)) != CB_CLASS_UNKNOWN) {
8037  if (class == CB_CLASS_UNKNOWN) {
8038  class = CB_TREE_CLASS (CB_VALUE (l));
8039  } else if (class != CB_TREE_CLASS (CB_VALUE (l))) {
8040  break;
8041  }
8042  }
8043  }
8044  if (l || (class != CB_CLASS_INDEX && class != CB_CLASS_POINTER)) {
8046  _("The targets of SET must be either indexes or pointers"));
8047  return;
8048  }
8049 #endif
8050 
8051  if (CB_CAST_P (x)) {
8052  p = CB_CAST (x);
8053  if (p->cast_type == CB_CAST_PROGRAM_POINTER) {
8054  for (l = vars; l; l = CB_CHAIN (l)) {
8055  v = CB_VALUE (l);
8056  if (!CB_REFERENCE_P (v)) {
8058  _("SET targets must be PROGRAM-POINTER"));
8059  CB_VALUE (l) = cb_error_node;
8060  } else if (CB_FIELD(cb_ref(v))->usage != CB_USAGE_PROGRAM_POINTER) {
8062  _("SET targets must be PROGRAM-POINTER"));
8063  CB_VALUE (l) = cb_error_node;
8064  }
8065  }
8066  }
8067  }
8068  /* Validate the targets */
8069  for (l = vars; l; l = CB_CHAIN (l)) {
8070  v = CB_VALUE (l);
8071  if (!CB_CAST_P (v)) {
8072  continue;
8073  }
8074  p = CB_CAST (v);
8075  if (p->cast_type == CB_CAST_ADDRESS &&
8076  !CB_FIELD (cb_ref (p->val))->flag_item_based &&
8077  CB_FIELD (cb_ref (p->val))->storage != CB_STORAGE_LINKAGE) {
8078  cb_error_x (p->val, _("The address of '%s' cannot be changed"),
8079  cb_name (p->val));
8080  CB_VALUE (l) = cb_error_node;
8081  }
8082  }
8083  if (cb_validate_list (vars)) {
8084  return;
8085  }
8086 
8087  for (l = vars; l; l = CB_CHAIN (l)) {
8088  class = cb_tree_class (CB_VALUE (l));
8089  switch (class) {
8090  case CB_CLASS_INDEX:
8091  case CB_CLASS_NUMERIC:
8092  case CB_CLASS_POINTER:
8094  cb_emit (cb_build_move (x, CB_VALUE (l)));
8095  break;
8096  default:
8098  _("SET target is invalid - '%s'"),
8099  cb_name (CB_VALUE(l)));
8100  break;
8101  }
8102  }
8103 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_CAST_P(x)
Definition: tree.h:963
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_CAST(x)
Definition: tree.h:962
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_TREE_CLASS(x)
Definition: tree.h:442
static void cb_check_data_incompat(cb_tree x)
Definition: typeck.c:719
#define _(s)
Definition: cobcrun.c:59
#define CB_CHAIN(x)
Definition: tree.h:1194
cb_class
Definition: tree.h:213
Definition: tree.h:956
cb_tree cb_error_node
Definition: tree.c:140
enum cb_cast_type cast_type
Definition: tree.h:959
cb_tree val
Definition: tree.h:958
enum cb_class cb_tree_class(cb_tree x)
Definition: tree.c:836
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
struct cb_statement * current_statement
Definition: parser.c:169
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_true ( cb_tree  l)

Definition at line 8139 of file typeck.c.

References _, cb_build_field_reference(), cb_build_move(), CB_CHAIN, cb_emit, cb_error_node, cb_error_x(), CB_FIELD_P, CB_FIELD_PTR, CB_PAIR_P, CB_PAIR_X, CB_REFERENCE, CB_REFERENCE_P, CB_VALUE, cb_field::level, cb_field::parent, value, and cb_field::values.

Referenced by yyparse().

8140 {
8141  cb_tree x;
8142  struct cb_field *f;
8143  cb_tree ref;
8144  cb_tree val;
8145 
8146  for (; l; l = CB_CHAIN (l)) {
8147  x = CB_VALUE (l);
8148  if (x == cb_error_node) {
8149  return;
8150  }
8151  if (!(CB_REFERENCE_P (x) && CB_FIELD_P(CB_REFERENCE(x)->value)) &&
8152  !CB_FIELD_P (x)) {
8153  cb_error_x (x, _("Invalid SET statement"));
8154  return;
8155  }
8156  f = CB_FIELD_PTR (x);
8157  if (f->level != 88) {
8158  cb_error_x (x, _("Invalid SET statement"));
8159  return;
8160  }
8161  ref = cb_build_field_reference (f->parent, x);
8162  val = CB_VALUE (f->values);
8163  if (CB_PAIR_P (val)) {
8164  val = CB_PAIR_X (val);
8165  }
8166  cb_emit (cb_build_move (val, ref));
8167  }
8168 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_PAIR_P(x)
Definition: tree.h:1204
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
int level
Definition: tree.h:673
#define CB_VALUE(x)
Definition: tree.h:1193
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
struct cb_field * parent
Definition: tree.h:651
#define cb_emit(x)
Definition: typeck.c:75
cb_tree values
Definition: tree.h:648

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_set_up_down ( cb_tree  l,
cb_tree  flag,
cb_tree  x 
)

Definition at line 8106 of file typeck.c.

References cb_build_add(), cb_build_sub(), CB_CHAIN, cb_emit, cb_int0, cb_validate_list(), cb_validate_one(), and CB_VALUE.

Referenced by yyparse().

8107 {
8108  if (cb_validate_one (x)) {
8109  return;
8110  }
8111  if (cb_validate_list (l)) {
8112  return;
8113  }
8114  for (; l; l = CB_CHAIN (l)) {
8115  if (flag == cb_int0) {
8116  cb_emit (cb_build_add (CB_VALUE (l), x, cb_int0));
8117  } else {
8118  cb_emit (cb_build_sub (CB_VALUE (l), x, cb_int0));
8119  }
8120  }
8121 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_build_add(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:4015
cb_tree cb_build_sub(cb_tree v, cb_tree n, cb_tree round_opt)
Definition: typeck.c:4058
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_CHAIN(x)
Definition: tree.h:1194
cb_tree cb_int0
Definition: tree.c:133
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_setenv ( cb_tree  x,
cb_tree  y 
)

Definition at line 8013 of file typeck.c.

References CB_BUILD_FUNCALL_2, and cb_emit.

Referenced by yyparse().

8014 {
8015  cb_emit (CB_BUILD_FUNCALL_2 ("cob_set_environment", x, y));
8016 }
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define cb_emit(x)
Definition: typeck.c:75

Here is the caller graph for this function:

void cb_emit_sort_finish ( cb_tree  file)

Definition at line 8356 of file typeck.c.

References CB_BUILD_FUNCALL_1, cb_emit, CB_FILE_P, and cb_ref().

Referenced by yyparse().

8357 {
8358  if (CB_FILE_P (cb_ref (file))) {
8359  cb_emit (CB_BUILD_FUNCALL_1 ("cob_file_sort_close", cb_ref (file)));
8360  }
8361 }
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_FILE_P(x)
Definition: tree.h:859
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_sort_giving ( cb_tree  file,
cb_tree  l 
)

Definition at line 8319 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, CB_CHAIN, cb_emit, cb_error_x(), CB_FILE, CB_FUNCALL, cb_list_length(), cb_ref(), CB_TREE, cb_validate_list(), CB_VALUE, COB_ORG_SORT, and current_statement.

Referenced by yyparse().

8320 {
8321  cb_tree p;
8322  int listlen;
8323 
8324  if (cb_validate_list (l)) {
8325  return;
8326  }
8327  for (p = l; p; p = CB_CHAIN (p)) {
8328  if (CB_FILE (cb_ref(CB_VALUE(p)))->organization == COB_ORG_SORT) {
8330  _("Invalid SORT GIVING parameter"));
8331  }
8332  }
8333  listlen = cb_list_length (l);
8334  p = CB_BUILD_FUNCALL_2 ("cob_file_sort_giving", cb_ref (file), l);
8335  CB_FUNCALL(p)->varcnt = listlen;
8336  cb_emit (p);
8337 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_FILE(x)
Definition: tree.h:858
#define CB_FUNCALL(x)
Definition: tree.h:951
#define CB_VALUE(x)
Definition: tree.h:1193
int cb_list_length(cb_tree l)
Definition: tree.c:1342
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
#define COB_ORG_SORT
Definition: common.h:746
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_sort_init ( cb_tree  name,
cb_tree  keys,
cb_tree  col 
)

Definition at line 8237 of file typeck.c.

References _, CB_BUILD_CAST_ADDRESS, cb_build_cast_int(), CB_BUILD_FUNCALL_2, CB_BUILD_FUNCALL_3, CB_BUILD_FUNCALL_4, CB_BUILD_FUNCALL_5, CB_CHAIN, cb_emit, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_PTR, CB_FILE, CB_FILE_P, cb_int(), cb_list_length(), CB_PURPOSE, cb_ref(), cb_program::cb_sort_return, cb_validate_list(), CB_VALUE, COB_ORG_SORT, current_program, cb_field::depending, cb_field::name, NULL, cb_field::occurs_max, cb_field::offset, and cb_field::parent.

Referenced by yyparse().

8238 {
8239  cb_tree l;
8240  struct cb_field *f;
8241 
8242  if (cb_validate_list (keys)) {
8243  return;
8244  }
8245  if (cb_ref (name) == cb_error_node) {
8246  return;
8247  }
8248  for (l = keys; l; l = CB_CHAIN (l)) {
8249  if (CB_VALUE (l) == NULL) {
8250  CB_VALUE (l) = name;
8251  }
8252  cb_ref (CB_VALUE (l));
8253  }
8254 
8255  if (CB_FILE_P (cb_ref (name))) {
8256  if (CB_FILE (cb_ref (name))->organization != COB_ORG_SORT) {
8257  cb_error_x (name, _("Invalid SORT filename"));
8258  }
8260  cb_emit (CB_BUILD_FUNCALL_5 ("cob_file_sort_init", cb_ref (name),
8261  cb_int (cb_list_length (keys)), col,
8263  CB_FILE(cb_ref (name))->file_status));
8264  for (l = keys; l; l = CB_CHAIN (l)) {
8265  cb_emit (CB_BUILD_FUNCALL_4 ("cob_file_sort_init_key",
8266  cb_ref (name),
8267  CB_VALUE (l),
8268  CB_PURPOSE (l),
8269  cb_int (CB_FIELD_PTR (CB_VALUE(l))->offset)));
8270  }
8271  } else {
8272  if (keys == NULL) {
8273  cb_error_x (name, _("Table sort without keys not implemented yet"));
8274  }
8275  cb_emit (CB_BUILD_FUNCALL_2 ("cob_table_sort_init",
8276  cb_int (cb_list_length (keys)), col));
8277  for (l = keys; l; l = CB_CHAIN (l)) {
8278  cb_emit (CB_BUILD_FUNCALL_3 ("cob_table_sort_init_key",
8279  CB_VALUE (l),
8280  CB_PURPOSE (l),
8282  - CB_FIELD_PTR (CB_VALUE(l))->parent->offset)));
8283  }
8284  f = CB_FIELD (cb_ref (name));
8285  cb_emit (CB_BUILD_FUNCALL_2 ("cob_table_sort", name,
8286  (f->depending
8288  : cb_int (f->occurs_max))));
8289  }
8290 }
const char * name
Definition: tree.h:645
int occurs_max
Definition: tree.h:677
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_BUILD_FUNCALL_4(f, a1, a2, a3, a4)
Definition: tree.h:1811
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_PURPOSE(x)
Definition: tree.h:1192
#define CB_FILE(x)
Definition: tree.h:858
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int cb_list_length(cb_tree l)
Definition: tree.c:1342
cb_tree depending
Definition: tree.h:647
int offset
Definition: tree.h:675
#define CB_BUILD_CAST_ADDRESS(x)
Definition: tree.h:1841
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_sort_return
Definition: tree.h:1266
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define CB_FILE_P(x)
Definition: tree.h:859
cb_tree cb_error_node
Definition: tree.c:140
struct cb_field * parent
Definition: tree.h:651
struct cb_program * current_program
Definition: parser.c:168
#define COB_ORG_SORT
Definition: common.h:746
#define cb_emit(x)
Definition: typeck.c:75
#define CB_BUILD_FUNCALL_5(f, a1, a2, a3, a4, a5)
Definition: tree.h:1815
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_sort_input ( cb_tree  proc)

Definition at line 8309 of file typeck.c.

References cb_build_debug(), cb_build_perform_once(), cb_emit, current_program, current_statement, cb_program::flag_debugging, cb_statement::flag_in_debug, and NULL.

Referenced by yyparse().

8310 {
8313  cb_emit (cb_build_debug (cb_debug_contents, "SORT INPUT", NULL));
8314  }
8315  cb_emit (cb_build_perform_once (proc));
8316 }
cb_tree cb_build_perform_once(cb_tree body)
Definition: typeck.c:7523
unsigned int flag_debugging
Definition: tree.h:1320
unsigned int flag_in_debug
Definition: tree.h:1150
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_debug_contents
Definition: typeck.c:88
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_sort_output ( cb_tree  proc)

Definition at line 8340 of file typeck.c.

References cb_build_debug(), cb_build_perform_once(), cb_emit, current_program, current_statement, cb_program::flag_debugging, cb_statement::flag_in_debug, cb_statement::flag_merge, and NULL.

Referenced by yyparse().

8341 {
8346  "MERGE OUTPUT", NULL));
8347  } else {
8349  "SORT OUTPUT", NULL));
8350  }
8351  }
8352  cb_emit (cb_build_perform_once (proc));
8353 }
cb_tree cb_build_perform_once(cb_tree body)
Definition: typeck.c:7523
unsigned int flag_debugging
Definition: tree.h:1320
unsigned int flag_in_debug
Definition: tree.h:1150
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct cb_program * current_program
Definition: parser.c:168
cb_tree cb_debug_contents
Definition: typeck.c:88
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
unsigned int flag_merge
Definition: tree.h:1151
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_sort_using ( cb_tree  file,
cb_tree  l 
)

Definition at line 8293 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, CB_CHAIN, cb_emit, cb_error_x(), CB_FILE, cb_ref(), CB_TREE, cb_validate_list(), CB_VALUE, COB_ORG_SORT, and current_statement.

Referenced by yyparse().

8294 {
8295  if (cb_validate_list (l)) {
8296  return;
8297  }
8298  for (; l; l = CB_CHAIN (l)) {
8299  if (CB_FILE (cb_ref(CB_VALUE(l)))->organization == COB_ORG_SORT) {
8301  _("Invalid SORT USING parameter"));
8302  }
8303  cb_emit (CB_BUILD_FUNCALL_2 ("cob_file_sort_using",
8304  cb_ref (file), cb_ref (CB_VALUE (l))));
8305  }
8306 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_FILE(x)
Definition: tree.h:858
#define CB_VALUE(x)
Definition: tree.h:1193
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_CHAIN(x)
Definition: tree.h:1194
#define COB_ORG_SORT
Definition: common.h:746
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_start ( cb_tree  file,
cb_tree  op,
cb_tree  key,
cb_tree  keylen 
)

Definition at line 8414 of file typeck.c.

References _, cb_file::access_mode, CB_BUILD_FUNCALL_5, cb_emit, cb_error_node, cb_error_x(), CB_FIELD_PTR, CB_FILE, cb_ref(), CB_TREE, cb_validate_one(), check_valid_key(), COB_ACCESS_RANDOM, COB_ORG_INDEXED, COB_ORG_RELATIVE, current_program, current_statement, cb_statement::file, cb_file::file_status, cb_statement::flag_callback, cb_program::flag_debugging, cb_file::flag_fl_debug, cb_statement::flag_in_debug, cb_file::key, and cb_file::organization.

Referenced by yyparse().

8415 {
8416  cb_tree kfld;
8417  cb_tree fl;
8418  cb_tree cbtkey;
8419  struct cb_file *f;
8420 
8421  if (cb_validate_one (key)) {
8422  return;
8423  }
8424  if (cb_validate_one (keylen)) {
8425  return;
8426  }
8427  if (file == cb_error_node) {
8428  return;
8429  }
8430  fl = cb_ref (file);
8431  if (fl == cb_error_node) {
8432  return;
8433  }
8434  f = CB_FILE (fl);
8435 
8436  if (f->organization != COB_ORG_INDEXED &&
8439  _("%s not allowed on %s files"), "START", "SEQUENTIAL");
8440  return;
8441  }
8442  if (keylen && f->organization != COB_ORG_INDEXED) {
8444  _("LENGTH/SIZE clause only allowed on INDEXED files"));
8445  return;
8446  }
8447  if (f->access_mode == COB_ACCESS_RANDOM) {
8449  _("START not allowed with ACCESS MODE RANDOM"));
8450  return;
8451  }
8452 
8453  current_statement->file = fl;
8454  if (key) {
8455  kfld = cb_ref (key);
8456  if (kfld == cb_error_node) {
8457  return;
8458  }
8459  if (check_valid_key (f, CB_FIELD_PTR (kfld))) {
8460  return;
8461  }
8462  cbtkey = key;
8463  } else {
8464  cbtkey = f->key;
8465  }
8466 
8467  /* Check for file debugging */
8470  f->flag_fl_debug) {
8471  /* Gen callback after start but before exception test */
8473  }
8474 
8475  cb_emit (CB_BUILD_FUNCALL_5 ("cob_start", fl, op, cbtkey, keylen,
8476  f->file_status));
8477 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
static unsigned int check_valid_key(const struct cb_file *cbf, const struct cb_field *f)
Definition: typeck.c:8366
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_ORG_INDEXED
Definition: common.h:745
#define CB_FILE(x)
Definition: tree.h:858
unsigned int flag_debugging
Definition: tree.h:1320
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
#define COB_ORG_RELATIVE
Definition: common.h:744
cb_tree file
Definition: tree.h:1140
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
int access_mode
Definition: tree.h:845
cb_tree file_status
Definition: tree.h:824
unsigned int flag_fl_debug
Definition: tree.h:854
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ACCESS_RANDOM
Definition: common.h:753
unsigned int flag_callback
Definition: tree.h:1152
#define cb_emit(x)
Definition: typeck.c:75
#define CB_BUILD_FUNCALL_5(f, a1, a2, a3, a4, a5)
Definition: tree.h:1815
cb_tree key
Definition: tree.h:826
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_stop_run ( cb_tree  x)

Definition at line 8482 of file typeck.c.

References cb_build_cast_int(), CB_BUILD_FUNCALL_1, and cb_emit.

Referenced by yyparse().

8483 {
8484  cb_emit (CB_BUILD_FUNCALL_1 ("cob_stop_run", cb_build_cast_int (x)));
8485 }
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_cast_int(const cb_tree val)
Definition: tree.c:2964

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_string ( cb_tree  items,
cb_tree  into,
cb_tree  pointer 
)

Definition at line 8490 of file typeck.c.

References CB_BUILD_FUNCALL_0, CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_2, CB_CHAIN, cb_emit, cb_int0, CB_PAIR_P, CB_PAIR_X, cb_validate_one(), CB_VALUE, and NULL.

Referenced by yyparse().

8491 {
8492  cb_tree start;
8493  cb_tree l;
8494  cb_tree end;
8495  cb_tree dlm;
8496 
8497  if (cb_validate_one (into)) {
8498  return;
8499  }
8500  if (cb_validate_one (pointer)) {
8501  return;
8502  }
8503  start = items;
8504  cb_emit (CB_BUILD_FUNCALL_2 ("cob_string_init", into, pointer));
8505  while (start) {
8506 
8507  /* Find DELIMITED item */
8508  for (end = start; end; end = CB_CHAIN (end)) {
8509  if (CB_PAIR_P (CB_VALUE (end))) {
8510  break;
8511  }
8512  }
8513 
8514  /* cob_string_delimited */
8515  dlm = end ? CB_PAIR_X (CB_VALUE (end)) : NULL;
8516  if (dlm == cb_int0) {
8517  dlm = NULL;
8518  }
8519  cb_emit (CB_BUILD_FUNCALL_1 ("cob_string_delimited", dlm));
8520 
8521  /* cob_string_append */
8522  for (l = start; l != end; l = CB_CHAIN (l)) {
8523  cb_emit (CB_BUILD_FUNCALL_1 ("cob_string_append",
8524  CB_VALUE (l)));
8525  }
8526 
8527  start = end ? CB_CHAIN (end) : NULL;
8528  }
8529  cb_emit (CB_BUILD_FUNCALL_0 ("cob_string_finish"));
8530 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_PAIR_P(x)
Definition: tree.h:1204
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int0
Definition: tree.c:133
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_unlock ( cb_tree  ref)

Definition at line 8535 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_emit, cb_error_node, CB_FILE, cb_ref(), current_statement, file, cb_statement::file, and cb_file::file_status.

Referenced by yyparse().

8536 {
8537  cb_tree file;
8538 
8539  if (ref != cb_error_node) {
8540  file = cb_ref (ref);
8541  if (file != cb_error_node) {
8542  cb_emit (CB_BUILD_FUNCALL_2 ("cob_unlock_file",
8543  file, CB_FILE(file)->file_status));
8545  }
8546  }
8547 }
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_FILE(x)
Definition: tree.h:858
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
cb_tree file
Definition: tree.h:1140
cb_tree cb_error_node
Definition: tree.c:140
cb_tree file_status
Definition: tree.h:824
#define cb_emit(x)
Definition: typeck.c:75
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_unstring ( cb_tree  name,
cb_tree  delimited,
cb_tree  into,
cb_tree  pointer,
cb_tree  tallying 
)

Definition at line 8552 of file typeck.c.

References CB_BUILD_FUNCALL_0, CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_3, cb_emit, cb_emit_list, cb_int(), cb_list_length(), cb_validate_list(), and cb_validate_one().

Referenced by yyparse().

8554 {
8555  if (cb_validate_one (name)) {
8556  return;
8557  }
8558  if (cb_validate_one (tallying)) {
8559  return;
8560  }
8561  if (cb_validate_list (delimited)) {
8562  return;
8563  }
8564  if (cb_validate_list (into)) {
8565  return;
8566  }
8567  cb_emit (CB_BUILD_FUNCALL_3 ("cob_unstring_init", name, pointer,
8568  cb_int (cb_list_length (delimited))));
8569  cb_emit_list (delimited);
8570  cb_emit_list (into);
8571  if (tallying) {
8572  cb_emit (CB_BUILD_FUNCALL_1 ("cob_unstring_tallying", tallying));
8573  }
8574  cb_emit (CB_BUILD_FUNCALL_0 ("cob_unstring_finish"));
8575 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define cb_emit_list(l)
Definition: typeck.c:77
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
int cb_list_length(cb_tree l)
Definition: tree.c:1342
#define CB_BUILD_FUNCALL_0(f)
Definition: tree.h:1795
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define cb_emit(x)
Definition: typeck.c:75
static size_t cb_validate_list(cb_tree l)
Definition: typeck.c:581

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_emit_write ( cb_tree  record,
cb_tree  from,
cb_tree  opt,
cb_tree  lockopt 
)

Definition at line 8604 of file typeck.c.

References _, cb_build_debug(), cb_build_debug_call(), CB_BUILD_FUNCALL_5, cb_build_move(), cb_emit, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_PTR, CB_FILE, cb_int(), cb_int0, cb_int1, cb_int_hex(), cb_ref(), CB_REF_OR_FIELD_P, CB_STORAGE_FILE, CB_TREE, cb_validate_one(), COB_EC_I_O_EOP, COB_EC_I_O_INVALID_KEY, COB_LOCK_AUTOMATIC, COB_ORG_INDEXED, COB_ORG_LINE_SEQUENTIAL, COB_ORG_RELATIVE, COB_ORG_SORT, COB_WRITE_AFTER, COB_WRITE_BEFORE, COB_WRITE_LINES, COB_WRITE_LOCK, current_program, current_statement, cb_file::debug_section, file, cb_statement::file, cb_file::file_status, cb_program::flag_debugging, cb_statement::flag_in_debug, cb_file::flag_line_adv, cb_statement::handler1, cb_statement::handler_id, cb_file::lock_mode, cb_file::name, NULL, and cb_file::organization.

Referenced by yyparse().

8605 {
8606  cb_tree file;
8607  cb_tree check_eop;
8608  struct cb_file *f;
8609 
8610  if (cb_validate_one (record)) {
8611  return;
8612  }
8613  if (cb_validate_one (from)) {
8614  return;
8615  }
8616  if (!CB_REF_OR_FIELD_P (cb_ref (record))) {
8618  _("%s requires a record name as subject"), "WRITE");
8619  return;
8620  }
8621  if (CB_FIELD_PTR (record)->storage != CB_STORAGE_FILE) {
8623  _("%s subject does not refer to a record name"), "WRITE");
8624  return;
8625  }
8626  file = CB_TREE (CB_FIELD (cb_ref (record))->file);
8627  if (!file || file == cb_error_node) {
8628  return;
8629  }
8631  f = CB_FILE (file);
8632 
8633  if (f->organization == COB_ORG_SORT) {
8635  _("%s not allowed on %s files"), "WRITE", "SORT");
8637  (f->organization != COB_ORG_RELATIVE &&
8638  f->organization != COB_ORG_INDEXED)) {
8640  _("INVALID KEY clause invalid with this file type"));
8641  } else if (lockopt) {
8642  if (f->lock_mode & COB_LOCK_AUTOMATIC) {
8644  _("LOCK clause invalid with file LOCK AUTOMATIC"));
8645  } else if (opt != cb_int0) {
8647  _("LOCK clause invalid here"));
8648  } else if (lockopt == cb_int1) {
8649  opt = cb_int (COB_WRITE_LOCK);
8650  }
8651  }
8652 
8653  if (from) {
8654  cb_emit (cb_build_move (from, record));
8655  }
8656 
8657  /* Check debugging on record name */
8660  CB_FIELD_PTR (record)->flag_field_debug) {
8662  CB_FIELD_PTR (record)->name, NULL));
8665  }
8667  opt == cb_int0) {
8668  if (cb_flag_write_after || CB_FILE (file)->flag_line_adv) {
8670  } else {
8672  }
8673  }
8676  check_eop = cb_int1;
8677  } else {
8678  check_eop = cb_int0;
8679  }
8680  cb_emit (CB_BUILD_FUNCALL_5 ("cob_write", file, record, opt,
8681  f->file_status, check_eop));
8682 }
#define COB_WRITE_LINES
Definition: common.h:802
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_int1
Definition: tree.c:134
cb_tree cb_debug_name
Definition: typeck.c:84
unsigned int flag_line_adv
Definition: tree.h:855
const char * name
Definition: tree.h:820
#define COB_LOCK_AUTOMATIC
Definition: common.h:775
int lock_mode
Definition: tree.h:846
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_ORG_INDEXED
Definition: common.h:745
int handler_id
Definition: tree.h:1148
#define CB_FILE(x)
Definition: tree.h:858
#define COB_WRITE_AFTER
Definition: common.h:805
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_debugging
Definition: tree.h:1320
struct cb_label * debug_section
Definition: tree.h:839
unsigned int flag_in_debug
Definition: tree.h:1150
#define _(s)
Definition: cobcrun.c:59
cb_tree cb_int_hex(const int n)
Definition: tree.c:1514
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree cb_int0
Definition: tree.c:133
#define COB_ORG_RELATIVE
Definition: common.h:744
cb_tree cb_build_debug_call(struct cb_label *target)
Definition: tree.c:1590
cb_tree cb_int(const int n)
Definition: tree.c:1488
cb_tree file
Definition: tree.h:1140
Definition: tree.h:818
cb_tree cb_error_node
Definition: tree.c:140
#define COB_WRITE_BEFORE
Definition: common.h:806
cb_tree file_status
Definition: tree.h:824
struct cb_program * current_program
Definition: parser.c:168
int organization
Definition: tree.h:844
#define COB_ORG_SORT
Definition: common.h:746
cb_tree cb_debug_contents
Definition: typeck.c:88
#define COB_ORG_LINE_SEQUENTIAL
Definition: common.h:743
#define cb_emit(x)
Definition: typeck.c:75
cb_tree cb_build_debug(const cb_tree target, const char *str, const cb_tree fld)
Definition: tree.c:1566
#define CB_BUILD_FUNCALL_5(f, a1, a2, a3, a4, a5)
Definition: tree.h:1815
#define COB_WRITE_LOCK
Definition: common.h:808
cb_tree handler1
Definition: tree.h:1141
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

char* cb_encode_program_id ( const char *  name)

Definition at line 1132 of file typeck.c.

References COB_FOLD_LOWER, COB_FOLD_UPPER, COB_MINI_BUFF, cob_u8_t, cobc_check_string(), hexval, likely, NULL, unlikely, and valid_char.

Referenced by cb_build_program_id(), emit_entry(), output_call(), output_cancel(), process_filename(), and user_func_upper().

1133 {
1134  unsigned char *p;
1135  const unsigned char *s;
1136  const unsigned char *t;
1137  unsigned char buff[COB_MINI_BUFF];
1138 
1139  s = NULL;
1140  for (t = (const unsigned char *)name; *t; t++) {
1141  if (*t == (unsigned char)'/' || *t == (unsigned char)'\\') {
1142  s = t + 1;
1143  }
1144  }
1145  if (!s) {
1146  s = (const unsigned char *)name;
1147  }
1148  p = buff;
1149  /* Encode the initial digit */
1150  if (*s <= (unsigned char)'9' && *s >= (unsigned char)'0') {
1151  *p++ = (unsigned char)'_';
1152  }
1153  /* Encode invalid letters */
1154  for (; *s; s++) {
1155  if (likely(valid_char[*s])) {
1156  *p++ = *s;
1157  } else {
1158  *p++ = (unsigned char)'_';
1159  if (*s == (unsigned char)'-') {
1160  *p++ = (unsigned char)'_';
1161  } else {
1162  *p++ = hexval[*s / 16U];
1163  *p++ = hexval[*s % 16U];
1164  }
1165  }
1166  }
1167  *p = 0;
1168 
1169  /* Check case folding */
1170  if (unlikely(cb_fold_call)) {
1171  if (cb_fold_call == COB_FOLD_UPPER) {
1172  for (p = buff; *p; p++) {
1173  if (islower (*p)) {
1174  *p = (cob_u8_t)toupper (*p);
1175  }
1176  }
1177  } else if (cb_fold_call == COB_FOLD_LOWER) {
1178  for (p = buff; *p; p++) {
1179  if (isupper (*p)) {
1180  *p = (cob_u8_t)tolower (*p);
1181  }
1182  }
1183  }
1184  }
1185 
1186  return cobc_check_string ((char *)buff);
1187 }
const char * name
Definition: tree.h:820
#define COB_MINI_BUFF
Definition: common.h:539
void * cobc_check_string(const char *dupstr)
Definition: cobc.c:951
#define cob_u8_t
Definition: common.h:27
static unsigned char valid_char[256]
Definition: typeck.c:200
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static const unsigned char hexval[]
Definition: typeck.c:109
#define COB_FOLD_LOWER
Definition: common.h:587
#define COB_FOLD_UPPER
Definition: common.h:586
#define likely(x)
Definition: common.h:436

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree cb_expr_finish ( void  )
static

Definition at line 3108 of file typeck.c.

References _, cb_error(), cb_error_node, cb_error_x(), cb_exp_line, cb_source_file, expr_expand(), expr_index, expr_reduce(), cb_tree_common::source_file, cb_tree_common::source_line, value, and expr_node::value.

Referenced by cb_build_expr().

3109 {
3110  /* Reduce all */
3111  (void)expr_reduce (0);
3112 
3113  if (!expr_stack[3].value) {
3114  cb_error (_("Invalid expression"));
3115  return cb_error_node;
3116  }
3117 
3120 
3121  if (expr_index != 4) {
3122  cb_error_x (expr_stack[3].value, _("Invalid expression"));
3123  return cb_error_node;
3124  }
3125 
3126  expr_expand (&expr_stack[3].value);
3127  if (expr_stack[3].token != 'x') {
3128  cb_error_x (expr_stack[3].value, _("Invalid expression"));
3129  return cb_error_node;
3130  }
3131 
3132  return expr_stack[3].value;
3133 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
const char * cb_source_file
Definition: cobc.c:145
static void expr_expand(cb_tree *x)
Definition: typeck.c:3088
const char * source_file
Definition: tree.h:431
cb_tree value
Definition: typeck.c:66
strict implicit external value
Definition: warning.def:54
int source_line
Definition: tree.h:432
#define _(s)
Definition: cobcrun.c:59
static int expr_index
Definition: typeck.c:105
cb_tree cb_error_node
Definition: tree.c:140
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98
int cb_exp_line
Definition: parser.c:174
static struct expr_node * expr_stack
Definition: typeck.c:107
static int expr_reduce(int token)
Definition: typeck.c:2788

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_expr_init ( void  )
static

Definition at line 2714 of file typeck.c.

References cobc_main_malloc(), expr_index, expr_op, expr_stack_size, initialized, NULL, and START_STACK_SIZE.

Referenced by cb_build_expr().

2715 {
2716  if (initialized == 0) {
2717  initialized = 1;
2718  /* Init stack */
2720  expr_stack = cobc_main_malloc (sizeof (struct expr_node) * START_STACK_SIZE);
2721  } else {
2722  memset (expr_stack, 0, expr_stack_size * sizeof (struct expr_node));
2723  }
2724  expr_op = 0;
2725  expr_lh = NULL;
2726  /* First three entries are dummies */
2727  expr_index = 3;
2728 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
static int expr_stack_size
Definition: typeck.c:106
static cb_tree expr_lh
Definition: typeck.c:100
static int expr_op
Definition: typeck.c:99
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static int expr_index
Definition: typeck.c:105
static size_t initialized
Definition: typeck.c:102
#define START_STACK_SIZE
Definition: typeck.c:69
static struct expr_node * expr_stack
Definition: typeck.c:107

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_expr_shift ( int  token,
cb_tree  value 
)
static

Definition at line 2970 of file typeck.c.

References cb_build_binary_op(), CB_BUILD_PARENTHESIS, cb_expr_shift_sign(), cb_zero, cobc_main_realloc(), expr_index, expr_op, expr_reduce(), expr_stack_size, TOKEN, value, and VALUE.

Referenced by cb_build_expr().

2971 {
2972  switch (token) {
2973  case 'M':
2974  break;
2975  case 'x':
2976  /* Sign ZERO condition */
2977  if (value == cb_zero) {
2978  if (TOKEN (-1) == 'x' || TOKEN (-1) == '!') {
2979  cb_expr_shift_sign ('=');
2980  return;
2981  }
2982  }
2983 
2984  /* Unary sign */
2985  if ((TOKEN (-1) == '+' || TOKEN (-1) == '-') &&
2986  TOKEN (-2) != 'x') {
2987  if (TOKEN (-1) == '-') {
2988  value = cb_build_binary_op (cb_zero, '-', value);
2989  }
2990  expr_index -= 1;
2991  }
2992  break;
2993 
2994  case '(':
2995  /* 'x' op '(' --> '(' 'x' op */
2996  switch (TOKEN (-1)) {
2997  case '=':
2998  case '~':
2999  case '<':
3000  case '>':
3001  case '[':
3002  case ']':
3003  expr_op = TOKEN (-1);
3004  if (TOKEN (-2) == 'x') {
3005  expr_lh = VALUE (-2);
3006  }
3007  break;
3008  default:
3009  break;
3010  }
3011  break;
3012 
3013  case ')':
3014  /* Enclosed by parentheses */
3015  (void)expr_reduce (token);
3016  if (TOKEN (-2) == '(') {
3017  value = CB_BUILD_PARENTHESIS (VALUE (-1));
3018  expr_index -= 2;
3019  cb_expr_shift ('x', value);
3020  return;
3021  }
3022  break;
3023 
3024  default:
3025  /* '<' '|' '=' --> '[' */
3026  /* '>' '|' '=' --> ']' */
3027  if (token == '=' && TOKEN (-1) == '|' &&
3028  (TOKEN (-2) == '<' || TOKEN (-2) == '>')) {
3029  token = (TOKEN (-2) == '<') ? '[' : ']';
3030  expr_index -= 2;
3031  }
3032 
3033  /* '!' '=' --> '~', etc. */
3034  if (TOKEN (-1) == '!') {
3035  switch (token) {
3036  case '=':
3037  token = '~';
3038  expr_index--;
3039  break;
3040  case '~':
3041  token = '=';
3042  expr_index--;
3043  break;
3044  case '<':
3045  token = ']';
3046  expr_index--;
3047  break;
3048  case '>':
3049  token = '[';
3050  expr_index--;
3051  break;
3052  case '[':
3053  token = '>';
3054  expr_index--;
3055  break;
3056  case ']':
3057  token = '<';
3058  expr_index--;
3059  break;
3060  default:
3061  break;
3062  }
3063  }
3064  break;
3065  }
3066 
3067  /* Reduce */
3068  /* Catch invalid condition */
3069  if (expr_reduce (token) > 0) {
3070  return;
3071  }
3072 
3073  /* Allocate sufficient stack memory */
3074  if (expr_index >= expr_stack_size) {
3075  while (expr_stack_size <= expr_index) {
3076  expr_stack_size *= 2;
3077  }
3079  }
3080 
3081  /* Put on the stack */
3082  TOKEN (0) = token;
3083  VALUE (0) = value;
3084  expr_index++;
3085 }
#define CB_BUILD_PARENTHESIS(x)
Definition: tree.h:1846
static void cb_expr_shift(int token, cb_tree value)
Definition: typeck.c:2970
cb_tree cb_zero
Definition: tree.c:125
static int expr_stack_size
Definition: typeck.c:106
static cb_tree expr_lh
Definition: typeck.c:100
static int expr_op
Definition: typeck.c:99
void * cobc_main_realloc(void *prevptr, const size_t size)
Definition: cobc.c:738
#define TOKEN(offset)
Definition: typeck.c:70
strict implicit external value
Definition: warning.def:54
#define VALUE(offset)
Definition: typeck.c:71
static int expr_index
Definition: typeck.c:105
static void cb_expr_shift_sign(const int op)
Definition: typeck.c:2930
static struct expr_node * expr_stack
Definition: typeck.c:107
static int expr_reduce(int token)
Definition: typeck.c:2788
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_expr_shift_class ( const char *  name)
static

Definition at line 2950 of file typeck.c.

References CB_BUILD_FUNCALL_1, CB_BUILD_NEGATION, expr_index, expr_reduce(), TOKEN, and VALUE.

Referenced by cb_build_expr().

2951 {
2952  int have_not;
2953 
2954  if (TOKEN (-1) == '!') {
2955  have_not = 1;
2956  expr_index--;
2957  } else {
2958  have_not = 0;
2959  }
2960  (void)expr_reduce ('=');
2961  if (TOKEN (-1) == 'x') {
2962  VALUE (-1) = CB_BUILD_FUNCALL_1 (name, VALUE (-1));
2963  if (have_not) {
2964  VALUE (-1) = CB_BUILD_NEGATION (VALUE (-1));
2965  }
2966  }
2967 }
const char * name
Definition: tree.h:820
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
#define TOKEN(offset)
Definition: typeck.c:70
#define VALUE(offset)
Definition: typeck.c:71
static int expr_index
Definition: typeck.c:105
static int expr_reduce(int token)
Definition: typeck.c:2788

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_expr_shift_sign ( const int  op)
static

Definition at line 2930 of file typeck.c.

References cb_build_binary_op(), CB_BUILD_NEGATION, cb_zero, expr_index, expr_reduce(), TOKEN, and VALUE.

Referenced by cb_build_expr(), and cb_expr_shift().

2931 {
2932  int have_not;
2933 
2934  if (TOKEN (-1) == '!') {
2935  have_not = 1;
2936  expr_index--;
2937  } else {
2938  have_not = 0;
2939  }
2940  (void)expr_reduce ('=');
2941  if (TOKEN (-1) == 'x') {
2942  VALUE (-1) = cb_build_binary_op (VALUE (-1), op, cb_zero);
2943  if (have_not) {
2944  VALUE (-1) = CB_BUILD_NEGATION (VALUE (-1));
2945  }
2946  }
2947 }
cb_tree cb_zero
Definition: tree.c:125
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
#define TOKEN(offset)
Definition: typeck.c:70
#define VALUE(offset)
Definition: typeck.c:71
static int expr_index
Definition: typeck.c:105
static int expr_reduce(int token)
Definition: typeck.c:2788
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

static int cb_field_size ( const cb_tree  x)
static

Definition at line 790 of file typeck.c.

References _, CB_FIELD, cb_get_int(), CB_LITERAL, CB_LITERAL_P, CB_REFERENCE, CB_TAG_FIELD, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE_TAG, cobc_abort_pr(), COBC_DUMB_ABORT, cb_reference::length, cb_reference::offset, cb_field::size, and cb_reference::value.

Referenced by cb_build_cond(), cb_build_length(), cb_build_length_1(), cb_build_memset(), cb_build_move_copy(), cb_build_move_field(), cb_check_overlapping(), cb_chk_alpha_cond(), and validate_move().

791 {
792  struct cb_reference *r;
793  struct cb_field *f;
794 
795  switch (CB_TREE_TAG (x)) {
796  case CB_TAG_LITERAL:
797  return CB_LITERAL (x)->size;
798  case CB_TAG_FIELD:
799  return CB_FIELD (x)->size;
800  case CB_TAG_REFERENCE:
801  r = CB_REFERENCE (x);
802  f = CB_FIELD (r->value);
803 
804  if (r->length) {
805  if (CB_LITERAL_P (r->length)) {
806  return cb_get_int (r->length);
807  } else {
808  return -1;
809  }
810  } else if (r->offset) {
811  if (CB_LITERAL_P (r->offset)) {
812  return f->size - cb_get_int (r->offset) + 1;
813  } else {
814  return -1;
815  }
816  } else {
817  return f->size;
818  }
819  default:
820  cobc_abort_pr (_("Unexpected tree tag %d"), (int)CB_TREE_TAG (x));
821  /* Use dumb variant */
822  COBC_DUMB_ABORT ();
823  }
824  /* NOT REACHED */
825 #ifndef _MSC_VER
826  return 0;
827 #endif
828 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define CB_LITERAL(x)
Definition: tree.h:601
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
cb_tree value
Definition: tree.h:876
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_TREE_TAG(x)
Definition: tree.h:441
cb_tree offset
Definition: tree.h:878
#define CB_REFERENCE(x)
Definition: tree.h:901
int size
Definition: tree.h:672
#define COBC_DUMB_ABORT()
Definition: cobc.h:62
cb_tree length
Definition: tree.h:879
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static void cb_gen_field_accept ( cb_tree  var,
cb_tree  pos,
cb_tree  fgc,
cb_tree  bgc,
cb_tree  scroll,
cb_tree  timeout,
cb_tree  prompt,
cb_tree  size_is,
int  dispattrs 
)
static

Definition at line 4316 of file typeck.c.

References CB_BUILD_FUNCALL_10, cb_emit, cb_int(), CB_LIST_P, CB_PAIR_X, CB_PAIR_Y, line, NULL, and valid_screen_pos().

Referenced by cb_emit_accept().

4319 {
4320  cb_tree line;
4321  cb_tree column;
4322 
4323  if (!pos) {
4324  cb_emit (CB_BUILD_FUNCALL_10 ("cob_field_accept",
4325  var, NULL, NULL, fgc, bgc, scroll,
4326  timeout, prompt, size_is, cb_int (dispattrs)));
4327  } else if (CB_LIST_P (pos)) {
4328  line = CB_PAIR_X (pos);
4329  column = CB_PAIR_Y (pos);
4330  cb_emit (CB_BUILD_FUNCALL_10 ("cob_field_accept",
4331  var, line, column, fgc, bgc, scroll,
4332  timeout, prompt, size_is, cb_int (dispattrs)));
4333  } else if (valid_screen_pos (pos)) {
4334  cb_emit (CB_BUILD_FUNCALL_10 ("cob_field_accept",
4335  var, pos, NULL, fgc, bgc, scroll,
4336  timeout, prompt, size_is, cb_int (dispattrs)));
4337  }
4338 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_PAIR_Y(x)
Definition: tree.h:1206
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static int valid_screen_pos(cb_tree pos)
Definition: typeck.c:4289
cb_tree cb_int(const int n)
Definition: tree.c:1488
#define CB_BUILD_FUNCALL_10(f, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
Definition: tree.h:1835
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
#define CB_LIST_P(x)
Definition: tree.h:1190
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_init_tallying ( void  )

Definition at line 5849 of file typeck.c.

References inspect_func, and NULL.

Referenced by yyparse().

5850 {
5851  inspect_func = NULL;
5852  inspect_data = NULL;
5853 }
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree inspect_data
Definition: typeck.c:97
static const char * inspect_func
Definition: typeck.c:96

Here is the caller graph for this function:

void cb_list_system ( void  )

Definition at line 833 of file typeck.c.

References _, system_table::syst_name, and system_table::syst_params.

Referenced by process_command_line().

834 {
835  const struct system_table *psyst;
836  const char *s;
837  size_t n;
838 
839  putchar ('\n');
840  printf (_("System routine\t\t\tParameters"));
841  puts ("\n");
842  for (psyst = system_tab; psyst->syst_name; psyst++) {
843  switch (*(unsigned char *)(psyst->syst_name)) {
844  case 'C':
845  case 'S':
846  printf ("%s", psyst->syst_name);
847  break;
848  case 0xF4:
849  printf ("X\"F4\"");
850  break;
851  case 0xF5:
852  printf ("X\"F5\"");
853  break;
854  case 0x91:
855  printf ("X\"91\"");
856  break;
857  case 0xE4:
858  printf ("X\"E4\"");
859  break;
860  case 0xE5:
861  printf ("X\"E5\"");
862  break;
863  default:
864  break;
865  }
866  n = strlen (psyst->syst_name);
867  switch (n / 8) {
868  case 0:
869  s = "\t\t\t\t";
870  break;
871  case 1:
872  s = "\t\t\t";
873  break;
874  case 2:
875  s = "\t\t";
876  break;
877  default:
878  s = "\t";
879  break;
880  }
881  printf ("%s%d\n", s, psyst->syst_params);
882  }
883 }
static const struct system_table system_tab[]
Definition: typeck.c:282
#define _(s)
Definition: cobcrun.c:59
const int syst_params
Definition: typeck.c:48
const char * syst_name
Definition: codegen.c:66

Here is the caller graph for this function:

static void cb_validate_collating ( struct cb_program prog)
static

Definition at line 1864 of file typeck.c.

References _, CB_ALPHABET_CUSTOM, CB_ALPHABET_NAME, CB_ALPHABET_NAME_P, cb_build_alphanumeric_literal(), cb_error_x(), cb_high, CB_LITERAL, cb_low, cb_name(), cb_ref(), cb_program::collating_sequence, and NULL.

Referenced by cb_validate_program_environment().

1865 {
1866  cb_tree x;
1867 
1868  x = cb_ref (prog->collating_sequence);
1869  if (!CB_ALPHABET_NAME_P (x)) {
1870  cb_error_x (prog->collating_sequence, _("'%s' is not an alphabet name"),
1871  cb_name (prog->collating_sequence));
1872  prog->collating_sequence = NULL;
1873  return;
1874  }
1875  if (CB_ALPHABET_NAME (x)->alphabet_type != CB_ALPHABET_CUSTOM) {
1876  return;
1877  }
1878  if (CB_ALPHABET_NAME (x)->low_val_char) {
1879  cb_low = cb_build_alphanumeric_literal ("\0", (size_t)1);
1880  CB_LITERAL(cb_low)->data[0] = (unsigned char)CB_ALPHABET_NAME (x)->low_val_char;
1881  CB_LITERAL(cb_low)->all = 1;
1882  }
1883  if (CB_ALPHABET_NAME (x)->high_val_char != 255){
1884  cb_high = cb_build_alphanumeric_literal ("\0", (size_t)1);
1885  CB_LITERAL(cb_high)->data[0] = (unsigned char)CB_ALPHABET_NAME (x)->high_val_char;
1886  CB_LITERAL(cb_high)->all = 1;
1887  }
1888 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LITERAL(x)
Definition: tree.h:601
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
cb_tree cb_build_alphanumeric_literal(const void *data, const size_t size)
Definition: tree.c:1716
#define CB_ALPHABET_NAME(x)
Definition: tree.h:550
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_ALPHABET_CUSTOM
Definition: tree.h:110
cb_tree collating_sequence
Definition: tree.h:1284
cb_tree cb_high
Definition: tree.c:129
#define CB_ALPHABET_NAME_P(x)
Definition: tree.h:551
cb_tree cb_low
Definition: tree.c:128

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t cb_validate_list ( cb_tree  l)
static

Definition at line 581 of file typeck.c.

References CB_CHAIN, cb_validate_one(), and CB_VALUE.

Referenced by cb_emit_arithmetic(), cb_emit_display(), cb_emit_free(), cb_emit_initialize(), cb_emit_move(), cb_emit_set_on_off(), cb_emit_set_to(), cb_emit_set_up_down(), cb_emit_sort_giving(), cb_emit_sort_init(), cb_emit_sort_using(), and cb_emit_unstring().

582 {
583  for (; l; l = CB_CHAIN (l)) {
584  if (cb_validate_one (CB_VALUE (l))) {
585  return 1;
586  }
587  }
588  return 0;
589 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545
#define CB_VALUE(x)
Definition: tree.h:1193
#define CB_CHAIN(x)
Definition: tree.h:1194

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t cb_validate_one ( cb_tree  x)
static

Definition at line 545 of file typeck.c.

References _, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_P, cb_ref(), CB_REFERENCE_P, cb_field::flag_invalid, cb_field::level, and cb_field::odo_level.

Referenced by cb_build_unstring_delimited(), cb_build_unstring_into(), cb_emit_accept(), cb_emit_accept_arg_number(), cb_emit_accept_arg_value(), cb_emit_accept_command_line(), cb_emit_accept_date(), cb_emit_accept_date_yyyymmdd(), cb_emit_accept_day(), cb_emit_accept_day_of_week(), cb_emit_accept_day_yyyyddd(), cb_emit_accept_environment(), cb_emit_accept_escape_key(), cb_emit_accept_exception_status(), cb_emit_accept_line_or_col(), cb_emit_accept_mnemonic(), cb_emit_accept_name(), cb_emit_accept_time(), cb_emit_accept_user_name(), cb_emit_allocate(), cb_emit_arg_number(), cb_emit_arithmetic(), cb_emit_cancel(), cb_emit_command_line(), cb_emit_corresponding(), cb_emit_divide(), cb_emit_env_name(), cb_emit_env_value(), cb_emit_get_environment(), cb_emit_move(), cb_emit_move_corresponding(), cb_emit_release(), cb_emit_return(), cb_emit_rewrite(), cb_emit_search(), cb_emit_search_all(), cb_emit_set_attribute(), cb_emit_set_to(), cb_emit_set_up_down(), cb_emit_start(), cb_emit_string(), cb_emit_unstring(), cb_emit_write(), cb_validate_list(), and validate_attrs().

546 {
547  cb_tree y;
548  struct cb_field *f;
549 
550  if (x == cb_error_node) {
551  return 1;
552  }
553  if (!x) {
554  return 0;
555  }
556  if (CB_REFERENCE_P (x)) {
557  y = cb_ref (x);
558  if (y == cb_error_node) {
559  return 1;
560  }
561  if (CB_FIELD_P (y)) {
562  f = CB_FIELD (y);
563  if (f->level == 88) {
564  cb_error_x (x, _("Invalid use of 88 level item"));
565  return 1;
566  }
567  if (f->flag_invalid) {
568  return 1;
569  }
570  /* check for nested ODO */
571  if (f->odo_level > 1) {
572  cb_error_x (x, _("'%s' not implemented"),
573  _("Reference to item containing nested ODO"));
574  }
575  }
576  }
577  return 0;
578 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
unsigned int odo_level
Definition: tree.h:687
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
int level
Definition: tree.h:673
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
unsigned int flag_invalid
Definition: tree.h:716
cb_tree cb_error_node
Definition: tree.c:140
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_validate_program_body ( struct cb_program prog)

Definition at line 2554 of file typeck.c.

References _, cb_program::all_procedure, cb_label::alter_gotos, cb_program::alter_gotos, cb_program::alter_list, CB_CHAIN, cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_PTR, CB_LABEL, CB_LABEL_P, cb_list_reverse(), cb_name(), CB_PURPOSE, cb_ref(), CB_REFERENCE, CB_TAG_FIELD, CB_TAG_FILE, CB_TAG_LABEL, CB_TREE_TAG, CB_VALUE, cb_warning_x(), cobc_cs_check, cobc_parse_malloc(), current_paragraph, current_program, current_section, cb_program::debug_list, cb_program::exec_list, cb_program::file_list, cb_program::flag_debugging, cb_label::flag_first_is_goto, cb_alter_id::goto_id, cb_label::id, cb_program::label_list, cb_field::memory_size, cb_field::name, cb_label::name, cb_alter_id::next, cb_field::size, and value.

Referenced by clean_up_program(), set_up_program(), and yyparse().

2555 {
2556  cb_tree l;
2557  cb_tree x;
2558  cb_tree v;
2559  struct cb_label *save_section;
2560  struct cb_label *save_paragraph;
2561  struct cb_alter_id *aid;
2562  struct cb_label *l1;
2563  struct cb_label *l2;
2564  struct cb_field *f;
2565  int size;
2566 
2567  /* Resolve all labels */
2568  save_section = current_section;
2569  save_paragraph = current_paragraph;
2570  for (l = cb_list_reverse (prog->label_list); l; l = CB_CHAIN (l)) {
2571  x = CB_VALUE (l);
2572  current_section = CB_REFERENCE (x)->section;
2573  current_paragraph = CB_REFERENCE (x)->paragraph;
2574  v = cb_ref (x);
2575  /* Check refs in to / out of DECLARATIVES */
2576  if (CB_LABEL_P (v)) {
2577  if (CB_REFERENCE (x)->flag_in_decl &&
2578  !CB_LABEL (v)->flag_declaratives) {
2579  if (!cb_relaxed_syntax_check) {
2580  cb_error_x (x, _("'%s' is not in DECLARATIVES"),
2581  CB_LABEL (v)->name);
2582  } else {
2583  cb_warning_x (x, _("'%s' is not in DECLARATIVES"),
2584  CB_LABEL (v)->name);
2585  }
2586  }
2587  if (CB_LABEL (v)->flag_declaratives &&
2588  !CB_REFERENCE (x)->flag_in_decl &&
2589  !CB_REFERENCE (x)->flag_decl_ok) {
2590  cb_error_x (x, _("Invalid reference to '%s' (In DECLARATIVES)"), CB_LABEL (v)->name);
2591  }
2592  CB_LABEL (v)->flag_begin = 1;
2593  if (CB_REFERENCE (x)->length) {
2594  CB_LABEL (v)->flag_return = 1;
2595  }
2596  } else if (v != cb_error_node) {
2597  cb_error_x (x, _("'%s' not a procedure name"), cb_name (x));
2598  }
2599  }
2600 
2601  /* Resolve DEBUG references */
2602  /* For data items, we may need to adjust the size of DEBUG-CONTENTS */
2603  /* Basic size of DEBUG-CONTENTS is 31 */
2604  size = 31;
2605  for (l = prog->debug_list; l; l = CB_CHAIN (l)) {
2606  x = CB_VALUE (l);
2607  current_section = CB_REFERENCE (x)->section;
2608  current_paragraph = CB_REFERENCE (x)->paragraph;
2609  v = cb_ref (x);
2610  if (v == cb_error_node) {
2611  continue;
2612  }
2613  switch (CB_TREE_TAG (v)) {
2614  case CB_TAG_LABEL:
2616  cb_error_x (x, _("'%s' - DEBUGGING target invalid with ALL PROCEDURES"),
2617  cb_name (x));
2618  }
2619  if (!CB_LABEL (v)->flag_real_label) {
2620  cb_error_x (x, _("'%s' - DEBUGGING target invalid"),
2621  cb_name (x));
2622  }
2623  CB_LABEL (v)->debug_section =
2624  CB_REFERENCE (x)->debug_section;
2625  CB_LABEL (v)->flag_debugging_mode = 1;
2626  break;
2627  case CB_TAG_FILE:
2628  break;
2629  case CB_TAG_FIELD:
2630  if (CB_FIELD (v)->size > size) {
2631  size = CB_FIELD (v)->size;
2632  }
2633  break;
2634  default:
2635  cb_error_x (x, _("'%s' is not a valid DEBUGGING target"),
2636  cb_name (x));
2637  break;
2638  }
2639  }
2640  /* If necessary, adjust size of DEBUG-CONTENTS (and DEBUG-ITEM) */
2642  if (size != 31) {
2644  f->size = size;
2645  f->memory_size = size;
2646  size -= 31;
2648  f->size += size;
2649  f->memory_size += size;
2650  }
2651  }
2652 
2653  /* Build ALTER ids - We need to remove duplicates */
2654  for (l = prog->alter_list; l; l = CB_CHAIN (l)) {
2655  if (CB_PURPOSE (l) == cb_error_node) {
2656  continue;
2657  }
2658  if (CB_VALUE (l) == cb_error_node) {
2659  continue;
2660  }
2661  x = CB_PURPOSE (l);
2662  v = CB_VALUE (l);
2663  if (CB_REFERENCE (x)->value == cb_error_node) {
2664  continue;
2665  }
2666  if (CB_REFERENCE (v)->value == cb_error_node) {
2667  continue;
2668  }
2669  l1 = CB_LABEL (CB_REFERENCE (x)->value);
2670  l2 = CB_LABEL (CB_REFERENCE (v)->value);
2671  current_section = CB_REFERENCE (x)->section;
2672  current_paragraph = CB_REFERENCE (x)->paragraph;
2673  /* First statement in paragraph must be a GO TO */
2674  if (!l1->flag_first_is_goto) {
2675  cb_error_x (x, _("'%s' is not an alterable paragraph"),
2676  l1->name);
2677  continue;
2678  }
2679  for (aid = l1->alter_gotos; aid; aid = aid->next) {
2680  if (aid->goto_id == l2->id) {
2681  break;
2682  }
2683  }
2684  if (!aid) {
2685  aid = cobc_parse_malloc (sizeof(struct cb_alter_id));
2686  aid->next = l1->alter_gotos;
2687  aid->goto_id = l2->id;
2688  l1->alter_gotos = aid;
2689  }
2690  for (aid = prog->alter_gotos; aid; aid = aid->next) {
2691  if (aid->goto_id == l1->id) {
2692  break;
2693  }
2694  }
2695  if (!aid) {
2696  aid = cobc_parse_malloc (sizeof(struct cb_alter_id));
2697  aid->next = prog->alter_gotos;
2698  aid->goto_id = l1->id;
2699  prog->alter_gotos = aid;
2700  }
2701  }
2702 
2703  current_section = save_section;
2704  current_paragraph = save_paragraph;
2705  cobc_cs_check = 0;
2706 
2707  prog->file_list = cb_list_reverse (prog->file_list);
2708  prog->exec_list = cb_list_reverse (prog->exec_list);
2709 }
const char * name
Definition: tree.h:645
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LABEL(x)
Definition: tree.h:801
const char * name
Definition: tree.h:766
void * cobc_parse_malloc(const size_t size)
Definition: cobc.c:809
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_LABEL_P(x)
Definition: tree.h:802
#define CB_PURPOSE(x)
Definition: tree.h:1192
cb_tree file_list
Definition: tree.h:1252
unsigned int flag_debugging
Definition: tree.h:1320
cb_tree debug_list
Definition: tree.h:1264
#define CB_VALUE(x)
Definition: tree.h:1193
struct cb_alter_id * alter_gotos
Definition: tree.h:1275
cb_tree alter_list
Definition: tree.h:1263
cb_tree cb_debug_item
Definition: typeck.c:82
strict implicit external value
Definition: warning.def:54
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define CB_REFERENCE(x)
Definition: tree.h:901
struct cb_alter_id * next
Definition: tree.h:760
int size
Definition: tree.h:672
cb_tree cb_error_node
Definition: tree.c:140
struct cb_label * current_paragraph
Definition: parser.c:171
cb_tree label_list
Definition: tree.h:1254
struct cb_program * current_program
Definition: parser.c:168
struct cb_alter_id * alter_gotos
Definition: tree.h:772
Definition: tree.h:764
cb_tree cb_debug_contents
Definition: typeck.c:88
struct cb_label * all_procedure
Definition: tree.h:1289
cb_tree exec_list
Definition: tree.h:1253
int memory_size
Definition: tree.h:674
int goto_id
Definition: tree.h:761
struct cb_label * current_section
Definition: parser.c:170
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
unsigned int cobc_cs_check
Definition: parser.c:182
int id
Definition: tree.h:773
#define CB_FIELD(x)
Definition: tree.h:740
unsigned int flag_first_is_goto
Definition: tree.h:793

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_validate_program_data ( struct cb_program prog)

Definition at line 2344 of file typeck.c.

References _, build_literal(), CB_ASSIGN_MF, cb_build_field(), cb_build_field_reference(), cb_build_implicit_field(), cb_build_picture(), cb_build_reference(), CB_CATEGORY_ALPHANUMERIC, CB_CHAIN, cb_depend_check, cb_error(), cb_error_node, cb_error_x(), CB_FIELD, CB_FIELD_ADD, CB_FIELD_P, CB_FIELD_PTR, CB_FILE, CB_LIST_INIT, cb_list_reverse(), CB_LITERAL, cb_name(), CB_NAME, cb_needs_01, CB_PICTURE, cb_ref(), CB_REF_OR_FIELD_P, CB_REFERENCE_P, CB_REPORT, CB_STORAGE_LINKAGE, CB_STORAGE_LOCAL, CB_STORAGE_WORKING, CB_TREE, CB_USAGE_DISPLAY, CB_USAGE_UNSIGNED_INT, CB_VALID_TREE, cb_validate_field(), CB_VALUE, cb_warning(), CB_WORD_COUNT, cb_zero, check_level_78(), cb_report::cname, COB_MINI_BUFF, COB_MINI_MAX, COB_SMALL_BUFF, cb_program::crt_status, current_program, cb_program::cursor_pos, cb_field::depending, cb_program::file_list, finalize_file(), cb_file::flag_finalized, cb_field::flag_is_global, cb_field::flag_no_init, cb_field::flag_odo_relative, cb_report::line_counter, cb_field::name, cb_report::name, NULL, cb_field::odo_level, cb_report::page_counter, cb_field::parent, cb_field::pic, cb_file::record_depending, cb_field::redefines, redefinition_error(), cb_program::reference_list, cb_program::report_list, cb_field::sister, cb_field::storage, cb_field::usage, cb_field::values, and cb_program::working_storage.

Referenced by yyparse().

2345 {
2346  cb_tree l;
2347  cb_tree x;
2348  cb_tree assign;
2349  struct cb_field *p;
2350  struct cb_field *q;
2351  struct cb_field *depfld;
2352  struct cb_file *f;
2353  struct cb_report *rep;
2354  unsigned char *c;
2355  char buff[COB_MINI_BUFF];
2356  unsigned int odo_level;
2357 
2358  for (l = current_program->report_list; l; l = CB_CHAIN (l)) {
2359  /* Set up LINE-COUNTER / PAGE-COUNTER */
2360  rep = CB_REPORT (CB_VALUE (l));
2361  snprintf (buff, (size_t)COB_MINI_MAX,
2362  "LINE-COUNTER %s", rep->cname);
2363  x = cb_build_field (cb_build_reference (buff));
2364  CB_FIELD (x)->usage = CB_USAGE_UNSIGNED_INT;
2365  CB_FIELD (x)->values = CB_LIST_INIT (cb_zero);
2366  CB_FIELD (x)->count++;
2370  snprintf (buff, (size_t)COB_MINI_MAX,
2371  "PAGE-COUNTER %s", rep->cname);
2372  x = cb_build_field (cb_build_reference (buff));
2373  CB_FIELD (x)->usage = CB_USAGE_UNSIGNED_INT;
2374  CB_FIELD (x)->values = CB_LIST_INIT (cb_zero);
2375  CB_FIELD (x)->count++;
2379  }
2380 
2381  for (l = current_program->file_list; l; l = CB_CHAIN (l)) {
2382  f = CB_FILE (CB_VALUE (l));
2383  if (!f->flag_finalized) {
2384  finalize_file (f, NULL);
2385  }
2386  }
2387 
2388  /* Build undeclared assignment name now */
2389  if (cb_assign_clause == CB_ASSIGN_MF) {
2390  for (l = current_program->file_list; l; l = CB_CHAIN (l)) {
2391  assign = CB_FILE (CB_VALUE (l))->assign;
2392  if (!assign) {
2393  continue;
2394  }
2395  if (CB_REFERENCE_P (assign)) {
2396  for (x = current_program->file_list; x; x = CB_CHAIN (x)) {
2397  if (!strcmp (CB_FILE (CB_VALUE (x))->name,
2398  CB_NAME (assign))) {
2399  redefinition_error (assign);
2400  }
2401  }
2402  p = check_level_78 (CB_NAME (assign));
2403  if (p) {
2404  c = (unsigned char *)CB_LITERAL(CB_VALUE(p->values))->data;
2405  assign = CB_TREE (build_literal (CB_CATEGORY_ALPHANUMERIC, c, strlen ((char *)c)));
2406  CB_FILE (CB_VALUE (l))->assign = assign;
2407  }
2408  }
2409  if (CB_REFERENCE_P (assign) &&
2410  CB_WORD_COUNT (assign) == 0) {
2411  if (cb_warn_implicit_define) {
2412  cb_warning (_("'%s' will be implicitly defined"), CB_NAME (assign));
2413  }
2415  CB_FIELD (x)->count++;
2417  if (p) {
2418  while (p->sister) {
2419  p = p->sister;
2420  }
2421  p->sister = CB_FIELD (x);
2422  } else {
2424  }
2425  }
2426  if (CB_REFERENCE_P (assign)) {
2427  x = cb_ref (assign);
2428  if (CB_FIELD_P (x) && CB_FIELD (x)->level == 88) {
2429  cb_error_x (assign, _("ASSIGN data item '%s' invalid"), CB_NAME (assign));
2430  }
2431  }
2432  }
2433  }
2434 
2435  if (prog->cursor_pos) {
2436  x = cb_ref (prog->cursor_pos);
2437  if (x == cb_error_node) {
2438  prog->cursor_pos = NULL;
2439  } else if (CB_FIELD(x)->size != 6 && CB_FIELD(x)->size != 4) {
2440  cb_error_x (prog->cursor_pos, _("'%s' CURSOR is not 4 or 6 characters long"),
2441  cb_name (prog->cursor_pos));
2442  prog->cursor_pos = NULL;
2443  }
2444  }
2445  if (prog->crt_status) {
2446  x = cb_ref (prog->crt_status);
2447  if (x == cb_error_node) {
2448  prog->crt_status = NULL;
2449  } else if (CB_FIELD(x)->size != 4) {
2450  cb_error_x (prog->crt_status, _("'%s' CRT STATUS is not 4 characters long"),
2451  cb_name (prog->crt_status));
2452  prog->crt_status = NULL;
2453  }
2454  } else {
2455  l = cb_build_reference ("COB-CRT-STATUS");
2456  p = CB_FIELD (cb_build_field (l));
2457  p->usage = CB_USAGE_DISPLAY;
2458  p->pic = CB_PICTURE (cb_build_picture ("9(4)"));
2459  cb_validate_field (p);
2460  p->flag_no_init = 1;
2461  /* Do not initialize/bump ref count here
2462  p->values = CB_LIST_INIT (cb_zero);
2463  p->count++;
2464  */
2466  prog->crt_status = l;
2467  }
2468 
2469  /* Resolve all references so far */
2470  for (l = cb_list_reverse (prog->reference_list); l; l = CB_CHAIN (l)) {
2471  cb_ref (CB_VALUE (l));
2472  }
2473 
2474  /* Check ODO items */
2475  for (l = cb_depend_check; l; l = CB_CHAIN (l)) {
2476  x = CB_VALUE(l);
2477  if (x == cb_error_node) {
2478  continue;
2479  }
2480  q = CB_FIELD_PTR (x);
2481  if (cb_ref (q->depending) != cb_error_node) {
2482  depfld = CB_FIELD_PTR (q->depending);
2483  } else {
2484  depfld = NULL;
2485  }
2486  /* The data item that contains a OCCURS DEPENDING clause must be
2487  the last data item in the group */
2488  odo_level = 0;
2489  for (p = q; ; p = p->parent) {
2490  if (p->depending) odo_level++;
2491  p->odo_level = odo_level;
2492  if (!p->parent) {
2493  break;
2494  }
2495  for (; p->sister; p = p->sister) {
2496  if (p->sister == depfld) {
2497  cb_error_x (x,
2498  _("'%s' ODO field item invalid here"),
2499  p->sister->name);
2500  }
2501  if (!p->sister->redefines) {
2502  if (!cb_complex_odo) {
2503  cb_error_x (x,
2504  _("'%s' cannot have OCCURS DEPENDING"),
2505  cb_name (x));
2506  break;
2507  }
2508  p->flag_odo_relative = 1;
2509  }
2510  }
2511  }
2512 
2513  /* If the field is GLOBAL, then the ODO must also be GLOBAL */
2514  if (q->flag_is_global && depfld) {
2515  if (!depfld->flag_is_global) {
2516  cb_error_x (x, _("'%s' ODO item must have GLOBAL attribute"),
2517  depfld->name);
2518  }
2519  }
2520  }
2522  cb_needs_01 = 0;
2523 
2524  for (l = current_program->file_list; l; l = CB_CHAIN (l)) {
2525  f = CB_FILE (CB_VALUE (l));
2526  if (CB_VALID_TREE(f->record_depending)) {
2527  x = f->record_depending;
2528  if (cb_ref (x) != cb_error_node) {
2529 #if 0 /* RXWRXW - This breaks old legacy programs */
2530  if (CB_REF_OR_FIELD_P(x)) {
2531  p = CB_FIELD_PTR (x);
2532  switch (p->storage) {
2533  case CB_STORAGE_WORKING:
2534  case CB_STORAGE_LOCAL:
2535  case CB_STORAGE_LINKAGE:
2536  break;
2537  default:
2538  cb_error (_("RECORD DEPENDING item must be in WORKING/LOCAL/LINKAGE section"));
2539  }
2540  } else {
2541 #endif
2542  if (!CB_REF_OR_FIELD_P(x)) {
2543  cb_error (_("Invalid RECORD DEPENDING item"));
2544  }
2545 #if 0 /* RXWRXW */
2546  }
2547 #endif
2548  }
2549  }
2550  }
2551 }
struct cb_literal * build_literal(const enum cb_category category, const void *data, const size_t size)
Definition: tree.c:722
const char * name
Definition: tree.h:645
cb_tree line_counter
Definition: tree.h:1215
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
size_t cb_needs_01
Definition: field.c:37
unsigned int odo_level
Definition: tree.h:687
#define CB_VALID_TREE(x)
Definition: tree.h:445
cb_tree report_list
Definition: tree.h:1262
#define CB_FIELD_ADD(x, y)
Definition: tree.h:1856
struct cb_field * sister
Definition: tree.h:653
#define CB_LITERAL(x)
Definition: tree.h:601
cb_tree cb_build_implicit_field(cb_tree name, const int len)
Definition: tree.c:2175
#define CB_FIELD_PTR(x)
Definition: tree.h:745
unsigned int flag_odo_relative
Definition: tree.h:731
cb_tree reference_list
Definition: tree.h:1255
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
cb_tree cb_build_field(cb_tree name)
Definition: tree.c:2159
struct cb_picture * pic
Definition: tree.h:659
#define COB_SMALL_BUFF
Definition: common.h:540
cb_tree cb_zero
Definition: tree.c:125
#define CB_PICTURE(x)
Definition: tree.h:631
cb_tree crt_status
Definition: tree.h:1287
#define COB_MINI_BUFF
Definition: common.h:539
char * cname
Definition: tree.h:1213
cb_tree file_list
Definition: tree.h:1252
unsigned char flag_is_global
Definition: tree.h:699
#define CB_FILE(x)
Definition: tree.h:858
cb_tree cb_build_picture(const char *str)
Definition: tree.c:1800
#define CB_VALUE(x)
Definition: tree.h:1193
cb_tree depending
Definition: tree.h:647
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
unsigned int flag_no_init
Definition: tree.h:727
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_NAME(x)
Definition: tree.h:904
cb_tree page_counter
Definition: tree.h:1216
void redefinition_error(cb_tree x)
Definition: error.c:284
Definition: tree.h:818
cb_tree cb_build_reference(const char *name)
Definition: tree.c:2572
void finalize_file(struct cb_file *f, struct cb_field *records)
Definition: tree.c:2409
cb_tree cb_error_node
Definition: tree.c:140
#define CB_ASSIGN_MF
Definition: cobc.h:77
struct cb_field * parent
Definition: tree.h:651
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98
struct cb_program * current_program
Definition: parser.c:168
cb_tree cursor_pos
Definition: tree.h:1286
const char * name
Definition: tree.h:1212
#define CB_REPORT(x)
Definition: tree.h:1228
#define CB_WORD_COUNT(x)
Definition: tree.h:905
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
#define CB_LIST_INIT(x)
Definition: tree.h:1851
struct cb_field * working_storage
Definition: tree.h:1276
cb_tree cb_depend_check
Definition: field.c:36
void cb_validate_field(struct cb_field *f)
Definition: field.c:1338
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
struct cb_field * redefines
Definition: tree.h:654
cb_tree values
Definition: tree.h:648
unsigned int flag_finalized
Definition: tree.h:849
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_field * check_level_78(const char *name)
Definition: scanner.c:4858
enum cb_usage usage
Definition: tree.h:693
cb_tree record_depending
Definition: tree.h:830
enum cb_storage storage
Definition: tree.h:692
#define CB_FIELD(x)
Definition: tree.h:740
#define COB_MINI_MAX
Definition: common.h:545

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_validate_program_environment ( struct cb_program prog)

Definition at line 1891 of file typeck.c.

References _, cb_program::alphabet_name_list, cb_alphabet_name::alphabet_type, cb_alphabet_name::alphachr, CB_ALPHABET_ASCII, CB_ALPHABET_EBCDIC, CB_ALPHABET_NAME, CB_ALPHABET_NAME_P, CB_ALPHABET_NATIVE, cb_build_symbolic_chars(), CB_CHAIN, CB_CLASS_NAME, cb_error_node, cb_error_x(), cb_high, cb_int1, CB_LIST_P, CB_LITERAL, CB_LITERAL_P, CB_LOCALE_NAME_P, cb_low, cb_name(), cb_norm_high, cb_norm_low, CB_NUMERIC_LITERAL_P, CB_PAIR_P, CB_PAIR_X, CB_PAIR_Y, CB_PURPOSE, cb_ref(), cb_validate_collating(), CB_VALUE, cb_warning_x(), cb_program::class_name_list, cb_program::classification, cob_refer_ascii, cob_refer_ebcdic, cb_program::collating_sequence, current_program, cb_alphabet_name::custom_list, get_value(), cb_alphabet_name::high_val_char, cb_class_name::list, cb_alphabet_name::low_val_char, NULL, cb_program::symbolic_char_list, and cb_alphabet_name::values.

Referenced by yyparse().

1892 {
1893  cb_tree x;
1894  cb_tree y;
1895  cb_tree l;
1896  cb_tree ls;
1897  struct cb_alphabet_name *ap;
1898  struct cb_class_name *cp;
1899  unsigned char *data;
1900  size_t dupls;
1901  size_t unvals;
1902  size_t count;
1903  int lower;
1904  int upper;
1905  int size;
1906  int n;
1907  int i;
1908  int lastval;
1909  int tableval;
1910  int values[256];
1911  int charvals[256];
1912 
1913  /* Check ALPHABET clauses */
1914  /* Complicated by difference between code set and collating sequence */
1915  for (l = current_program->alphabet_name_list; l; l = CB_CHAIN (l)) {
1916  ap = CB_ALPHABET_NAME (CB_VALUE (l));
1917 
1918  /* Native */
1919  if (ap->alphabet_type == CB_ALPHABET_NATIVE) {
1920  for (n = 0; n < 256; n++) {
1921  ap->values[n] = n;
1922  ap->alphachr[n] = n;
1923  }
1924  continue;
1925  }
1926 
1927  /* ASCII */
1928  if (ap->alphabet_type == CB_ALPHABET_ASCII) {
1929  for (n = 0; n < 256; n++) {
1930 #ifdef COB_EBCDIC_MACHINE
1931  ap->values[n] = (int)cob_refer_ascii[n];
1932  ap->alphachr[n] = (int)cob_refer_ascii[n];
1933 #else
1934  ap->values[n] = n;
1935  ap->alphachr[n] = n;
1936 #endif
1937  }
1938  continue;
1939  }
1940 
1941  /* EBCDIC */
1942  if (ap->alphabet_type == CB_ALPHABET_EBCDIC) {
1943  for (n = 0; n < 256; n++) {
1944 #ifdef COB_EBCDIC_MACHINE
1945  ap->values[n] = n;
1946  ap->alphachr[n] = n;
1947 #else
1948  ap->values[n] = (int)cob_refer_ebcdic[n];
1949  ap->alphachr[n] = (int)cob_refer_ebcdic[n];
1950 #endif
1951  }
1952  continue;
1953  }
1954 
1955  /* Custom alphabet */
1956  dupls = 0;
1957  unvals = 0;
1958  count = 0;
1959  lastval = 0;
1960  tableval = 0;
1961  for (n = 0; n < 256; n++) {
1962  values[n] = -1;
1963  charvals[n] = -1;
1964  ap->values[n] = -1;
1965  ap->alphachr[n] = -1;
1966  }
1967  ap->low_val_char = 0;
1968  ap->high_val_char = 255;
1969  for (y = ap->custom_list; y; y = CB_CHAIN (y)) {
1970  if (count > 255) {
1971  unvals = 1;
1972  break;
1973  }
1974  x = CB_VALUE (y);
1975  if (CB_PAIR_P (x)) {
1976  /* X THRU Y */
1977  lower = get_value (CB_PAIR_X (x));
1978  upper = get_value (CB_PAIR_Y (x));
1979  lastval = upper;
1980  if (!count) {
1981  ap->low_val_char = lower;
1982  }
1983  if (lower < 0 || lower > 255) {
1984  unvals = 1;
1985  continue;
1986  }
1987  if (upper < 0 || upper > 255) {
1988  unvals = 1;
1989  continue;
1990  }
1991  if (lower <= upper) {
1992  for (i = lower; i <= upper; i++) {
1993  if (values[i] != -1) {
1994  dupls = 1;
1995  }
1996  values[i] = i;
1997  charvals[i] = i;
1998  ap->alphachr[tableval] = i;
1999  ap->values[i] = tableval++;
2000  count++;
2001  }
2002  } else {
2003  for (i = lower; i >= upper; i--) {
2004  if (values[i] != -1) {
2005  dupls = 1;
2006  }
2007  values[i] = i;
2008  charvals[i] = i;
2009  ap->alphachr[tableval] = i;
2010  ap->values[i] = tableval++;
2011  count++;
2012  }
2013  }
2014  } else if (CB_LIST_P (x)) {
2015  /* X ALSO Y ... */
2016  if (!count) {
2017  ap->low_val_char = get_value (CB_VALUE (x));
2018  }
2019  for (ls = x; ls; ls = CB_CHAIN (ls)) {
2020  n = get_value (CB_VALUE (ls));
2021  if (!CB_CHAIN (ls)) {
2022  lastval = n;
2023  }
2024  if (n < 0 || n > 255) {
2025  unvals = 1;
2026  continue;
2027  }
2028  if (values[n] != -1) {
2029  dupls = 1;
2030  }
2031  values[n] = n;
2032  ap->values[n] = tableval;
2033  if (ls == x) {
2034  ap->alphachr[tableval] = n;
2035  charvals[n] = n;
2036  }
2037  count++;
2038  }
2039  tableval++;
2040  } else {
2041  /* Literal */
2042  if (CB_NUMERIC_LITERAL_P (x)) {
2043  n = get_value (x);
2044  lastval = n;
2045  if (!count) {
2046  ap->low_val_char = n;
2047  }
2048  if (n < 0 || n > 255) {
2049  unvals = 1;
2050  continue;
2051  }
2052  if (values[n] != -1) {
2053  dupls = 1;
2054  }
2055  values[n] = n;
2056  charvals[n] = n;
2057  ap->alphachr[tableval] = n;
2058  ap->values[n] = tableval++;
2059  count++;
2060  } else if (CB_LITERAL_P (x)) {
2061  size = (int)CB_LITERAL (x)->size;
2062  data = CB_LITERAL (x)->data;
2063  if (!count) {
2064  ap->low_val_char = data[0];
2065  }
2066  lastval = data[size - 1];
2067  for (i = 0; i < size; i++) {
2068  n = data[i];
2069  if (values[n] != -1) {
2070  dupls = 1;
2071  }
2072  values[n] = n;
2073  charvals[n] = n;
2074  ap->alphachr[tableval] = n;
2075  ap->values[n] = tableval++;
2076  count++;
2077  }
2078  } else {
2079  n = get_value (x);
2080  lastval = n;
2081  if (!count) {
2082  ap->low_val_char = n;
2083  }
2084  if (n < 0 || n > 255) {
2085  unvals = 1;
2086  continue;
2087  }
2088  if (values[n] != -1) {
2089  dupls = 1;
2090  }
2091  values[n] = n;
2092  charvals[n] = n;
2093  ap->alphachr[tableval] = n;
2094  ap->values[n] = tableval++;
2095  count++;
2096  }
2097  }
2098  }
2099  if (dupls || unvals) {
2100  if (dupls) {
2101  cb_error_x (l, _("Duplicate character values in alphabet '%s'"),
2102  cb_name (CB_VALUE(l)));
2103  }
2104  if (unvals) {
2105  cb_error_x (l, _("Invalid character values in alphabet '%s'"),
2106  cb_name (CB_VALUE(l)));
2107  }
2108  ap->low_val_char = 0;
2109  ap->high_val_char = 255;
2110  continue;
2111  }
2112  /* Calculate HIGH-VALUE */
2113  /* If all 256 values have been specified, */
2114  /* HIGH-VALUE is the last one */
2115  /* Otherwise if HIGH-VALUE has been specified, find the highest */
2116  /* value that has not been used */
2117  if (count == 256) {
2118  ap->high_val_char = lastval;
2119  } else if (values[255] != -1) {
2120  for (n = 254; n >= 0; n--) {
2121  if (values[n] == -1) {
2122  ap->high_val_char = n;
2123  break;
2124  }
2125  }
2126  }
2127 
2128  /* Get rest of code set */
2129  for (n = tableval; n < 256; ++n) {
2130  for (i = 0; i < 256; ++i) {
2131  if (charvals[i] < 0) {
2132  charvals[i] = 0;
2133  ap->alphachr[n] = i;
2134  break;
2135  }
2136  }
2137  }
2138 
2139  /* Fill in missing characters */
2140  for (n = 0; n < 256; n++) {
2141  if (ap->values[n] < 0) {
2142  ap->values[n] = tableval++;
2143  }
2144  }
2145  }
2146 
2147  /* Reset HIGH/LOW-VALUES */
2148  cb_low = cb_norm_low;
2150 
2151  /* Check and generate SYMBOLIC clauses */
2152  for (l = current_program->symbolic_char_list; l; l = CB_CHAIN (l)) {
2153  if (CB_VALUE (l)) {
2154  y = cb_ref (CB_VALUE (l));
2155  if (y == cb_error_node) {
2156  continue;
2157  }
2158  if (!CB_ALPHABET_NAME_P (y)) {
2159  cb_error_x (y, _("Invalid ALPHABET name"));
2160  continue;
2161  }
2162  } else {
2163  y = NULL;
2164  }
2166  }
2167 
2168  /* Check CLASS clauses */
2169  for (l = current_program->class_name_list; l; l = CB_CHAIN (l)) {
2170  dupls = 0;
2171  memset (values, 0, sizeof(values));
2172  cp = CB_CLASS_NAME (CB_VALUE (l));
2173  for (y = cp->list; y; y = CB_CHAIN (y)) {
2174  x = CB_VALUE (y);
2175  if (CB_PAIR_P (x)) {
2176  /* X THRU Y */
2177  lower = get_value (CB_PAIR_X (x));
2178  upper = get_value (CB_PAIR_Y (x));
2179  for (i = lower; i <= upper; i++) {
2180  if (values[i]) {
2181  dupls = 1;
2182  }
2183  values[i] = 1;
2184  }
2185  } else {
2186  if (CB_NUMERIC_LITERAL_P (x)) {
2187  n = get_value (x);
2188  if (values[n]) {
2189  dupls = 1;
2190  }
2191  values[n] = 1;
2192  } else if (CB_LITERAL_P (x)) {
2193  size = (int)CB_LITERAL (x)->size;
2194  data = CB_LITERAL (x)->data;
2195  for (i = 0; i < size; i++) {
2196  n = data[i];
2197  if (values[n]) {
2198  dupls = 1;
2199  }
2200  values[n] = 1;
2201  }
2202  } else {
2203  n = get_value (x);
2204  if (values[n]) {
2205  dupls = 1;
2206  }
2207  values[n] = 1;
2208  }
2209  }
2210  }
2211  if (dupls) {
2212  if (!cb_relaxed_syntax_check) {
2213  cb_error_x (CB_VALUE(l),
2214  _("Duplicate values in class '%s'"),
2215  cb_name (CB_VALUE(l)));
2216  } else {
2217  cb_warning_x (CB_VALUE(l),
2218  _("Duplicate values in class '%s'"),
2219  cb_name (CB_VALUE(l)));
2220  }
2221  }
2222  }
2223 
2224  /* Resolve the program collating sequence */
2225  if (prog->collating_sequence) {
2226  cb_validate_collating (prog);
2227  }
2228 
2229  /* Resolve the program classification */
2230  if (prog->classification && prog->classification != cb_int1) {
2231  x = cb_ref (prog->classification);
2232  if (!CB_LOCALE_NAME_P (x)) {
2233  cb_error_x (prog->classification,
2234  _("'%s' is not a locale name"),
2235  cb_name (prog->classification));
2236  prog->classification = NULL;
2237  return;
2238  }
2239  }
2240 }
#define CB_NUMERIC_LITERAL_P(x)
Definition: tree.h:603
#define CB_PAIR_X(x)
Definition: tree.h:1205
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_int1
Definition: tree.c:134
#define CB_PAIR_P(x)
Definition: tree.h:1204
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
cb_tree cb_norm_high
Definition: tree.c:131
#define CB_LITERAL(x)
Definition: tree.h:601
static const unsigned char cob_refer_ebcdic[256]
Definition: typeck.c:242
cb_tree cb_norm_low
Definition: tree.c:130
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_PAIR_Y(x)
Definition: tree.h:1206
#define CB_ALPHABET_ASCII
Definition: tree.h:108
void cb_build_symbolic_chars(const cb_tree sym_list, const cb_tree alphabet)
Definition: tree.c:2289
#define CB_ALPHABET_NATIVE
Definition: tree.h:107
#define CB_PURPOSE(x)
Definition: tree.h:1192
static int get_value(cb_tree x)
Definition: typeck.c:1843
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define CB_VALUE(x)
Definition: tree.h:1193
int alphachr[256]
Definition: tree.h:547
#define CB_ALPHABET_NAME(x)
Definition: tree.h:550
#define _(s)
Definition: cobcrun.c:59
int high_val_char
Definition: tree.h:545
#define CB_CHAIN(x)
Definition: tree.h:1194
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
cb_tree alphabet_name_list
Definition: tree.h:1256
int values[256]
Definition: tree.h:546
#define CB_LOCALE_NAME_P(x)
Definition: tree.h:575
cb_tree cb_error_node
Definition: tree.c:140
cb_tree class_name_list
Definition: tree.h:1258
#define CB_LIST_P(x)
Definition: tree.h:1190
struct cb_program * current_program
Definition: parser.c:168
int low_val_char
Definition: tree.h:544
cb_tree collating_sequence
Definition: tree.h:1284
cb_tree classification
Definition: tree.h:1285
static void cb_validate_collating(struct cb_program *prog)
Definition: typeck.c:1864
cb_tree cb_high
Definition: tree.c:129
#define CB_ALPHABET_NAME_P(x)
Definition: tree.h:551
#define CB_CLASS_NAME(x)
Definition: tree.h:562
unsigned int alphabet_type
Definition: tree.h:543
#define CB_ALPHABET_EBCDIC
Definition: tree.h:109
static const unsigned char cob_refer_ascii[256]
Definition: typeck.c:206
cb_tree cb_low
Definition: tree.c:128
cb_tree symbolic_char_list
Definition: tree.h:1257
cb_tree custom_list
Definition: tree.h:542
cb_tree list
Definition: tree.h:559

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int check_valid_key ( const struct cb_file cbf,
const struct cb_field f 
)
static

Definition at line 8366 of file typeck.c.

References _, cb_file::alt_key_list, cb_error_node, cb_error_x(), cb_field_founder(), CB_FIELD_PTR, cb_ref(), CB_TREE, COB_ORG_INDEXED, current_statement, f1, cb_alt_key::key, cb_file::key, cb_alt_key::next, cb_field::offset, cb_file::organization, cb_file::record, and cb_field::sister.

Referenced by cb_emit_start().

8367 {
8368  cb_tree kfld;
8369  struct cb_alt_key *cbak;
8370  struct cb_field *f1;
8371  struct cb_field *ff;
8372 
8373  if (cbf->organization != COB_ORG_INDEXED) {
8374  if (CB_FIELD_PTR (cbf->key) != f) {
8376  _("Invalid key item"));
8377  return 1;
8378  }
8379  return 0;
8380  }
8381 
8382  ff = cb_field_founder (f);
8383  for (f1 = cbf->record; f1; f1 = f1->sister) {
8384  if (f1 == ff) {
8385  break;
8386  }
8387  }
8388  if (!f1) {
8389  cb_error_x (CB_TREE (current_statement), _("Invalid key item"));
8390  return 1;
8391  }
8392 
8393  kfld = cb_ref (cbf->key);
8394  if (kfld == cb_error_node) {
8395  return 1;
8396  }
8397  if (f->offset == CB_FIELD_PTR (kfld)->offset) {
8398  return 0;
8399  }
8400  for (cbak = cbf->alt_key_list; cbak; cbak = cbak->next) {
8401  kfld = cb_ref (cbak->key);
8402  if (kfld == cb_error_node) {
8403  return 1;
8404  }
8405  if (f->offset == CB_FIELD_PTR (kfld)->offset) {
8406  return 0;
8407  }
8408  }
8409  cb_error_x (CB_TREE (current_statement), _("Invalid key item"));
8410  return 1;
8411 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
struct cb_field * sister
Definition: tree.h:653
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define COB_ORG_INDEXED
Definition: common.h:745
struct cb_alt_key * next
Definition: tree.h:812
int offset
Definition: tree.h:675
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
cob_field f1
Definition: cobxref.c.l.h:54
cb_tree cb_error_node
Definition: tree.c:140
cb_tree key
Definition: tree.h:813
struct cb_field * record
Definition: tree.h:829
int organization
Definition: tree.h:844
cb_tree key
Definition: tree.h:826
struct cb_alt_key * alt_key_list
Definition: tree.h:827
struct cb_statement * current_statement
Definition: parser.c:169
struct cb_field * cb_field_founder(const struct cb_field *f)
Definition: tree.c:2227

Here is the call graph for this function:

Here is the caller graph for this function:

static void cob_put_sign_ebcdic ( unsigned char *  p,
const int  sign 
)
static

Definition at line 6959 of file typeck.c.

Referenced by cb_build_move_literal().

6960 {
6961  if (sign < 0) {
6962  switch (*p) {
6963  case '0':
6964  *p = (unsigned char)'}';
6965  return;
6966  case '1':
6967  *p = (unsigned char)'J';
6968  return;
6969  case '2':
6970  *p = (unsigned char)'K';
6971  return;
6972  case '3':
6973  *p = (unsigned char)'L';
6974  return;
6975  case '4':
6976  *p = (unsigned char)'M';
6977  return;
6978  case '5':
6979  *p = (unsigned char)'N';
6980  return;
6981  case '6':
6982  *p = (unsigned char)'O';
6983  return;
6984  case '7':
6985  *p = (unsigned char)'P';
6986  return;
6987  case '8':
6988  *p = (unsigned char)'Q';
6989  return;
6990  case '9':
6991  *p = (unsigned char)'R';
6992  return;
6993  default:
6994  /* What to do here */
6995  *p = (unsigned char)'}';
6996  return;
6997  }
6998  }
6999  switch (*p) {
7000  case '0':
7001  *p = (unsigned char)'{';
7002  return;
7003  case '1':
7004  *p = (unsigned char)'A';
7005  return;
7006  case '2':
7007  *p = (unsigned char)'B';
7008  return;
7009  case '3':
7010  *p = (unsigned char)'C';
7011  return;
7012  case '4':
7013  *p = (unsigned char)'D';
7014  return;
7015  case '5':
7016  *p = (unsigned char)'E';
7017  return;
7018  case '6':
7019  *p = (unsigned char)'F';
7020  return;
7021  case '7':
7022  *p = (unsigned char)'G';
7023  return;
7024  case '8':
7025  *p = (unsigned char)'H';
7026  return;
7027  case '9':
7028  *p = (unsigned char)'I';
7029  return;
7030  default:
7031  /* What to do here */
7032  *p = (unsigned char)'{';
7033  return;
7034  }
7035 }
if sign
Definition: flag.def:42

Here is the caller graph for this function:

void cobc_init_typeck ( void  )

Definition at line 8747 of file typeck.c.

References expr_prio, pvalid_char, and valid_char.

Referenced by main().

8748 {
8749  const unsigned char *p;
8750 
8751  memset (valid_char, 0, sizeof(valid_char));
8752  for (p = pvalid_char; *p; ++p) {
8753  valid_char[*p] = 1;
8754  }
8755  memset(expr_prio, 0, sizeof(expr_prio));
8756  expr_prio['x' & 0xFF] = 0;
8757  expr_prio['^' & 0xFF] = 1;
8758  expr_prio['*' & 0xFF] = 2;
8759  expr_prio['/' & 0xFF] = 2;
8760  expr_prio['+' & 0xFF] = 3;
8761  expr_prio['-' & 0xFF] = 3;
8762  expr_prio['=' & 0xFF] = 4;
8763  expr_prio['~' & 0xFF] = 4;
8764  expr_prio['<' & 0xFF] = 4;
8765  expr_prio['>' & 0xFF] = 4;
8766  expr_prio['[' & 0xFF] = 4;
8767  expr_prio[']' & 0xFF] = 4;
8768  expr_prio['!' & 0xFF] = 5;
8769  expr_prio['&' & 0xFF] = 6;
8770  expr_prio['|' & 0xFF] = 7;
8771  expr_prio[')' & 0xFF] = 8;
8772  expr_prio['(' & 0xFF] = 9;
8773  expr_prio[0] = 10;
8774 }
static const unsigned char pvalid_char[]
Definition: typeck.c:201
static unsigned char valid_char[256]
Definition: typeck.c:200
static unsigned char expr_prio[256]
Definition: typeck.c:199

Here is the caller graph for this function:

static int count_pic_alphanumeric_edited ( struct cb_field field)
static

Definition at line 6060 of file typeck.c.

References cb_field::count, cb_field::pic, and cb_picture::str.

Referenced by validate_move().

6061 {
6062  unsigned char *p;
6063  int count;
6064  int repeat;
6065 
6066  /* Count number of free places in an alphanumeric edited field */
6067  count = 0;
6068  for (p = (unsigned char *)(field->pic->str); *p; p += 5) {
6069  if (*p == '9' || *p == 'A' || *p == 'X') {
6070  memcpy ((void *)&repeat, p + 1, sizeof(int));
6071  count += repeat;
6072  }
6073  }
6074  return count;
6075 }
char * str
Definition: tree.h:621
struct cb_picture * pic
Definition: tree.h:659
int count
Definition: tree.h:680

Here is the caller graph for this function:

static cb_tree decimal_alloc ( void  )
static

Definition at line 3229 of file typeck.c.

References _, cb_build_decimal(), COB_MAX_DEC_STRUCT, COBC_ABORT, cobc_abort_pr(), current_program, current_statement, cb_program::decimal_index, cb_program::decimal_index_max, and cb_statement::name.

Referenced by build_decimal_assign(), cb_build_cond(), and decimal_expand().

3230 {
3231  cb_tree x;
3232 
3236  cobc_abort_pr (_("Internal decimal structure size exceeded - %d"),
3238  if (strcmp(current_statement->name, "COMPUTE") == 0) {
3239  cobc_abort_pr (_("Try to minimize the number of parenthesis "
3240  "or split into multiple computations."));
3241  }
3242  COBC_ABORT ();
3243  }
3246  }
3247  return x;
3248 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define COB_MAX_DEC_STRUCT
Definition: common.h:571
int decimal_index
Definition: tree.h:1293
cb_tree cb_build_decimal(const int id)
Definition: tree.c:1770
const char * name
Definition: tree.h:1137
int decimal_index_max
Definition: tree.h:1294
#define _(s)
Definition: cobcrun.c:59
#define COBC_ABORT()
Definition: cobc.h:61
struct cb_program * current_program
Definition: parser.c:168
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

static void decimal_assign ( cb_tree  x,
cb_tree  d,
cb_tree  round_opt 
)
static

Definition at line 3361 of file typeck.c.

References build_store_option(), CB_BUILD_FUNCALL_3, and dpush.

Referenced by build_decimal_assign().

3362 {
3363  dpush (CB_BUILD_FUNCALL_3 ("cob_decimal_get_field", d, x,
3364  build_store_option (x, round_opt)));
3365 }
#define dpush(x)
Definition: typeck.c:73
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
static cb_tree build_store_option(cb_tree x, cb_tree round_opt)
Definition: typeck.c:3193

Here is the call graph for this function:

Here is the caller graph for this function:

static void decimal_compute ( const int  op,
cb_tree  x,
cb_tree  y 
)
static

Definition at line 3257 of file typeck.c.

References _, CB_BUILD_FUNCALL_2, COBC_ABORT, cobc_abort_pr(), and dpush.

Referenced by build_decimal_assign(), and decimal_expand().

3258 {
3259  const char *func;
3260 
3261  switch (op) {
3262  case '+':
3263  func = "cob_decimal_add";
3264  break;
3265  case '-':
3266  func = "cob_decimal_sub";
3267  break;
3268  case '*':
3269  func = "cob_decimal_mul";
3270  break;
3271  case '/':
3272  func = "cob_decimal_div";
3273  break;
3274  case '^':
3275  func = "cob_decimal_pow";
3276  break;
3277  default:
3278  cobc_abort_pr (_("Unexpected operation %d"), op);
3279  COBC_ABORT ();
3280  }
3281  dpush (CB_BUILD_FUNCALL_2 (func, x, y));
3282 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define dpush(x)
Definition: typeck.c:73
#define _(s)
Definition: cobcrun.c:59
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
#define COBC_ABORT()
Definition: cobc.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

static void decimal_expand ( cb_tree  d,
cb_tree  x 
)
static

Definition at line 3285 of file typeck.c.

References _, CB_BINARY_OP, cb_build_cast_llint(), CB_BUILD_FUNCALL_1, CB_BUILD_FUNCALL_2, CB_BUILD_STRING0, cb_emit, CB_EXCEPTION_ENABLE, CB_FIELD_PTR, cb_int0, CB_LITERAL, CB_TAG_BINARY_OP, CB_TAG_CONST, CB_TAG_INTRINSIC, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE_TAG, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_6, CB_USAGE_COMP_X, CB_USAGE_DISPLAY, CB_USAGE_INDEX, CB_USAGE_PACKED, cb_zero, COB_EC_DATA_INCOMPATIBLE, COBC_ABORT, cobc_abort_pr(), decimal_alloc(), decimal_compute(), decimal_free(), dpush, cb_field::name, cb_binary_op::op, cb_field::pic, cb_literal::scale, cb_picture::scale, cb_literal::size, cb_field::size, cb_field::usage, cb_binary_op::x, and cb_binary_op::y.

Referenced by build_decimal_assign(), and cb_build_cond().

3286 {
3287  struct cb_literal *l;
3288  struct cb_field *f;
3289  struct cb_binary_op *p;
3290  cb_tree t;
3291 
3292  switch (CB_TREE_TAG (x)) {
3293  case CB_TAG_CONST:
3294  if (x == cb_zero) {
3295  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_llint", d,
3296  cb_int0));
3297  } else {
3298  cobc_abort_pr (_("Unexpected constant expansion"));
3299  COBC_ABORT ();
3300  }
3301  break;
3302  case CB_TAG_LITERAL:
3303  /* Set d, N */
3304  l = CB_LITERAL (x);
3305  if (l->size < 19 && l->scale == 0) {
3306  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_llint", d,
3307  cb_build_cast_llint (x)));
3308  } else {
3309  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_field", d, x));
3310  }
3311  break;
3312  case CB_TAG_REFERENCE:
3313  /* Set d, X */
3314  f = CB_FIELD_PTR (x);
3315  /* Check numeric */
3316  if (cb_flag_correct_numeric && f->usage == CB_USAGE_DISPLAY) {
3317  cb_emit (CB_BUILD_FUNCALL_1 ("cob_correct_numeric", x));
3318  }
3320  if (f->usage == CB_USAGE_DISPLAY ||
3321  f->usage == CB_USAGE_PACKED ||
3322  f->usage == CB_USAGE_COMP_6) {
3323  dpush (CB_BUILD_FUNCALL_2 ("cob_check_numeric",
3324  x, CB_BUILD_STRING0 (f->name)));
3325  }
3326  }
3327 
3328  if ((f->usage == CB_USAGE_BINARY ||
3329  f->usage == CB_USAGE_COMP_5 ||
3330  f->usage == CB_USAGE_INDEX ||
3331  f->usage == CB_USAGE_COMP_X) &&
3332  !f->pic->scale &&
3333  (f->size == 1 || f->size == 2 || f->size == 4 ||
3334  f->size == 8)) {
3335  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_llint", d, cb_build_cast_llint (x)));
3336  } else {
3337  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_field", d, x));
3338  }
3339  break;
3340  case CB_TAG_BINARY_OP:
3341  /* Set d, X
3342  * Set t, Y
3343  * OP d, t */
3344  p = CB_BINARY_OP (x);
3345  decimal_expand (d, p->x);
3346  t = decimal_alloc ();
3347  decimal_expand (t, p->y);
3348  decimal_compute (p->op, d, t);
3349  decimal_free ();
3350  break;
3351  case CB_TAG_INTRINSIC:
3352  dpush (CB_BUILD_FUNCALL_2 ("cob_decimal_set_field", d, x));
3353  break;
3354  default:
3355  cobc_abort_pr (_("Unexpected tree tag %d"), (int)CB_TREE_TAG (x));
3356  COBC_ABORT ();
3357  }
3358 }
const char * name
Definition: tree.h:645
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
int scale
Definition: tree.h:626
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_FIELD_PTR(x)
Definition: tree.h:745
struct cb_picture * pic
Definition: tree.h:659
#define CB_BUILD_FUNCALL_1(f, a1)
Definition: tree.h:1799
cb_tree cb_zero
Definition: tree.c:125
static void decimal_expand(cb_tree d, cb_tree x)
Definition: typeck.c:3285
#define dpush(x)
Definition: typeck.c:73
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
static void decimal_free(void)
Definition: typeck.c:3251
static cb_tree decimal_alloc(void)
Definition: typeck.c:3229
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
int scale
Definition: tree.h:595
int op
Definition: tree.h:932
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define COBC_ABORT()
Definition: cobc.h:61
cb_tree cb_int0
Definition: tree.c:133
cb_tree cb_build_cast_llint(const cb_tree val)
Definition: tree.c:2975
int size
Definition: tree.h:672
cb_tree y
Definition: tree.h:931
static void decimal_compute(const int op, cb_tree x, cb_tree y)
Definition: typeck.c:3257
#define CB_BUILD_STRING0(str)
Definition: tree.h:1849
#define CB_EXCEPTION_ENABLE(id)
Definition: cobc.h:243
cb_tree x
Definition: tree.h:930
#define CB_BINARY_OP(x)
Definition: tree.h:936
#define cb_emit(x)
Definition: typeck.c:75
cob_u32_t size
Definition: tree.h:594
enum cb_usage usage
Definition: tree.h:693

Here is the call graph for this function:

Here is the caller graph for this function:

static void decimal_free ( void  )
static

Definition at line 3251 of file typeck.c.

References current_program, and cb_program::decimal_index.

Referenced by build_decimal_assign(), cb_build_cond(), and decimal_expand().

3252 {
3254 }
int decimal_index
Definition: tree.h:1293
struct cb_program * current_program
Definition: parser.c:168

Here is the caller graph for this function:

static unsigned int emit_corresponding ( cb_tree(*)(cb_tree f1, cb_tree f2, cb_tree f3 func,
cb_tree  x1,
cb_tree  x2,
cb_tree  opt 
)
static

Definition at line 4093 of file typeck.c.

References cb_build_field_reference(), cb_emit, CB_FIELD_PTR, cb_field::children, f1, f2, cb_field::flag_occurs, cb_field::name, cb_field::redefines, and cb_field::sister.

Referenced by cb_emit_corresponding().

4095 {
4096  struct cb_field *f1, *f2;
4097  cb_tree t1;
4098  cb_tree t2;
4099  unsigned int found;
4100 
4101  found = 0;
4102  for (f1 = CB_FIELD_PTR (x1)->children; f1; f1 = f1->sister) {
4103  if (!f1->redefines && !f1->flag_occurs) {
4104  for (f2 = CB_FIELD_PTR (x2)->children; f2; f2 = f2->sister) {
4105  if (!f2->redefines && !f2->flag_occurs) {
4106  if (strcmp (f1->name, f2->name) == 0) {
4107  t1 = cb_build_field_reference (f1, x1);
4108  t2 = cb_build_field_reference (f2, x2);
4109  if (f1->children && f2->children) {
4110  found += emit_corresponding (func, t1, t2, opt);
4111  } else {
4112  found++;
4113  cb_emit (func (t1, t2, opt));
4114  }
4115  }
4116  }
4117  }
4118  }
4119  }
4120  return found;
4121 }
const char * name
Definition: tree.h:645
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
cob_field f2
Definition: cobxref.c.l.h:55
Definition: tree.h:643
cob_field f1
Definition: cobxref.c.l.h:54
unsigned int flag_occurs
Definition: tree.h:702
static unsigned int emit_corresponding(cb_tree(*func)(cb_tree f1, cb_tree f2, cb_tree f3), cb_tree x1, cb_tree x2, cb_tree opt)
Definition: typeck.c:4093
#define cb_emit(x)
Definition: typeck.c:75
struct cb_field * redefines
Definition: tree.h:654

Here is the call graph for this function:

Here is the caller graph for this function:

static void emit_field_display ( const cb_tree  x,
const cb_tree  pos,
const cb_tree  fgc,
const cb_tree  bgc,
const cb_tree  scroll,
const cb_tree  size_is,
const int  dispattrs 
)
static

Definition at line 5202 of file typeck.c.

References CB_BUILD_FUNCALL_8, cb_emit, cb_int(), get_line_and_column_from_pos(), line, and NULL.

Referenced by cb_emit_display().

5205 {
5206  cb_tree line = NULL;
5207  cb_tree column = NULL;
5208 
5209  get_line_and_column_from_pos (pos, &line, &column);
5210  cb_emit (CB_BUILD_FUNCALL_8 ("cob_field_display",
5211  x, line, column, fgc, bgc,
5212  scroll, size_is,
5213  cb_int (dispattrs)));
5214 }
static void get_line_and_column_from_pos(const cb_tree pos, cb_tree *const line, cb_tree *const column)
Definition: typeck.c:5173
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_BUILD_FUNCALL_8(f, a1, a2, a3, a4, a5, a6, a7, a8)
Definition: tree.h:1827
cb_tree cb_int(const int n)
Definition: tree.c:1488
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int emit_move_corresponding ( cb_tree  x1,
cb_tree  x2 
)
static

Definition at line 4145 of file typeck.c.

References cb_build_field_reference(), cb_build_move(), cb_emit, CB_FIELD_PTR, cb_field::children, f1, f2, cb_field::flag_occurs, cb_field::name, cb_field::redefines, and cb_field::sister.

Referenced by cb_emit_move_corresponding().

4146 {
4147  struct cb_field *f1, *f2;
4148  cb_tree t1;
4149  cb_tree t2;
4150  unsigned int found;
4151 
4152  found = 0;
4153  for (f1 = CB_FIELD_PTR (x1)->children; f1; f1 = f1->sister) {
4154  if (!f1->redefines && !f1->flag_occurs) {
4155  for (f2 = CB_FIELD_PTR (x2)->children; f2; f2 = f2->sister) {
4156  if (!f2->redefines && !f2->flag_occurs) {
4157  if (strcmp (f1->name, f2->name) == 0) {
4158  t1 = cb_build_field_reference (f1, x1);
4159  t2 = cb_build_field_reference (f2, x2);
4160  if (f1->children && f2->children) {
4161  found += emit_move_corresponding (t1, t2);
4162  } else {
4163  cb_emit (cb_build_move (t1, t2));
4164  found++;
4165  }
4166  }
4167  }
4168  }
4169  }
4170  }
4171  return found;
4172 }
const char * name
Definition: tree.h:645
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
cb_tree cb_build_move(cb_tree src, cb_tree dst)
Definition: typeck.c:7333
#define CB_FIELD_PTR(x)
Definition: tree.h:745
static unsigned int emit_move_corresponding(cb_tree x1, cb_tree x2)
Definition: typeck.c:4145
cb_tree cb_build_field_reference(struct cb_field *f, cb_tree ref)
Definition: tree.c:2604
cob_field f2
Definition: cobxref.c.l.h:55
Definition: tree.h:643
cob_field f1
Definition: cobxref.c.l.h:54
unsigned int flag_occurs
Definition: tree.h:702
#define cb_emit(x)
Definition: typeck.c:75
struct cb_field * redefines
Definition: tree.h:654

Here is the call graph for this function:

Here is the caller graph for this function:

static void emit_screen_display ( const cb_tree  x,
const cb_tree  pos 
)
static

Definition at line 5192 of file typeck.c.

References CB_BUILD_FUNCALL_3, cb_emit, get_line_and_column_from_pos(), line, and NULL.

Referenced by cb_emit_display().

5193 {
5194  cb_tree line = NULL;
5195  cb_tree column = NULL;
5196 
5197  get_line_and_column_from_pos (pos, &line, &column);
5198  cb_emit (CB_BUILD_FUNCALL_3 ("cob_screen_display", x, line, column));
5199 }
static void get_line_and_column_from_pos(const cb_tree pos, cb_tree *const line, cb_tree *const column)
Definition: typeck.c:5173
#define CB_BUILD_FUNCALL_3(f, a1, a2, a3)
Definition: tree.h:1807
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
#define cb_emit(x)
Definition: typeck.c:75

Here is the call graph for this function:

Here is the caller graph for this function:

static cb_tree evaluate_test ( cb_tree  s,
cb_tree  o 
)
static

Definition at line 5430 of file typeck.c.

References _, cb_any, cb_build_binary_op(), CB_BUILD_NEGATION, cb_error_x(), cb_false, CB_FIELD, CB_FIELD_P, CB_PAIR_X, CB_PAIR_Y, CB_PURPOSE_INT, CB_REFERENCE, CB_REFERENCE_P, CB_TREE, cb_true, CB_VALUE, current_statement, NULL, and value.

Referenced by build_evaluate().

5431 {
5432  cb_tree x;
5433  cb_tree y;
5434  cb_tree t;
5435  int flag;
5436 
5437  /* ANY is always true */
5438  if (o == cb_any) {
5439  return cb_true;
5440  }
5441 
5442  /* Object TRUE or FALSE */
5443  if (o == cb_true) {
5444  return s;
5445  }
5446  if (o == cb_false) {
5447  return CB_BUILD_NEGATION (s);
5448  }
5449 
5450  flag = CB_PURPOSE_INT (o);
5451  x = CB_PAIR_X (CB_VALUE (o));
5452  y = CB_PAIR_Y (CB_VALUE (o));
5453 
5454  /* Subject TRUE or FALSE */
5455  if (s == cb_true) {
5456  return flag ? CB_BUILD_NEGATION (x) : x;
5457  }
5458  if (s == cb_false) {
5459  return flag ? x : CB_BUILD_NEGATION (x);
5460  }
5461 
5462  /* x THRU y */
5463  if (y) {
5464  t = cb_build_binary_op (cb_build_binary_op (x, '[', s),
5465  '&',
5466  cb_build_binary_op (s, '[', y));
5467 
5468  return flag ? CB_BUILD_NEGATION (t) : t;
5469  }
5470 
5471  if (CB_REFERENCE_P(x) && CB_FIELD_P(CB_REFERENCE(x)->value) &&
5472  CB_FIELD(CB_REFERENCE(x)->value)->level == 88) {
5474  _("Invalid use of 88 level in WHEN expression"));
5475  return NULL;
5476  }
5477 
5478  /* Regular comparison */
5479  switch (flag) {
5480  case 0:
5481  /* Equal comparison */
5482  return cb_build_binary_op (s, '=', x);
5483  case 1:
5484  /* Unequal comparison */
5485  return cb_build_binary_op (s, '~', x);
5486  default:
5487  /* Class and relational conditions */
5488  return x;
5489  }
5490 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree cb_true
Definition: tree.c:122
#define CB_PURPOSE_INT(x)
Definition: tree.h:1197
#define CB_PAIR_Y(x)
Definition: tree.h:1206
cb_tree cb_false
Definition: tree.c:123
cb_tree cb_any
Definition: tree.c:121
int level
Definition: tree.h:673
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
#define CB_VALUE(x)
Definition: tree.h:1193
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
struct cb_statement * current_statement
Definition: parser.c:169
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static int expr_chk_cond ( cb_tree  expr_1,
cb_tree  expr_2 
)
static

Definition at line 2731 of file typeck.c.

References CB_CAST, CB_CAST_ADDR_OF_ADDR, CB_CAST_ADDRESS, CB_CAST_P, CB_CAST_PROGRAM_POINTER, CB_FIELD_PTR, cb_null, CB_REF_OR_FIELD_P, f1, f2, cb_field::flag_is_pointer, and cb_field::level.

Referenced by expr_reduce().

2732 {
2733  struct cb_field *f1;
2734  struct cb_field *f2;
2735  int is_ptr_1;
2736  int is_ptr_2;
2737 
2738  /* 88 level is invalid here */
2739  /* Likewise combination of pointer and non-pointer */
2740  is_ptr_1 = 0;
2741  is_ptr_2 = 0;
2742  if (CB_REF_OR_FIELD_P (expr_1)) {
2743  f1 = CB_FIELD_PTR (expr_1);
2744  if (f1->level == 88) {
2745  return 1;
2746  }
2747  if (f1->flag_is_pointer) {
2748  is_ptr_1 = 1;
2749  }
2750  } else if (CB_CAST_P (expr_1)) {
2751  switch (CB_CAST (expr_1)->cast_type) {
2752  case CB_CAST_ADDRESS:
2753  case CB_CAST_ADDR_OF_ADDR:
2755  is_ptr_1 = 1;
2756  break;
2757  default:
2758  break;
2759  }
2760  } else if (expr_1 == cb_null) {
2761  is_ptr_1 = 1;
2762  }
2763  if (CB_REF_OR_FIELD_P (expr_2)) {
2764  f2 = CB_FIELD_PTR (expr_2);
2765  if (f2->level == 88) {
2766  return 1;
2767  }
2768  if (f2->flag_is_pointer) {
2769  is_ptr_2 = 1;
2770  }
2771  } else if (CB_CAST_P (expr_2)) {
2772  switch (CB_CAST (expr_2)->cast_type) {
2773  case CB_CAST_ADDRESS:
2774  case CB_CAST_ADDR_OF_ADDR:
2776  is_ptr_2 = 1;
2777  break;
2778  default:
2779  break;
2780  }
2781  } else if (expr_2 == cb_null) {
2782  is_ptr_2 = 1;
2783  }
2784  return is_ptr_1 ^ is_ptr_2;
2785 }
unsigned int flag_is_pointer
Definition: tree.h:710
#define CB_CAST_P(x)
Definition: tree.h:963
#define CB_FIELD_PTR(x)
Definition: tree.h:745
#define CB_CAST(x)
Definition: tree.h:962
cob_field f2
Definition: cobxref.c.l.h:55
int level
Definition: tree.h:673
Definition: tree.h:643
cob_field f1
Definition: cobxref.c.l.h:54
cb_tree cb_null
Definition: tree.c:124
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743

Here is the caller graph for this function:

static void expr_expand ( cb_tree x)
static

Definition at line 3088 of file typeck.c.

References CB_BINARY_OP, CB_BINARY_OP_P, cb_binary_op::op, cb_binary_op::x, and cb_binary_op::y.

Referenced by cb_expr_finish().

3089 {
3090  struct cb_binary_op *p;
3091 
3092 start:
3093  /* Remove parenthesis */
3094  if (CB_BINARY_OP_P (*x)) {
3095  p = CB_BINARY_OP (*x);
3096  if (p->op == '@') {
3097  *x = p->x;
3098  goto start;
3099  }
3100  expr_expand (&p->x);
3101  if (p->y) {
3102  expr_expand (&p->y);
3103  }
3104  }
3105 }
static void expr_expand(cb_tree *x)
Definition: typeck.c:3088
#define CB_BINARY_OP_P(x)
Definition: tree.h:937
int op
Definition: tree.h:932
cb_tree y
Definition: tree.h:931
cb_tree x
Definition: tree.h:930
#define CB_BINARY_OP(x)
Definition: tree.h:936

Here is the caller graph for this function:

static int expr_reduce ( int  token)
static

Definition at line 2788 of file typeck.c.

References _, CB_BINARY_OP, CB_BINARY_OP_P, cb_build_binary_op(), CB_BUILD_NEGATION, CB_CLASS_BOOLEAN, cb_error_node, CB_TREE_CLASS, cb_warning(), expr_chk_cond(), expr_index, expr_op, expr_prio, TOKEN, and VALUE.

Referenced by cb_expr_finish(), cb_expr_shift(), cb_expr_shift_class(), and cb_expr_shift_sign().

2789 {
2790  /* Example:
2791  * index: -3 -2 -1 0
2792  * token: 'x' '*' 'x' '+' ...
2793  */
2794 
2795  int op;
2796 
2797  while (expr_prio[TOKEN (-2)] <= expr_prio[token]) {
2798  /* Reduce the expression depending on the last operator */
2799  op = TOKEN (-2);
2800  switch (op) {
2801  case 'x':
2802  return 0;
2803 
2804  case '+':
2805  case '-':
2806  case '*':
2807  case '/':
2808  case '^':
2809  /* Arithmetic operators: 'x' op 'x' */
2810  if (TOKEN (-1) != 'x' || TOKEN (-3) != 'x') {
2811  return -1;
2812  }
2813  TOKEN (-3) = 'x';
2814  VALUE (-3) = cb_build_binary_op (VALUE (-3), op, VALUE (-1));
2815  expr_index -= 2;
2816  break;
2817 
2818  case '!':
2819  /* Negation: '!' 'x' */
2820  if (TOKEN (-1) != 'x') {
2821  return -1;
2822  }
2823  /* 'x' '=' 'x' '|' '!' 'x' */
2824  if (expr_lh) {
2825  if (CB_TREE_CLASS (VALUE (-1)) != CB_CLASS_BOOLEAN) {
2826  VALUE (-1) = cb_build_binary_op (expr_lh, expr_op, VALUE (-1));
2827  }
2828  }
2829  TOKEN (-2) = 'x';
2830  VALUE (-2) = CB_BUILD_NEGATION (VALUE (-1));
2831  expr_index -= 1;
2832  break;
2833 
2834  case '&':
2835  case '|':
2836  /* Logical AND/OR: 'x' op 'x' */
2837  if (TOKEN (-1) != 'x' || TOKEN (-3) != 'x') {
2838  return -1;
2839  }
2840  /* 'x' '=' 'x' '|' 'x' */
2841  if (expr_lh) {
2842  if (CB_TREE_CLASS (VALUE (-1)) != CB_CLASS_BOOLEAN) {
2843  VALUE (-1) = cb_build_binary_op (expr_lh, expr_op, VALUE (-1));
2844  }
2845  if (CB_TREE_CLASS (VALUE (-3)) != CB_CLASS_BOOLEAN) {
2846  VALUE (-3) = cb_build_binary_op (expr_lh, expr_op, VALUE (-3));
2847  }
2848  }
2849  /* Warning for complex expressions without explicit parentheses
2850  (i.e., "a OR b AND c" or "a AND b OR c") */
2851  if (cb_warn_parentheses && op == '|') {
2852  if ((CB_BINARY_OP_P (VALUE (-3)) &&
2853  CB_BINARY_OP (VALUE (-3))->op == '&') ||
2854  (CB_BINARY_OP_P (VALUE (-1)) &&
2855  CB_BINARY_OP (VALUE (-1))->op == '&')) {
2856  cb_warning (_("Suggest parentheses around AND within OR"));
2857  }
2858  }
2859  TOKEN (-3) = 'x';
2860  VALUE (-3) = cb_build_binary_op (VALUE (-3), op,
2861  VALUE (-1));
2862  expr_index -= 2;
2863  break;
2864 
2865  case '(':
2866  case ')':
2867  return 0;
2868 
2869  default:
2870  /* Relational operators */
2871  if (TOKEN (-1) != 'x') {
2872  return -1;
2873  }
2874  switch (TOKEN (-3)) {
2875  case 'x':
2876  /* Simple condition: 'x' op 'x' */
2877  if (VALUE (-3) == cb_error_node ||
2878  VALUE (-1) == cb_error_node) {
2879  VALUE (-3) = cb_error_node;
2880  } else {
2881  expr_lh = VALUE (-3);
2882  if (expr_chk_cond (expr_lh, VALUE (-1))) {
2883  VALUE (-3) = cb_error_node;
2884  return 1;
2885  }
2886  expr_op = op;
2887  TOKEN (-3) = 'x';
2888  if (CB_TREE_CLASS (VALUE (-1)) != CB_CLASS_BOOLEAN) {
2889  VALUE (-3) = cb_build_binary_op (expr_lh, op, VALUE (-1));
2890  } else {
2891  VALUE (-3) = VALUE (-1);
2892  }
2893  }
2894  expr_index -= 2;
2895  break;
2896  case '&':
2897  case '|':
2898  /* Complex condition: 'x' '=' 'x' '|' op 'x' */
2899  if (VALUE (-1) == cb_error_node) {
2900  VALUE (-2) = cb_error_node;
2901  } else {
2902  expr_op = op;
2903  TOKEN (-2) = 'x';
2904  if (CB_TREE_CLASS (VALUE (-1)) != CB_CLASS_BOOLEAN && expr_lh) {
2905  VALUE (-2) = cb_build_binary_op (expr_lh, op, VALUE (-1));
2906  } else {
2907  VALUE (-2) = VALUE (-1);
2908  }
2909  }
2910  expr_index -= 1;
2911  break;
2912  default:
2913  return -1;
2914  }
2915  break;
2916  }
2917  }
2918 
2919  /* Handle special case "op OR x AND" */
2920  if (token == '&' && TOKEN (-2) == '|' &&
2921  CB_TREE_CLASS (VALUE (-1)) != CB_CLASS_BOOLEAN) {
2922  TOKEN (-1) = 'x';
2923  VALUE (-1) = cb_build_binary_op (expr_lh, expr_op, VALUE (-1));
2924  }
2925 
2926  return 0;
2927 }
static cb_tree expr_lh
Definition: typeck.c:100
static int expr_op
Definition: typeck.c:99
#define CB_BUILD_NEGATION(x)
Definition: tree.h:1847
#define TOKEN(offset)
Definition: typeck.c:70
#define CB_TREE_CLASS(x)
Definition: tree.h:442
#define CB_BINARY_OP_P(x)
Definition: tree.h:937
#define VALUE(offset)
Definition: typeck.c:71
#define _(s)
Definition: cobcrun.c:59
int op
Definition: tree.h:932
static int expr_index
Definition: typeck.c:105
cb_tree cb_error_node
Definition: tree.c:140
static int expr_chk_cond(cb_tree expr_1, cb_tree expr_2)
Definition: typeck.c:2731
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
#define CB_BINARY_OP(x)
Definition: tree.h:936
static unsigned char expr_prio[256]
Definition: typeck.c:199
cb_tree cb_build_binary_op(cb_tree x, const int op, cb_tree y)
Definition: tree.c:2827

Here is the call graph for this function:

Here is the caller graph for this function:

static void get_line_and_column_from_pos ( const cb_tree  pos,
cb_tree *const  line,
cb_tree *const  column 
)
static

Definition at line 5173 of file typeck.c.

References cb_int0, CB_PAIR_P, CB_PAIR_X, CB_PAIR_Y, NULL, and valid_screen_pos().

Referenced by emit_field_display(), and emit_screen_display().

5175 {
5176  if (!pos) {
5177  *line = NULL;
5178  *column = NULL;
5179  } else if (CB_PAIR_P (pos)) {
5180  *line = CB_PAIR_X (pos);
5181  *column = CB_PAIR_Y (pos);
5182  if (*line == cb_int0) {
5183  *line = NULL;
5184  }
5185  } else if (valid_screen_pos (pos)) {
5186  *line = pos;
5187  *column = NULL;
5188  }
5189 }
#define CB_PAIR_X(x)
Definition: tree.h:1205
#define CB_PAIR_P(x)
Definition: tree.h:1204
#define CB_PAIR_Y(x)
Definition: tree.h:1206
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static int valid_screen_pos(cb_tree pos)
Definition: typeck.c:4289
cb_tree cb_int0
Definition: tree.c:133

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_value ( cb_tree  x)
static

Definition at line 1843 of file typeck.c.

References CB_CLASS_NUMERIC, cb_get_int(), CB_LITERAL, cb_norm_high, cb_norm_low, cb_null, cb_quote, cb_space, CB_TREE_CLASS, and cb_zero.

Referenced by cb_validate_program_environment().

1844 {
1845  if (x == cb_space) {
1846  return ' ';
1847  } else if (x == cb_zero) {
1848  return '0';
1849  } else if (x == cb_quote) {
1850  return cb_flag_apostrophe ? '\'' : '"';
1851  } else if (x == cb_norm_low) {
1852  return 0;
1853  } else if (x == cb_norm_high) {
1854  return 255;
1855  } else if (x == cb_null) {
1856  return 0;
1857  } else if (CB_TREE_CLASS (x) == CB_CLASS_NUMERIC) {
1858  return cb_get_int (x) - 1;
1859  }
1860  return CB_LITERAL (x)->data[0];
1861 }
cb_tree cb_norm_high
Definition: tree.c:131
#define CB_LITERAL(x)
Definition: tree.h:601
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
cb_tree cb_norm_low
Definition: tree.c:130
cb_tree cb_zero
Definition: tree.c:125
cb_tree cb_quote
Definition: tree.c:132
cb_tree cb_space
Definition: tree.c:127
#define CB_TREE_CLASS(x)
Definition: tree.h:442
cb_tree cb_null
Definition: tree.c:124

Here is the call graph for this function:

Here is the caller graph for this function:

static void initialize_attrs ( const struct cb_attr_struct *const  attr_ptr,
cb_tree *const  fgc,
cb_tree *const  bgc,
cb_tree *const  scroll,
cb_tree *const  size_is,
int *const  dispattrs 
)
static

Definition at line 5152 of file typeck.c.

References cb_attr_struct::bgc, cb_attr_struct::dispattrs, cb_attr_struct::fgc, NULL, cb_attr_struct::scroll, and cb_attr_struct::size_is.

Referenced by cb_emit_display(), and cb_emit_display_omitted().

5156 {
5157  if (attr_ptr) {
5158  *fgc = attr_ptr->fgc;
5159  *bgc = attr_ptr->bgc;
5160  *scroll = attr_ptr->scroll;
5161  *size_is = attr_ptr->size_is;
5162  *dispattrs = attr_ptr->dispattrs;
5163  } else {
5164  *fgc = NULL;
5165  *bgc = NULL;
5166  *scroll = NULL;
5167  *size_is = NULL;
5168  *dispattrs = 0;
5169  }
5170 }
cb_tree scroll
Definition: tree.h:1126
cb_tree size_is
Definition: tree.h:1129
cb_tree bgc
Definition: tree.h:1125
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
int dispattrs
Definition: tree.h:1130
cb_tree fgc
Definition: tree.h:1124

Here is the caller graph for this function:

static COB_INLINE COB_A_INLINE int is_less_than_four_or_is_six ( int  x)
static

Definition at line 4246 of file typeck.c.

4247 {
4248  return x <= 4 || x == 6;
4249 }
cb_tree x
Definition: tree.h:930
static COB_INLINE COB_A_INLINE int is_reference_with_value ( cb_tree  pos)
static

Definition at line 4252 of file typeck.c.

References CB_REFERENCE, CB_REFERENCE_P, NULL, and value.

Referenced by valid_screen_pos_type().

4253 {
4254  return CB_REFERENCE_P (pos)
4255  && (CB_REFERENCE (pos))->value != NULL;
4256 
4257 }
#define CB_REFERENCE_P(x)
Definition: tree.h:902
strict implicit external value
Definition: warning.def:54
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901

Here is the caller graph for this function:

static void move_warning ( cb_tree  src,
cb_tree  dst,
const unsigned int  value_flag,
const int  flag,
const int  src_flag,
const char *  msg 
)
static

Definition at line 6025 of file typeck.c.

References CB_LITERAL_P, cb_warning_x(), cb_tree_common::source_line, suppress_warn, and warning_destination().

Referenced by validate_move().

6027 {
6028  cb_tree loc;
6029 
6030  if (suppress_warn) {
6031  return;
6032  }
6033  loc = src->source_line ? src : dst;
6034  if (value_flag) {
6035  /* VALUE clause */
6036  if (CB_LITERAL_P (src)) {
6037  cb_warning_x (dst, msg);
6038  } else {
6039  cb_warning_x (loc, msg);
6040  }
6041  } else {
6042  /* MOVE statement */
6043  if (flag) {
6044  if (CB_LITERAL_P (src)) {
6045  cb_warning_x (dst, msg);
6046  } else {
6047  cb_warning_x (loc, msg);
6048  }
6049  if (src_flag) {
6050  warning_destination (src);
6051  }
6052  warning_destination (dst);
6053  }
6054  }
6055 
6056  return;
6057 }
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
#define CB_LITERAL_P(x)
Definition: tree.h:602
int source_line
Definition: tree.h:432
static void warning_destination(cb_tree x)
Definition: typeck.c:5969
size_t suppress_warn
Definition: typeck.c:90
unsigned int flag
Definition: tree.h:933

Here is the call graph for this function:

Here is the caller graph for this function:

static void output_screen_from ( struct cb_field p,
const unsigned int  sisters 
)
static

Definition at line 4199 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_emit, CB_TREE, cb_field::children, COB_SCREEN_TYPE_ATTRIBUTE, COB_SCREEN_TYPE_FIELD, COB_SCREEN_TYPE_GROUP, COB_SCREEN_TYPE_VALUE, cb_field::count, cb_field::screen_from, cb_field::sister, cb_field::size, and cb_field::values.

Referenced by cb_emit_accept(), and cb_emit_display().

4200 {
4201  int type;
4202 
4203  if (sisters && p->sister) {
4204  output_screen_from (p->sister, 1U);
4205  }
4206  if (p->children) {
4207  output_screen_from (p->children, 1U);
4208  }
4209 
4210  type = (p->children ? COB_SCREEN_TYPE_GROUP :
4213  if (type == COB_SCREEN_TYPE_FIELD && p->screen_from) {
4214  /* Bump reference count */
4215  p->count++;
4216  cb_emit (CB_BUILD_FUNCALL_2 ("cob_move", p->screen_from,
4217  CB_TREE (p)));
4218  }
4219 }
#define CB_TREE(x)
Definition: tree.h:440
#define COB_SCREEN_TYPE_VALUE
Definition: common.h:929
#define COB_SCREEN_TYPE_FIELD
Definition: common.h:928
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
cb_tree screen_from
Definition: tree.h:665
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
int count
Definition: tree.h:680
static void output_screen_from(struct cb_field *p, const unsigned int sisters)
Definition: typeck.c:4199
#define COB_SCREEN_TYPE_ATTRIBUTE
Definition: common.h:930
int size
Definition: tree.h:672
#define cb_emit(x)
Definition: typeck.c:75
#define COB_SCREEN_TYPE_GROUP
Definition: common.h:927
cb_tree values
Definition: tree.h:648

Here is the caller graph for this function:

static void output_screen_to ( struct cb_field p,
const unsigned int  sisters 
)
static

Definition at line 4222 of file typeck.c.

References CB_BUILD_FUNCALL_2, cb_emit, CB_TREE, cb_field::children, COB_SCREEN_TYPE_ATTRIBUTE, COB_SCREEN_TYPE_FIELD, COB_SCREEN_TYPE_GROUP, COB_SCREEN_TYPE_VALUE, cb_field::count, cb_field::screen_to, cb_field::sister, cb_field::size, and cb_field::values.

Referenced by cb_emit_accept().

4223 {
4224  int type;
4225 
4226  if (sisters && p->sister) {
4227  output_screen_to (p->sister, 1U);
4228  }
4229  if (p->children) {
4230  output_screen_to (p->children, 1U);
4231  }
4232 
4233  type = (p->children ? COB_SCREEN_TYPE_GROUP :
4236  if (type == COB_SCREEN_TYPE_FIELD && p->screen_to) {
4237  /* Bump reference count */
4238  p->count++;
4239  cb_emit (CB_BUILD_FUNCALL_2 ("cob_move", CB_TREE (p), p->screen_to));
4240  }
4241 }
#define CB_TREE(x)
Definition: tree.h:440
#define COB_SCREEN_TYPE_VALUE
Definition: common.h:929
#define COB_SCREEN_TYPE_FIELD
Definition: common.h:928
struct cb_field * sister
Definition: tree.h:653
struct cb_field * children
Definition: tree.h:652
static void output_screen_to(struct cb_field *p, const unsigned int sisters)
Definition: typeck.c:4222
#define CB_BUILD_FUNCALL_2(f, a1, a2)
Definition: tree.h:1803
int count
Definition: tree.h:680
#define COB_SCREEN_TYPE_ATTRIBUTE
Definition: common.h:930
int size
Definition: tree.h:672
cb_tree screen_to
Definition: tree.h:666
#define cb_emit(x)
Definition: typeck.c:75
#define COB_SCREEN_TYPE_GROUP
Definition: common.h:927
cb_tree values
Definition: tree.h:648

Here is the caller graph for this function:

static unsigned int search_set_keys ( struct cb_field f,
cb_tree  x 
)
static

Definition at line 7852 of file typeck.c.

References _, build_cond_88(), CB_BINARY_OP, cb_error_node, cb_error_x(), CB_FIELD_PTR, CB_REF_OR_FIELD_P, CB_REFERENCE_P, CB_TREE, current_statement, cb_key::key, cb_field::keys, cb_field::nkeys, NULL, cb_binary_op::op, cb_key::ref, cb_key::val, cb_binary_op::x, and cb_binary_op::y.

Referenced by cb_build_search_all().

7853 {
7854  struct cb_binary_op *p;
7855  struct cb_field *fldx;
7856  struct cb_field *fldy;
7857  int i;
7858 
7859  if (CB_REFERENCE_P (x)) {
7860  x = build_cond_88 (x);
7861  if (!x || x == cb_error_node) {
7862  return 1;
7863  }
7864  }
7865 
7866  p = CB_BINARY_OP (x);
7867  switch (p->op) {
7868  case '&':
7869  if (search_set_keys (f, p->x)) {
7870  return 1;
7871  }
7872  if (search_set_keys (f, p->y)) {
7873  return 1;
7874  }
7875  break;
7876  case '=':
7877  fldx = NULL;
7878  fldy = NULL;
7879  /* One of the operands must be a key reference */
7880  if (CB_REF_OR_FIELD_P (p->x)) {
7881  fldx = CB_FIELD_PTR (p->x);
7882  }
7883  if (CB_REF_OR_FIELD_P (p->y)) {
7884  fldy = CB_FIELD_PTR (p->y);
7885  }
7886  if (!fldx && !fldy) {
7888  _("Invalid SEARCH ALL condition"));
7889  return 1;
7890  }
7891 
7892  for (i = 0; i < f->nkeys; ++i) {
7893  if (fldx == CB_FIELD_PTR (f->keys[i].key)) {
7894  f->keys[i].ref = p->x;
7895  f->keys[i].val = p->y;
7896  break;
7897  }
7898  }
7899  if (i == f->nkeys) {
7900  for (i = 0; i < f->nkeys; ++i) {
7901  if (fldy == CB_FIELD_PTR (f->keys[i].key)) {
7902  f->keys[i].ref = p->y;
7903  f->keys[i].val = p->x;
7904  break;
7905  }
7906  }
7907  if (i == f->nkeys) {
7909  _("Invalid SEARCH ALL condition"));
7910  return 1;
7911  }
7912  }
7913  break;
7914  default:
7916  _("Invalid SEARCH ALL condition"));
7917  return 1;
7918  }
7919  return 0;
7920 }
#define CB_TREE(x)
Definition: tree.h:440
#define CB_REFERENCE_P(x)
Definition: tree.h:902
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
cb_tree val
Definition: tree.h:639
#define CB_FIELD_PTR(x)
Definition: tree.h:745
cb_tree ref
Definition: tree.h:638
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
int op
Definition: tree.h:932
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static cb_tree build_cond_88(cb_tree x)
Definition: typeck.c:3519
cb_tree cb_error_node
Definition: tree.c:140
cb_tree y
Definition: tree.h:931
cb_tree key
Definition: tree.h:637
cb_tree x
Definition: tree.h:930
#define CB_BINARY_OP(x)
Definition: tree.h:936
static unsigned int search_set_keys(struct cb_field *f, cb_tree x)
Definition: typeck.c:7852
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169
struct cb_key * keys
Definition: tree.h:658
int nkeys
Definition: tree.h:682

Here is the call graph for this function:

Here is the caller graph for this function:

static int valid_screen_pos ( cb_tree  pos)
static

Definition at line 4289 of file typeck.c.

References _, cb_error(), CB_FIELD, CB_LITERAL, CB_NUMERIC_LITERAL_P, CB_REFERENCE, cb_field::pic, cb_picture::size, cb_field::size, valid_screen_pos_type(), and value.

Referenced by cb_emit_accept(), cb_gen_field_accept(), and get_line_and_column_from_pos().

4290 {
4291  int size;
4292 
4293  /* Find size of pos value, if possible */
4294  if (CB_NUMERIC_LITERAL_P (pos)) {
4295  size = (CB_LITERAL (pos))->size;
4296  } else if (valid_screen_pos_type (pos)) {
4297  size = (CB_FIELD ((CB_REFERENCE (pos))->value))->pic->size;
4298  } else {
4299  cb_error (_("Invalid value in AT clause"));
4300  return 0;
4301  }
4302 
4303  /* Check if size is valid. If it isn't, display error. */
4304  if (size == 5) {
4305  cb_error (_("Value in AT clause may not have 5 digits"));
4306  return 0;
4307  } else if (size > 6) {
4308  cb_error (_("Value in AT clause may not be longer than 6 digits"));
4309  return 0;
4310  } else {
4311  return 1;
4312  }
4313 }
#define CB_NUMERIC_LITERAL_P(x)
Definition: tree.h:603
int size
Definition: tree.h:622
#define CB_LITERAL(x)
Definition: tree.h:601
struct cb_picture * pic
Definition: tree.h:659
strict implicit external value
Definition: warning.def:54
#define _(s)
Definition: cobcrun.c:59
#define CB_REFERENCE(x)
Definition: tree.h:901
int size
Definition: tree.h:672
static int valid_screen_pos_type(cb_tree pos)
Definition: typeck.c:4280
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

static int valid_screen_pos_type ( cb_tree  pos)
static

Definition at line 4280 of file typeck.c.

References is_reference_with_value(), value_has_picture_clause(), value_is_numeric_field(), and value_pic_has_no_scale().

Referenced by valid_screen_pos().

4281 {
4282  return is_reference_with_value (pos)
4283  && value_is_numeric_field (pos)
4284  && value_has_picture_clause (pos)
4285  && value_pic_has_no_scale (pos);
4286 }
static COB_INLINE COB_A_INLINE int value_is_numeric_field(cb_tree pos)
Definition: typeck.c:4260
static COB_INLINE COB_A_INLINE int is_reference_with_value(cb_tree pos)
Definition: typeck.c:4252
static COB_INLINE COB_A_INLINE int value_has_picture_clause(cb_tree pos)
Definition: typeck.c:4268
static COB_INLINE COB_A_INLINE int value_pic_has_no_scale(cb_tree pos)
Definition: typeck.c:4274

Here is the call graph for this function:

Here is the caller graph for this function:

static int validate_attrs ( cb_tree  pos,
cb_tree  fgc,
cb_tree  bgc,
cb_tree  scroll,
cb_tree  size_is 
)
static

Definition at line 5142 of file typeck.c.

References cb_validate_one().

Referenced by cb_emit_display(), and cb_emit_display_omitted().

5143 {
5144  return cb_validate_one (pos)
5145  || cb_validate_one (fgc)
5146  || cb_validate_one (bgc)
5147  || cb_validate_one (scroll)
5148  || cb_validate_one (size_is);
5149 }
static size_t cb_validate_one(cb_tree x)
Definition: typeck.c:545

Here is the call graph for this function:

Here is the caller graph for this function:

static void validate_inspect ( cb_tree  x,
cb_tree  y,
const unsigned int  replconv 
)
static

Definition at line 5714 of file typeck.c.

References _, CB_ALPHABET_NAME_P, cb_error_node, cb_error_x(), CB_FIELD_PTR, cb_get_int(), CB_LITERAL, CB_LITERAL_P, cb_ref(), CB_REF_OR_FIELD_P, CB_REFERENCE, CB_TAG_CONST, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE, CB_TREE_TAG, current_statement, cb_reference::length, and cb_reference::offset.

Referenced by cb_build_converting(), cb_build_replacing_all(), cb_build_replacing_first(), cb_build_replacing_leading(), and cb_build_replacing_trailing().

5715 {
5716  cb_tree l;
5717  struct cb_reference *r;
5718  size_t size1;
5719  size_t size2;
5720  int offset;
5721 
5722  size1 = 0;
5723  size2 = 0;
5724  switch (CB_TREE_TAG(x)) {
5725  case CB_TAG_REFERENCE:
5726  r = CB_REFERENCE (x);
5727  l = cb_ref (x);
5728  if (l == cb_error_node) {
5729  return;
5730  }
5731  if (CB_REF_OR_FIELD_P (l)) {
5732  size1 = CB_FIELD_PTR (x)->size;
5733  } else if (CB_ALPHABET_NAME_P (l)) {
5734  size1 = 256;
5735  }
5736  if (size1 && r->offset) {
5737  if (!CB_LITERAL_P (r->offset)) {
5738  return;
5739  }
5740  offset = cb_get_int (r->offset);
5741  if (r->length) {
5742  if (!CB_LITERAL_P (r->length)) {
5743  return;
5744  }
5745  size1 = cb_get_int (r->length);
5746  } else {
5747  size1 -= (offset - 1);
5748  }
5749  }
5750  break;
5751  case CB_TAG_LITERAL:
5752  size1 = CB_LITERAL(x)->size;
5753  break;
5754  case CB_TAG_CONST:
5755  size1 = 1;
5756  break;
5757  default:
5758  break;
5759  }
5760  switch (CB_TREE_TAG(y)) {
5761  case CB_TAG_REFERENCE:
5762  r = CB_REFERENCE (y);
5763  l = cb_ref (y);
5764  if (l == cb_error_node) {
5765  return;
5766  }
5767  if (CB_REF_OR_FIELD_P (l)) {
5768  size2 = CB_FIELD_PTR (y)->size;
5769  } else if (CB_ALPHABET_NAME_P (l)) {
5770  size2 = 256;
5771  }
5772  if (size2 && r->offset) {
5773  if (!CB_LITERAL_P (r->offset)) {
5774  return;
5775  }
5776  offset = cb_get_int (r->offset);
5777  if (r->length) {
5778  if (!CB_LITERAL_P (r->length)) {
5779  return;
5780  }
5781  size2 = cb_get_int (r->length);
5782  } else {
5783  size2 -= (offset - 1);
5784  }
5785  }
5786  break;
5787  case CB_TAG_LITERAL:
5788  size2 = CB_LITERAL(y)->size;
5789  break;
5790  default:
5791  break;
5792  }
5793  if (size1 && size2 && size1 != size2) {
5794  if (replconv == 1) {
5796  _("%s operands differ in size"), "REPLACING");
5797  } else {
5799  _("%s operands differ in size"), "CONVERTING");
5800  }
5801  }
5802 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LITERAL(x)
Definition: tree.h:601
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int cb_get_int(const cb_tree x)
Definition: tree.c:1101
cb_tree cb_ref(cb_tree x)
Definition: tree.c:2653
#define CB_LITERAL_P(x)
Definition: tree.h:602
#define _(s)
Definition: cobcrun.c:59
#define CB_TREE_TAG(x)
Definition: tree.h:441
cb_tree offset
Definition: tree.h:878
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree cb_error_node
Definition: tree.c:140
#define CB_ALPHABET_NAME_P(x)
Definition: tree.h:551
cb_tree length
Definition: tree.h:879
#define CB_REF_OR_FIELD_P(x)
Definition: tree.h:743
struct cb_statement * current_statement
Definition: parser.c:169

Here is the call graph for this function:

Here is the caller graph for this function:

int validate_move ( cb_tree  src,
cb_tree  dst,
const unsigned int  is_value 
)

Definition at line 6167 of file typeck.c.

References _, cb_literal::all, CB_ALPHABET_NAME_P, CB_CATEGORY_ALPHABETIC, CB_CATEGORY_ALPHANUMERIC, CB_CATEGORY_ALPHANUMERIC_EDITED, CB_CATEGORY_BOOLEAN, CB_CATEGORY_NUMERIC, CB_CATEGORY_NUMERIC_EDITED, cb_check_overlapping(), CB_CLASS_NUMERIC, CB_CLASS_POINTER, CB_ERROR, cb_error_x(), CB_FIELD_PTR, cb_field_size(), CB_FILE_P, cb_get_long_long(), cb_high, CB_LITERAL, cb_low, cb_quote, CB_REFERENCE, CB_REFERENCE_P, cb_space, CB_TAG_BINARY_OP, CB_TAG_CONST, CB_TAG_FIELD, CB_TAG_FUNCALL, CB_TAG_INTEGER, CB_TAG_INTRINSIC, CB_TAG_LITERAL, CB_TAG_REFERENCE, CB_TREE_CATEGORY, CB_TREE_CLASS, CB_TREE_TAG, CB_USAGE_BINARY, CB_USAGE_COMP_5, CB_USAGE_COMP_X, CB_USAGE_DOUBLE, CB_USAGE_FLOAT, CB_USAGE_FP_BIN128, CB_USAGE_FP_BIN32, CB_USAGE_FP_BIN64, CB_USAGE_FP_DEC128, CB_USAGE_FP_DEC64, CB_USAGE_LONG_DOUBLE, cb_warning_x(), cb_zero, cb_field::children, COB_S64_C, cob_s64_t, COBC_ABORT, cobc_abort_pr(), count_pic_alphanumeric_edited(), cb_literal::data, cb_picture::digits, cb_field::flag_real_binary, cb_picture::have_sign, move_warning(), overlapping, cb_field::pic, cb_literal::scale, cb_picture::scale, cb_literal::sign, cb_literal::size, cb_picture::size, cb_field::size, cb_tree_common::source_line, suppress_warn, cb_field::usage, value, and warningopt.

Referenced by cb_build_move(), and validate_field_value().

6168 {
6169  struct cb_field *fdst;
6170  struct cb_field *fsrc;
6171  struct cb_literal *l;
6172  unsigned char *p;
6173  cb_tree loc;
6174  cob_s64_t val;
6175  size_t i;
6176  size_t is_numeric_edited;
6177  int src_scale_mod;
6178  int dst_scale_mod;
6179  int dst_size_mod;
6180  int size;
6181  int most_significant;
6182  int least_significant;
6183 
6184  loc = src->source_line ? src : dst;
6185  is_numeric_edited = 0;
6186  overlapping = 0;
6187  if (CB_REFERENCE_P (dst)) {
6188  if (CB_ALPHABET_NAME_P(CB_REFERENCE(dst)->value)) {
6189  goto invalid;
6190  }
6191  if (CB_FILE_P(CB_REFERENCE(dst)->value)) {
6192  goto invalid;
6193  }
6194  }
6195  if (CB_TREE_CATEGORY (dst) == CB_CATEGORY_BOOLEAN) {
6196  cb_error_x (loc, _("Invalid destination for MOVE"));
6197  return -1;
6198  }
6199 
6200  if (CB_TREE_CLASS (dst) == CB_CLASS_POINTER) {
6201  if (CB_TREE_CLASS (src) == CB_CLASS_POINTER) {
6202  return 0;
6203  } else {
6204  goto invalid;
6205  }
6206  }
6207 
6208  fdst = CB_FIELD_PTR (dst);
6209  switch (CB_TREE_TAG (src)) {
6210  case CB_TAG_CONST:
6211  if (src == cb_space) {
6212  if (CB_TREE_CATEGORY (dst) == CB_CATEGORY_NUMERIC ||
6213  (CB_TREE_CATEGORY (dst) == CB_CATEGORY_NUMERIC_EDITED && !is_value)) {
6214  if (!cb_relaxed_syntax_check || is_value) {
6215  goto invalid;
6216  }
6217  cb_warning_x (loc, _("Source is non-numeric - substituting zero"));
6218  }
6219  } else if (src == cb_zero) {
6221  goto invalid;
6222  }
6223  } else if (src == cb_low || src == cb_high || src == cb_quote) {
6224  if (CB_TREE_CATEGORY (dst) == CB_CATEGORY_NUMERIC ||
6226  if (!cb_relaxed_syntax_check || is_value) {
6227  goto invalid;
6228  }
6229  cb_warning_x (loc, _("Source is non-numeric - substituting zero"));
6230  }
6231  }
6232  break;
6233  case CB_TAG_LITERAL:
6234  l = CB_LITERAL (src);
6235  if (CB_TREE_CLASS (src) == CB_CLASS_NUMERIC) {
6236  /* Numeric literal */
6237  if (l->all) {
6238  goto invalid;
6239  }
6240  if (fdst->usage == CB_USAGE_DOUBLE ||
6241  fdst->usage == CB_USAGE_FLOAT ||
6242  fdst->usage == CB_USAGE_LONG_DOUBLE ||
6243  fdst->usage == CB_USAGE_FP_BIN32 ||
6244  fdst->usage == CB_USAGE_FP_BIN64 ||
6245  fdst->usage == CB_USAGE_FP_BIN128 ||
6246  fdst->usage == CB_USAGE_FP_DEC64 ||
6247  fdst->usage == CB_USAGE_FP_DEC128) {
6248  break;
6249  }
6250  most_significant = -999;
6251  least_significant = 999;
6252 
6253  /* Compute the most significant figure place */
6254  for (i = 0; i < l->size; i++) {
6255  if (l->data[i] != '0') {
6256  break;
6257  }
6258  }
6259  if (i != l->size) {
6260  most_significant = (int) (l->size - l->scale - i - 1);
6261  }
6262 
6263  /* Compute the least significant figure place */
6264  for (i = 0; i < l->size; i++) {
6265  if (l->data[l->size - i - 1] != '0') {
6266  break;
6267  }
6268  }
6269  if (i != l->size) {
6270  least_significant = (int) (-l->scale + i);
6271  }
6272 
6273  /* Value check */
6274  switch (CB_TREE_CATEGORY (dst)) {
6277  if (is_value) {
6278  goto expect_alphanumeric;
6279  }
6280  if (l->scale == 0) {
6281  goto expect_alphanumeric;
6282  }
6283  goto non_integer_move;
6284  case CB_CATEGORY_NUMERIC:
6285  if (fdst->pic->scale < 0) {
6286  /* Check for PIC 9(n)P(m) */
6287  if (least_significant < -fdst->pic->scale) {
6288  goto value_mismatch;
6289  }
6290  } else if (fdst->pic->scale > fdst->pic->size) {
6291  /* Check for PIC P(n)9(m) */
6292  if (most_significant >= fdst->pic->size - fdst->pic->scale) {
6293  goto value_mismatch;
6294  }
6295  }
6296  break;
6298  if (is_value) {
6299  goto expect_alphanumeric;
6300  }
6301 
6302  /* TODO */
6303  break;
6305  if (is_value) {
6306  goto expect_alphanumeric;
6307  }
6308  /* Coming from codegen */
6309  if (!suppress_warn) {
6310  goto invalid;
6311  }
6312 #if 1 /* RXWRXW - Initialize warn */
6313  if (warningopt) {
6314  cb_warning_x (loc, _("Numeric move to ALPHABETIC"));
6315  }
6316 #endif
6317  break;
6318  default:
6319  if (is_value) {
6320  goto expect_alphanumeric;
6321  }
6322  goto invalid;
6323  }
6324 
6325  /* Sign check */
6326  if (l->sign != 0 && !fdst->pic->have_sign) {
6327  if (is_value) {
6328  cb_error_x (loc, _("Data item not signed"));
6329  return -1;
6330  }
6331  if (cb_warn_constant) {
6332  cb_warning_x (loc, _("Ignoring sign"));
6333  }
6334  }
6335 
6336  /* Size check */
6337  if (fdst->flag_real_binary ||
6338  ((fdst->usage == CB_USAGE_COMP_5 ||
6339  fdst->usage == CB_USAGE_COMP_X ||
6340  fdst->usage == CB_USAGE_BINARY) &&
6341  fdst->pic->scale == 0)) {
6342  p = l->data;
6343  for (i = 0; i < l->size; i++) {
6344  if (l->data[i] != '0') {
6345  p = &l->data[i];
6346  break;
6347  }
6348  }
6349  i = l->size - i;
6350  switch (fdst->size) {
6351  case 1:
6352  if (i > 18) {
6353  goto numlit_overflow;
6354  }
6355  val = cb_get_long_long (src);
6356  if (fdst->pic->have_sign) {
6357  if (val < COB_S64_C(-128) ||
6358  val > COB_S64_C(127)) {
6359  goto numlit_overflow;
6360  }
6361  } else {
6362  if (val > COB_S64_C(255)) {
6363  goto numlit_overflow;
6364  }
6365  }
6366  break;
6367  case 2:
6368  if (i > 18) {
6369  goto numlit_overflow;
6370  }
6371  val = cb_get_long_long (src);
6372  if (fdst->pic->have_sign) {
6373  if (val < COB_S64_C(-32768) ||
6374  val > COB_S64_C(32767)) {
6375  goto numlit_overflow;
6376  }
6377  } else {
6378  if (val > COB_S64_C(65535)) {
6379  goto numlit_overflow;
6380  }
6381  }
6382  break;
6383  case 3:
6384  if (i > 18) {
6385  goto numlit_overflow;
6386  }
6387  val = cb_get_long_long (src);
6388  if (fdst->pic->have_sign) {
6389  if (val < COB_S64_C(-8388608) ||
6390  val > COB_S64_C(8388607)) {
6391  goto numlit_overflow;
6392  }
6393  } else {
6394  if (val > COB_S64_C(16777215)) {
6395  goto numlit_overflow;
6396  }
6397  }
6398  break;
6399  case 4:
6400  if (i > 18) {
6401  goto numlit_overflow;
6402  }
6403  val = cb_get_long_long (src);
6404  if (fdst->pic->have_sign) {
6405  if (val < COB_S64_C(-2147483648) ||
6406  val > COB_S64_C(2147483647)) {
6407  goto numlit_overflow;
6408  }
6409  } else {
6410  if (val > COB_S64_C(4294967295)) {
6411  goto numlit_overflow;
6412  }
6413  }
6414  break;
6415  case 5:
6416  if (i > 18) {
6417  goto numlit_overflow;
6418  }
6419  val = cb_get_long_long (src);
6420  if (fdst->pic->have_sign) {
6421  if (val < COB_S64_C(-549755813888) ||
6422  val > COB_S64_C(549755813887)) {
6423  goto numlit_overflow;
6424  }
6425  } else {
6426  if (val > COB_S64_C(1099511627775)) {
6427  goto numlit_overflow;
6428  }
6429  }
6430  break;
6431  case 6:
6432  if (i > 18) {
6433  goto numlit_overflow;
6434  }
6435  val = cb_get_long_long (src);
6436  if (fdst->pic->have_sign) {
6437  if (val < COB_S64_C(-140737488355328) ||
6438  val > COB_S64_C(140737488355327)) {
6439  goto numlit_overflow;
6440  }
6441  } else {
6442  if (val > COB_S64_C(281474976710655)) {
6443  goto numlit_overflow;
6444  }
6445  }
6446  break;
6447  case 7:
6448  if (i > 18) {
6449  goto numlit_overflow;
6450  }
6451  val = cb_get_long_long (src);
6452  if (fdst->pic->have_sign) {
6453  if (val < COB_S64_C(-36028797018963968) ||
6454  val > COB_S64_C(36028797018963967)) {
6455  goto numlit_overflow;
6456  }
6457  } else {
6458  if (val > COB_S64_C(72057594037927935)) {
6459  goto numlit_overflow;
6460  }
6461  }
6462  break;
6463  default:
6464  if (fdst->pic->have_sign) {
6465  if (i < 19) {
6466  break;
6467  }
6468  if (i > 19) {
6469  goto numlit_overflow;
6470  }
6471  if (memcmp (p, "9223372036854775807", (size_t)19) > 0) {
6472  goto numlit_overflow;
6473  }
6474  } else {
6475  if (i < 20) {
6476  break;
6477  }
6478  if (i > 20) {
6479  goto numlit_overflow;
6480  }
6481  if (memcmp (p, "18446744073709551615", (size_t)20) > 0) {
6482  goto numlit_overflow;
6483  }
6484  }
6485  break;
6486  }
6487  return 0;
6488  }
6489  if (least_significant < -fdst->pic->scale) {
6490  goto size_overflow;
6491  }
6492  if (fdst->pic->scale > 0) {
6493  size = fdst->pic->digits - fdst->pic->scale;
6494  } else {
6495  size = fdst->pic->digits;
6496  }
6497  if (most_significant >= size) {
6498  goto size_overflow;
6499  }
6500  } else {
6501  /* Alphanumeric literal */
6502 
6503  /* Value check */
6504  switch (CB_TREE_CATEGORY (dst)) {
6506  for (i = 0; i < l->size; i++) {
6507  if (!isalpha (l->data[i]) &&
6508  l->data[i] != ' ') {
6509  goto value_mismatch;
6510  }
6511  }
6512  break;
6513  case CB_CATEGORY_NUMERIC:
6514  goto expect_numeric;
6516  if (!is_value) {
6517  goto expect_numeric;
6518  }
6519 
6520  /* TODO: validate the value */
6521  break;
6522  default:
6523  break;
6524  }
6525 
6526  /* Size check */
6527  size = cb_field_size (dst);
6528  if (size > 0 && (int)l->size > size) {
6529  goto size_overflow;
6530  }
6531  }
6532  break;
6533  case CB_TAG_FIELD:
6534  case CB_TAG_REFERENCE:
6535  if (CB_REFERENCE_P(src) &&
6537  break;
6538  }
6539  if (CB_REFERENCE_P(src) &&
6540  CB_FILE_P(CB_REFERENCE(src)->value)) {
6541  goto invalid;
6542  }
6543  fsrc = CB_FIELD_PTR (src);
6544  size = cb_field_size (src);
6545  if (size < 0) {
6546  size = fsrc->size;
6547  }
6548 
6549  /* Check basic overlapping */
6550  overlapping = cb_check_overlapping (src, dst, fsrc, fdst);
6551 
6552  /* Non-elementary move */
6553  if (fsrc->children || fdst->children) {
6554  if (size > fdst->size) {
6555  goto size_overflow_1;
6556  }
6557  break;
6558  }
6559 
6560  /* Elementary move */
6561  switch (CB_TREE_CATEGORY (src)) {
6563  switch (CB_TREE_CATEGORY (dst)) {
6564  case CB_CATEGORY_NUMERIC:
6566  if (size > (int)fdst->pic->digits) {
6567  goto size_overflow_2;
6568  }
6569  break;
6571  if (size > count_pic_alphanumeric_edited (fdst)) {
6572  goto size_overflow_1;
6573  }
6574  break;
6575  default:
6576  if (size > fdst->size) {
6577  goto size_overflow_1;
6578  }
6579  break;
6580  }
6581  break;
6584  switch (CB_TREE_CATEGORY (dst)) {
6585  case CB_CATEGORY_NUMERIC:
6587  goto invalid;
6589  if (size > count_pic_alphanumeric_edited(fdst)) {
6590  goto size_overflow_1;
6591  }
6592  break;
6593  default:
6594  if (size > fdst->size) {
6595  goto size_overflow_1;
6596  }
6597  break;
6598  }
6599  break;
6600  case CB_CATEGORY_NUMERIC:
6602  switch (CB_TREE_CATEGORY (dst)) {
6604  goto invalid;
6606  is_numeric_edited = 1;
6607  /* Drop through */
6609  if (!fsrc->pic) {
6610  return -1;
6611  }
6612  if (is_numeric_edited) {
6613  dst_size_mod = count_pic_alphanumeric_edited (fdst);
6614  } else {
6615  dst_size_mod = fdst->size;
6616  }
6617  if (CB_TREE_CATEGORY (src) == CB_CATEGORY_NUMERIC &&
6618  fsrc->pic->scale > 0) {
6619  goto non_integer_move;
6620  }
6621  if (CB_TREE_CATEGORY (src) == CB_CATEGORY_NUMERIC &&
6622  (int)fsrc->pic->digits > dst_size_mod) {
6623  goto size_overflow_2;
6624  }
6626  fsrc->size > dst_size_mod) {
6627  goto size_overflow_1;
6628  }
6629  break;
6630  default:
6631  if (!fsrc->pic) {
6632  return -1;
6633  }
6634  if (!fdst->pic) {
6635  return -1;
6636  }
6637  src_scale_mod = fsrc->pic->scale < 0 ?
6638  0 : fsrc->pic->scale;
6639  dst_scale_mod = fdst->pic->scale < 0 ?
6640  0 : fdst->pic->scale;
6641  if (fsrc->pic->digits - src_scale_mod >
6642  fdst->pic->digits - dst_scale_mod ||
6643  src_scale_mod > dst_scale_mod) {
6644  goto size_overflow_2;
6645  }
6646  break;
6647  }
6648  break;
6649  default:
6650  cb_error_x (loc, _("Invalid source for MOVE"));
6651  return -1;
6652  }
6653  break;
6654  case CB_TAG_INTEGER:
6655  case CB_TAG_BINARY_OP:
6656  case CB_TAG_INTRINSIC:
6657  case CB_TAG_FUNCALL:
6658  /* TODO: check this */
6659  break;
6660  default:
6661  cobc_abort_pr (_("Unexpected tree tag %d"),
6662  (int)CB_TREE_TAG (src));
6663  COBC_ABORT ();
6664  }
6665  return 0;
6666 
6667 invalid:
6668  if (is_value) {
6669  cb_error_x (loc, _("Invalid VALUE clause"));
6670  } else {
6671  cb_error_x (loc, _("Invalid MOVE statement"));
6672  }
6673  return -1;
6674 
6675 numlit_overflow:
6676  if (is_value) {
6677  cb_error_x (loc, _("Invalid VALUE clause - literal exceeds data size"));
6678  return -1;
6679  }
6680  if (cb_warn_constant && !suppress_warn) {
6681  cb_warning_x (loc, _("Numeric literal exceeds data size"));
6682  }
6683  return 0;
6684 
6685 non_integer_move:
6686  if (cb_move_noninteger_to_alphanumeric == CB_ERROR) {
6687  goto invalid;
6688  }
6689  if (!suppress_warn) {
6690  cb_warning_x (loc, _("MOVE of non-integer to alphanumeric"));
6691  }
6692  return 0;
6693 
6694 expect_numeric:
6695  move_warning (src, dst, is_value, cb_warn_strict_typing, 0,
6696  _("Numeric value is expected"));
6697  return 0;
6698 
6699 expect_alphanumeric:
6700  move_warning (src, dst, is_value, cb_warn_strict_typing, 0,
6701  _("Alphanumeric value is expected"));
6702  return 0;
6703 
6704 value_mismatch:
6705  move_warning (src, dst, is_value, cb_warn_constant, 0,
6706  _("Value does not fit the picture string"));
6707  return 0;
6708 
6709 size_overflow:
6710  move_warning (src, dst, is_value, cb_warn_constant, 0,
6711  _("Value size exceeds data size"));
6712  return 0;
6713 
6714 size_overflow_1:
6715  move_warning (src, dst, is_value, cb_warn_truncate, 1,
6716  _("Sending field larger than receiving field"));
6717  return 0;
6718 
6719 size_overflow_2:
6720  move_warning (src, dst, is_value, cb_warn_truncate, 1,
6721  _("Some digits may be truncated"));
6722  return 0;
6723 }
unsigned int flag_real_binary
Definition: tree.h:708
#define CB_REFERENCE_P(x)
Definition: tree.h:902
static int cb_field_size(const cb_tree x)
Definition: typeck.c:790
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_TREE_CATEGORY(x)
Definition: tree.h:443
short sign
Definition: tree.h:597
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
int size
Definition: tree.h:622
int scale
Definition: tree.h:626
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
static void move_warning(cb_tree src, cb_tree dst, const unsigned int value_flag, const int flag, const int src_flag, const char *msg)
Definition: typeck.c:6025
static int count_pic_alphanumeric_edited(struct cb_field *field)
Definition: typeck.c:6060
struct cb_field * children
Definition: tree.h:652
#define CB_LITERAL(x)
Definition: tree.h:601
Definition: cobc.h:141
#define CB_FIELD_PTR(x)
Definition: tree.h:745
int warningopt
Definition: cobc.c:176
struct cb_picture * pic
Definition: tree.h:659
cob_u32_t digits
Definition: tree.h:625
cb_tree cb_zero
Definition: tree.c:125
static size_t overlapping
Definition: typeck.c:103
cb_tree cb_quote
Definition: tree.c:132
cb_tree cb_space
Definition: tree.c:127
#define cob_s64_t
Definition: common.h:51
#define COB_S64_C(x)
Definition: common.h:54
short all
Definition: tree.h:598
#define CB_TREE_CLASS(x)
Definition: tree.h:442
static size_t cb_check_overlapping(cb_tree src, cb_tree dst, struct cb_field *src_f, struct cb_field *dst_f)
Definition: typeck.c:6078
strict implicit external value
Definition: warning.def:54
int source_line
Definition: tree.h:432
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
int scale
Definition: tree.h:595
#define CB_TREE_TAG(x)
Definition: tree.h:441
#define COBC_ABORT()
Definition: cobc.h:61
#define CB_REFERENCE(x)
Definition: tree.h:901
#define CB_FILE_P(x)
Definition: tree.h:859
int size
Definition: tree.h:672
unsigned char * data
Definition: tree.h:593
cob_u32_t have_sign
Definition: tree.h:627
cb_tree cb_high
Definition: tree.c:129
#define CB_ALPHABET_NAME_P(x)
Definition: tree.h:551
size_t suppress_warn
Definition: typeck.c:90
cob_s64_t cb_get_long_long(const cb_tree x)
Definition: tree.c:1175
cob_u32_t size
Definition: tree.h:594
enum cb_usage usage
Definition: tree.h:693
cb_tree cb_low
Definition: tree.c:128

Here is the call graph for this function:

Here is the caller graph for this function:

static COB_INLINE COB_A_INLINE int value_has_picture_clause ( cb_tree  pos)
static

Definition at line 4268 of file typeck.c.

References CB_FIELD, CB_REFERENCE, NULL, and value.

Referenced by valid_screen_pos_type().

4269 {
4270  return (CB_FIELD ((CB_REFERENCE (pos))->value))->pic != NULL;
4271 }
strict implicit external value
Definition: warning.def:54
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
#define CB_FIELD(x)
Definition: tree.h:740

Here is the caller graph for this function:

static COB_INLINE COB_A_INLINE int value_is_numeric_field ( cb_tree  pos)
static

Definition at line 4260 of file typeck.c.

References CB_CATEGORY_NUMERIC, CB_FIELD_P, CB_REFERENCE, and value.

Referenced by valid_screen_pos_type().

4261 {
4262  return CB_FIELD_P ((CB_REFERENCE (pos))->value)
4263  && (CB_REFERENCE (pos))->value->category == CB_CATEGORY_NUMERIC;
4264 
4265 }
strict implicit external value
Definition: warning.def:54
#define CB_FIELD_P(x)
Definition: tree.h:741
#define CB_REFERENCE(x)
Definition: tree.h:901

Here is the caller graph for this function:

static COB_INLINE COB_A_INLINE int value_pic_has_no_scale ( cb_tree  pos)
static

Definition at line 4274 of file typeck.c.

References CB_FIELD, CB_REFERENCE, and value.

Referenced by valid_screen_pos_type().

4275 {
4276  return (CB_FIELD ((CB_REFERENCE (pos))->value))->pic->scale == 0;
4277 }
strict implicit external value
Definition: warning.def:54
#define CB_REFERENCE(x)
Definition: tree.h:901
#define CB_FIELD(x)
Definition: tree.h:740

Here is the caller graph for this function:

static void warning_destination ( cb_tree  x)
static

Definition at line 5969 of file typeck.c.

References _, CB_FIELD, cb_name(), CB_REFERENCE, CB_TREE, CB_USAGE_DOUBLE, CB_USAGE_FLOAT, CB_USAGE_FP_BIN128, CB_USAGE_FP_BIN32, CB_USAGE_FP_BIN64, CB_USAGE_FP_DEC128, CB_USAGE_FP_DEC64, CB_USAGE_LONG_DOUBLE, cb_warning(), cb_warning_x(), cb_field::flag_real_binary, cb_field::name, cb_reference::offset, cb_picture::orig, cb_field::pic, cb_field::size, cb_field::usage, and cb_reference::value.

Referenced by move_warning().

5970 {
5971  struct cb_reference *r;
5972  struct cb_field *f;
5973  cb_tree loc;
5974 
5975  r = CB_REFERENCE (x);
5976  f = CB_FIELD (r->value);
5977  loc = CB_TREE (f);
5978 
5979  if (r->offset) {
5980  return;
5981  }
5982 
5983  if (!strcmp (f->name, "RETURN-CODE") ||
5984  !strcmp (f->name, "SORT-RETURN") ||
5985  !strcmp (f->name, "NUMBER-OF-CALL-PARAMETERS")) {
5986  cb_warning (_("Internal register '%s' defined as BINARY-LONG"),
5987  f->name);
5988  } else if (f->flag_real_binary) {
5989  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
5990  f->name, f->pic->orig);
5991  } else if (f->usage == CB_USAGE_FLOAT) {
5992  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
5993  f->name, "FLOAT");
5994  } else if (f->usage == CB_USAGE_DOUBLE) {
5995  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
5996  f->name, "DOUBLE");
5997  } else if (f->usage == CB_USAGE_LONG_DOUBLE) {
5998  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
5999  f->name, "FLOAT EXTENDED");
6000  } else if (f->usage == CB_USAGE_FP_BIN32) {
6001  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
6002  f->name, "FLOAT-BINARY-7");
6003  } else if (f->usage == CB_USAGE_FP_BIN64) {
6004  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
6005  f->name, "FLOAT-BINARY-16");
6006  } else if (f->usage == CB_USAGE_FP_BIN128) {
6007  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
6008  f->name, "FLOAT-BINARY-34");
6009  } else if (f->usage == CB_USAGE_FP_DEC64) {
6010  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
6011  f->name, "FLOAT-DECIMAL-16");
6012  } else if (f->usage == CB_USAGE_FP_DEC128) {
6013  cb_warning_x (loc, _("'%s' defined here as USAGE %s"),
6014  f->name, "FLOAT-DECIMAL-34");
6015  } else if (f->pic) {
6016  cb_warning_x (loc, _("'%s' defined here as PIC %s"),
6017  cb_name (loc), f->pic->orig);
6018  } else {
6019  cb_warning_x (loc, _("'%s' defined here as a group of length %d"),
6020  cb_name (loc), f->size);
6021  }
6022 }
const char * name
Definition: tree.h:645
unsigned int flag_real_binary
Definition: tree.h:708
#define CB_TREE(x)
Definition: tree.h:440
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
cb_tree value
Definition: tree.h:876
char * cb_name(cb_tree x)
Definition: tree.c:735
struct cb_picture * pic
Definition: tree.h:659
char * orig
Definition: tree.h:620
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
cb_tree offset
Definition: tree.h:878
#define CB_REFERENCE(x)
Definition: tree.h:901
int size
Definition: tree.h:672
void cb_warning(const char *,...) COB_A_FORMAT12
Definition: error.c:87
enum cb_usage usage
Definition: tree.h:693
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const struct optim_table bin_add_funcs[]
static

Definition at line 343 of file typeck.c.

const struct optim_table bin_compare_funcs[]
static

Definition at line 308 of file typeck.c.

const struct optim_table bin_set_funcs[]
static
Initial value:
= {
{ ((void*)0) , COB_OPTIM_MIN },
{ "cob_setswp_u16", COB_SETSWP_U16 },
{ "cob_setswp_u24", COB_SETSWP_U24 },
{ "cob_setswp_u32", COB_SETSWP_U32 },
{ "cob_setswp_u40", COB_SETSWP_U40 },
{ "cob_setswp_u48", COB_SETSWP_U48 },
{ "cob_setswp_u56", COB_SETSWP_U56 },
{ "cob_setswp_u64", COB_SETSWP_U64 },
{ ((void*)0) , COB_OPTIM_MIN },
{ "cob_setswp_s16", COB_SETSWP_S16 },
{ "cob_setswp_s24", COB_SETSWP_S24 },
{ "cob_setswp_s32", COB_SETSWP_S32 },
{ "cob_setswp_s40", COB_SETSWP_S40 },
{ "cob_setswp_s48", COB_SETSWP_S48 },
{ "cob_setswp_s56", COB_SETSWP_S56 },
{ "cob_setswp_s64", COB_SETSWP_S64 }
}

Definition at line 289 of file typeck.c.

const struct optim_table bin_sub_funcs[]
static

Definition at line 378 of file typeck.c.

cb_tree cb_debug_item

Definition at line 82 of file typeck.c.

cb_tree cb_debug_line

Definition at line 83 of file typeck.c.

Referenced by output_stmt().

cb_tree cb_debug_sub_1

Definition at line 85 of file typeck.c.

cb_tree cb_debug_sub_2

Definition at line 86 of file typeck.c.

cb_tree cb_debug_sub_3

Definition at line 87 of file typeck.c.

const unsigned char cob_refer_ascii[256]
static

Definition at line 206 of file typeck.c.

Referenced by cb_validate_program_environment().

const unsigned char cob_refer_ebcdic[256]
static

Definition at line 242 of file typeck.c.

Referenced by cb_validate_program_environment().

cb_tree decimal_stack = ((void*)0)
static

Definition at line 94 of file typeck.c.

int expr_index
static
cb_tree expr_lh
static

Definition at line 100 of file typeck.c.

int expr_op
static

Definition at line 99 of file typeck.c.

Referenced by cb_expr_init(), cb_expr_shift(), and expr_reduce().

unsigned char expr_prio[256]
static

Definition at line 199 of file typeck.c.

Referenced by cobc_init_typeck(), and expr_reduce().

struct expr_node* expr_stack
static

Definition at line 107 of file typeck.c.

int expr_stack_size
static

Definition at line 106 of file typeck.c.

Referenced by cb_expr_init(), and cb_expr_shift().

const unsigned char hexval[] = "0123456789ABCDEF"
static

Definition at line 109 of file typeck.c.

Referenced by cb_encode_program_id(), output_integer(), and output_long_integer().

size_t initialized = 0
static

Definition at line 102 of file typeck.c.

Referenced by cb_expr_init(), CHECKSRC_(), cobxref_(), GCic_(), get__reserved__lists_(), and LISTING_().

cb_tree inspect_data
static

Definition at line 97 of file typeck.c.

size_t overlapping = 0
static

Definition at line 103 of file typeck.c.

Referenced by cb_build_move_copy(), and validate_move().

const unsigned char pvalid_char[]
static
Initial value:
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"

Definition at line 201 of file typeck.c.

Referenced by cobc_init_typeck().

size_t suppress_warn = 0

Definition at line 90 of file typeck.c.

Referenced by cb_check_overlapping(), move_warning(), output_move(), and validate_move().

const struct system_table system_tab[]
static

Definition at line 282 of file typeck.c.

unsigned char valid_char[256]
static

Definition at line 200 of file typeck.c.

Referenced by cb_encode_program_id(), and cobc_init_typeck().