📄 cmain.c
字号:
/* * C compiler * ========== * * Copyright 1989, 1990, 1991 Christoph van Wuellen. * Credits to Matthew Brandt. * All commercial rights reserved. * * This compiler may be redistributed as long there is no * commercial interest. The compiler must not be redistributed * without its full sources. This notice must stay intact. * * History: * * 1989 starting an 68000 C compiler, starting with material * originally by M. Brandt * 1990 68000 C compiler further bug fixes * started i386 port (December) * 1991 i386 port finished (January) * further corrections in the front end and in the 68000 * code generator. * The next port will be a SPARC port *//*****************************************************************************/#include "chdr.h"#include "expr.h"#include "cglbdec.h"#include "proto.h"#include "version.h"#ifdef SIGNAL#include <signal.h>#ifndef _NSIG#ifdef NSIG#define _NSIG NSIG#endif /* NSIG */#endif /* _NSIG */#endif /* SIGNAL */#ifdef __MWERKS__#include <console.h>#include <sioux.h>#endif /* __MWERKS__ *//*********************************************** Static Function Definitions */#ifdef _NSIGstatic void exception P_ ((int));#endif /* _NSIG */static void help_option P_ ((BOOL, OPTION *, const CHAR *));static void uniq_option P_ ((BOOL, OPTION *, const CHAR *));/********************************************************** Static Variables */#ifdef DEBUGstatic OPTSET debugopts[] = { {(const CHAR *) "global", MEMBER (DEBUG_GLOBAL)}, {(const CHAR *) "peep", MEMBER (DEBUG_PEEP)}, {(const CHAR *) "expr", MEMBER (DEBUG_EXPR)}, {(const CHAR *) "code", MEMBER (DEBUG_CODE)}, {(const CHAR *) "register", MEMBER (DEBUG_REGISTER)}, {(const CHAR *) "symbol", MEMBER (DEBUG_SYMBOL)}, {(const CHAR *) "flow", MEMBER (DEBUG_FLOW)}, {(const CHAR *) "longlong", MEMBER (DEBUG_LONGLONG)}, {(const CHAR *) "all", (SETVAL) ~ 0U}, {(const CHAR *) NULL, (SETVAL) 0}};#endif /* DEBUG */static OPTENUM intopts[] = { {(const CHAR *) "16", 1}, {(const CHAR *) "32", 0}, {(const CHAR *) NULL, 0}};static OPTENUM langopts[] = { {(const CHAR *) "kandr", LANG_KANDR}, {(const CHAR *) "c90", LANG_C90}, {(const CHAR *) "c99", LANG_C99}, {(const CHAR *) NULL, 0}};static OPTENUM yesnoopts[] = { {(const CHAR *) "yes", 1}, {(const CHAR *) "no", 0}, {(const CHAR *) NULL, 0}};static OPTION opts[] = { /* * Options which affect the front-end */ { (const CHAR *) "?", help_option, {NULL}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "v", uniq_option, {&verbose_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ },#ifdef DEBUG { (const CHAR *) "debug=", set_option, {&internal_option}, /*lint !e708*/ /* union initialization */ {(void *)&debugopts[0]}/*lint !e708*/ /* union initialization */ },#endif /* DEBUG */ { (const CHAR *) "error=", numeric_option, {&error_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "warn=", numeric_option, {&warn_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "maxerr=", numeric_option, {&max_error_count}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "align=", enumeration_option, {&align_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#ifdef ASM { (const CHAR *) "asm=", enumeration_option, {&asm_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* ASM */#ifdef EXTERNAL { (const CHAR *) "extern=", enumeration_option, {&extern_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* EXTERNAL */
#ifdef FLOAT_CHECK { (const CHAR *) "fcheck=", enumeration_option, {&fcheck_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* FLOAT_CHECK */#ifdef FORMAT_CHECK { (const CHAR *) "format=", enumeration_option, {&format_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* FORMAT_CHECK */#ifdef ICODE { (const CHAR *) "icode", uniq_option, {&icode_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ },#endif /* ICODE */
#ifdef DOINLINE
{
(const CHAR *) "inline=", numeric_option,
{&inline_option}, /*lint !e708*/ /* union initialization */
{NULL} /*lint !e708*/ /* union initialization */
},
#endif /* DOINLINE */ { (const CHAR *) "int=", enumeration_option, {&short_option}, /*lint !e708*/ /* union initialization */ {&intopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "lang=", enumeration_option, {&lang_option}, /*lint !e708*/ /* union initialization */ {&langopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "lattice=", enumeration_option, {&lattice_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#ifdef LIST { (const CHAR *) "list=", enumeration_option, {&listing_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* LIST */ { (const CHAR *) "obsolete=", enumeration_option, {&obsolete_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#ifdef PACKENUM { (const CHAR *) "packenum=", enumeration_option, {&packenum_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* PACKENUM */ { (const CHAR *) "packbit=", enumeration_option, {&packbit_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */
}, {
(const CHAR *) "promoteparam=", enumeration_option,
{&promoteparam_option},/*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "revbit=", enumeration_option, {&bitfield_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#ifdef TOPSPEED { (const CHAR *) "topspeed=", enumeration_option, {&topspeed_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* TOPSPEED */ { (const CHAR *) "trad=", enumeration_option, {&trad_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "uchar=", enumeration_option, {&uchar_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, /* * Options which affect the code generation */#ifdef DEBUGOPT { (const CHAR *) "g", uniq_option, {&debug_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ },#endif /*DEBUGOPT */ { (const CHAR *) "O", uniq_option, {&optimize_option}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "code=", enumeration_option, {&code_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "longdouble=", enumeration_option, {&longdouble_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "opt=", enumeration_option, {&opt_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "pointer=", enumeration_option, {&small_option}, /*lint !e708*/ /* union initialization */ {&intopts[0]} /*lint !e708*/ /* union initialization */ }, { (const CHAR *) "separate=", enumeration_option, {&IandD_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#ifdef TRACE { (const CHAR *) "trace=", enumeration_option, {&trace_option}, /*lint !e708*/ /* union initialization */ {&yesnoopts[0]} /*lint !e708*/ /* union initialization */ },#endif /* TRACE */ { NULL, NULL, {NULL}, /*lint !e708*/ /* union initialization */ {NULL} /*lint !e708*/ /* union initialization */ }};static OPTIONS optsstd = { (const CHAR *) "Common ", opts};static OPTIONS *optsarray[] = { &optsstd,#ifdef MC680X0 &opts68k,#endif /* MC680X0 */#ifdef INTEL_386 &opts386,#endif /* INTEL_386 */#ifdef INTEL_86 &opts86,#endif /* INTEL_86 */#ifdef TMS320C30 &optsc30,#endif /* TMS320C30 */#ifdef ARM &optsarm,#endif /* ARM */ (OPTIONS *) NULL};/*****************************************************************************//*ARGSUSED2 */static void uniq_option P3 (BOOL, set, OPTION *, optptr, const CHAR *, arg){ arg = arg; /* keep compiler quiet */ if (set) { *(optptr->u1.ip) = 1; } else { if (*(optptr->u1.ip)) { eprintf ("-%s", optptr->text); } else { eprintf ("\t"); } eprintf ("\t\t-%s%s", optptr->text, newline); }}void numeric_option P3 (BOOL, set, const OPTION *, optptr, const CHAR *, arg)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -