[ Top ] [ Modules ]
AUTHOR
Keisuke Nishida Roger While
COPYRIGHT
(c) 2001-2009 Keisuke Nishida (c) 2007-2009 Roger While
LICENCE
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
FUNCTION
Invoke the OpenCOBOL compiler
SOURCE
enum cb_compile_level { CB_LEVEL_PREPROCESS = 1, CB_LEVEL_TRANSLATE, CB_LEVEL_COMPILE, CB_LEVEL_ASSEMBLE, CB_LEVEL_MODULE, CB_LEVEL_LIBRARY, CB_LEVEL_EXECUTABLE };
[ Top ] [ cobc ] [ Variables ]
SOURCE
int cb_source_format = CB_FORMAT_FIXED;
[ Top ] [ cobc ] [ Variables ]
SOURCE
int cb_id = 1; int cb_attr_id = 1; int cb_literal_id = 1; int cb_field_id = 1; int cb_storage_id = 1; int cb_flag_main = 0; int errorcount = 0; int warningcount = 0; int alt_ebcdic = 0; int optimize_flag = 0; char *cb_source_file = NULL; char *cb_oc_build_stamp = NULL; char *source_name; char *demangle_name; int cb_source_line = 0; FILE *cb_storage_file; char *cb_storage_file_name; FILE *cb_listing_file = NULL; FILE *cb_depend_file = NULL; char *cb_depend_target = NULL; struct cb_text_list *cb_depend_list = NULL; struct cb_text_list *cb_include_list = NULL; struct cb_text_list *cb_extension_list = NULL; int cb_saveargc; char **cb_saveargv; const char *cob_config_dir;
[ Top ] [ cobc ] [ Variables ]
SOURCE
static const char *const cob_csyns[] = { "NULL", "L_initextern", "LRET_initextern", #ifndef __GNUC__ "P_switch", #endif "alignof", "asm", "auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "exit_program", "extern", "float", "for", "frame_pointer", "frame_stack", "goto", "if", "inline", "int", "long", "offsetof", "register", "restrict", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", "typeof", "union", "unsigned", "void", "volatile", "_Bool", "_Complex", "_Imaginary" }; #define COB_NUM_CSYNS sizeof(cob_csyns) / sizeof(char *) static enum cb_compile_level cb_compile_level = 0; static enum cb_compile_level local_level = 0; static size_t iparams = 0; static int iargs; static char *cobcpy = NULL; static char *save_temps_dir = NULL; static jmp_buf cob_jmpbuf; static int wants_nonfinal = 0; static int cb_flag_module = 0; static int cb_flag_library = 0; static int save_temps = 0; static int save_csrc = 0; static int verbose_output = 0; static int cob_iteration = 0; #ifndef _WIN32 static pid_t cob_process_id = 0; #endif static int strip_output = 0; static int gflag_set = 0; static char *output_name; static const char *cob_tmpdir; /* /tmp */ static struct filename *file_list; /* NOTE fcopts MUST have at least one leading space */ #if defined (__GNUC__) && (__GNUC__ >= 3) static const char fcopts[] = " -finline-functions -fno-gcse -freorder-blocks "; #elif defined(__xlc__) static const char fcopts[] = " -Q -qro -qroconst "; #else static const char fcopts[] = " "; #endif #if defined (__GNUC__) && (__GNUC__ >= 3) static const char gccpipe[] = "-pipe"; #else static const char gccpipe[] = "\0"; #endif #ifdef HAVE_SIGNAL_H typedef void (*cob_sighandler_t) (int); static cob_sighandler_t hupsig = NULL; static cob_sighandler_t intsig = NULL; static cob_sighandler_t qutsig = NULL; #endif
[ Top ] [ cobc ] [ Variables ]
SOURCE
static const char short_options[] = "hVvECScbmxOgwo:t:I:L:l:D:";
[ Top ] [ cobc ] [ Variables ]
SOURCE
static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, /* getopt_long_only has a problem with eg. -xv - remove {"verbose", no_argument, NULL, 'v'}, */ {"list-reserved", no_argument, NULL, 'R'}, {"list-intrinsics", no_argument, NULL, 'Q'}, {"list-mnemonics", no_argument, NULL, 'q'}, {"save-temps", optional_argument, NULL, '_'}, {"std", required_argument, NULL, '$'}, {"conf", required_argument, NULL, '&'}, {"debug", no_argument, NULL, 'd'}, {"ext", required_argument, NULL, 'e'}, {"free", no_argument, &cb_source_format, CB_FORMAT_FREE}, {"fixed", no_argument, &cb_source_format, CB_FORMAT_FIXED}, {"static", no_argument, &cb_flag_static_call, 1}, {"dynamic", no_argument, &cb_flag_static_call, 0}, {"O2", no_argument, NULL, '2'}, {"Os", no_argument, NULL, 's'}, {"MT", required_argument, NULL, '%'}, {"MF", required_argument, NULL, '@'}, #undef CB_FLAG #define CB_FLAG(var,name,doc) \ {"f"name, no_argument, &var, 1}, \ {"fno-"name, no_argument, &var, 0}, #include "flag.def" #undef CB_FLAG {"Wall", no_argument, NULL, 'W'}, {"W", no_argument, NULL, 'Z'}, #undef CB_WARNDEF #define CB_WARNDEF(var,name,wall,doc) \ {"W"name, no_argument, &var, 1}, \ {"Wno-"name, no_argument, &var, 0}, #include "warning.def" #undef CB_WARNDEF {NULL, 0, NULL, 0} };
[ Top ] [ cobc ] [ Variables ]
SOURCE
static const char *cob_cc; /* gcc */ static char cob_cflags[COB_SMALL_BUFF]; /* -I... */ static char cob_libs[COB_MEDIUM_BUFF]; /* -L... -lcob */ static char cob_define_flags[COB_SMALL_BUFF]; /* -D... */ static const char *cob_ldflags; static const char *cob_copy_dir;
[ Top ] [ cobc ] [ Functions ]
SUMMARY
Abort compile from internal errorr. Display file and line
SOURCE
void cobc_abort (const char *filename, const int linenum) { fprintf (stderr, "%s:%d: Internal compiler error\n", filename, linenum); (void)longjmp (cob_jmpbuf, 1); }
[ Top ] [ cobc ] [ Functions ]
SUMMARY
Abort compile with invalid internal type cast. Display file, line, and tag information
SOURCE
void cobc_tree_cast_error (cb_tree x, const char *filen, const int linenum, const int tagnum) { fprintf (stderr, "%s:%d: Invalid type cast from '%s'\n", filen, linenum, x ? cb_name (x) : "null"); fprintf (stderr, "Tag 1 %d Tag 2 %d\n", x ? CB_TREE_TAG(x) : 0, tagnum); (void)longjmp (cob_jmpbuf, 1); }
[ Top ] [ cobc ] [ Functions ]
SUMMARY
Allocate memory;
SOURCE
void * cobc_malloc (const size_t size) { void *mptr; mptr = calloc (1, size); if (!mptr) { fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", (int)size); fflush (stderr); (void)longjmp (cob_jmpbuf, 1); } return mptr; }
[ Top ] [ cobc ] [ Functions ]
SUMMARY
Reallocate memory;
SOURCE
void * cobc_realloc (void *prevptr, const size_t size) { void *mptr; mptr = realloc (prevptr, size); if (!mptr) { fprintf (stderr, "Cannot reallocate %d bytes of memory - Aborting\n", (int)size); fflush (stderr); (void)longjmp (cob_jmpbuf, 1); } return mptr; }