📄 genicode.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 *//****************************************************************************** * * This module performs a symbolic dump of the parse tree * *****************************************************************************/#include "config.h"#ifdef ICODE#include "chdr.h"#include "expr.h"#include "cglbdec.h"#include "proto.h"/********************************************************* Macro Definitions */#define INDENTATION 2 /* number of columns to indent *//*********************************************** Static Function Definitions */static void type P_ ((const TYP *));static void g_icode P_ ((const EXPR *, int));/*****************************************************************************/static void type P1 (const TYP *, tp){ iprintf (" %ld ", tp->size); if (is_const_qualified (tp)) { iprintf ("const "); } if (is_volatile_qualified (tp)) { iprintf ("volatile "); } if (is_restrict_qualified (tp)) { iprintf ("restrict"); } switch (tp->type) { case bt_bool: iprintf ("_Bool "); break; case bt_uchar: iprintf ("unsigned "); /*lint -fallthrough */ case bt_char: case bt_charu: iprintf ("char "); break; case bt_schar: iprintf ("signed char "); break; case bt_ushort: iprintf ("unsigned "); /*lint -fallthrough */ case bt_short: iprintf ("short "); break; case bt_uint16: case bt_uint32: iprintf ("unsigned "); /*lint -fallthrough */ case bt_int16: case bt_int32: iprintf ("int "); break; case bt_ulong: iprintf ("unsigned "); /*lint -fallthrough */ case bt_long: iprintf ("long "); break; case bt_pointer16: case bt_pointer32: if (is_array_type (tp)) { iprintf ("array of "); } else { iprintf ("pointer to "); } type (referenced_type (tp)); break; case bt_longlong: iprintf ("long long "); break; case bt_ulonglong: iprintf ("unsigned long long "); break; case bt_struct: iprintf ("struct "); break; case bt_union: iprintf ("union "); break; case bt_func: iprintf ("function returning "); type (returned_type (tp)); break; case bt_longdouble: iprintf ("long "); /*lint -fallthrough */ case bt_double: iprintf ("double "); break; case bt_float: iprintf ("float "); break; case bt_floatcomplex: iprintf ("float _Complex "); break; case bt_doublecomplex: iprintf ("double _Complex "); break; case bt_longdoublecomplex: iprintf ("long double _Complex "); break; case bt_floatimaginary: iprintf ("float _Imaginary "); break; case bt_doubleimaginary: iprintf ("double _Imaginary "); break; case bt_longdoubleimaginary: iprintf ("long double _Imaginary "); break; case bt_void: iprintf ("void "); break; case bt_bitfield: iprintf ("int (bitfield) "); break; case bt_ubitfield: iprintf ("unsigned int (bitfield) "); break; case bt_bbitfield: iprintf ("_Bool (bitfield) "); break; case bt_ellipsis: iprintf ("... "); break; default: FATAL ((__FILE__, "type", "illegal type %d", tp->type)); }}/* * general expression evaluation. symbolic dump. */static void g_icode P2 (const EXPR *, ep, int, indent){ int j; for (j = indent; j >= 0; j--) iprintf (" "); if (ep == NIL_EXPR) { iprintf ("*NULL%s", newline); return; } switch (ep->nodetype) { case en_icon: iprintf ("*icon %ld", (long) ep->v.i); type (ep->etp); iprintf ("%s", newline); break;#ifdef FLOAT_SUPPORT case en_fcon: iprintf ("*fcon %20.10f", ep->v.f); type (ep->etp); iprintf ("%s", newline); break;#endif /* FLOAT_SUPPORT */ case en_sym: iprintf ("*sym %s", nameof (ep->v.sp)); type (ep->etp); iprintf ("%s", newline); break; case en_labcon: iprintf ("*labcon L%u", (unsigned) ep->v.l); type (ep->etp); iprintf ("%s", newline); break; case en_nacon: iprintf ("*nacon %s", ep->v.str); type (ep->etp); iprintf ("%s", newline); break; case en_autocon: iprintf ("*autocon %ld", (long) ep->v.i); type (ep->etp); iprintf ("%s", newline); break; case en_global: iprintf ("*global %s", ep->v.str); type (ep->etp); iprintf ("%s", newline); break; case en_ref: iprintf ("*ref"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); break; case en_fieldref: iprintf ("*fref (%d,%d)", (int) ep->v.bit.offset, (int) ep->v.bit.width); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); break; case en_register: iprintf ("*register %d", (int) ep->v.r); type (ep->etp); iprintf ("%s", newline); break; case en_uminus: iprintf ("*uminus"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); break; case en_compl: iprintf ("*compl"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); break; case en_add: iprintf ("*add"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION); break; case en_sub: iprintf ("*sub"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_and: iprintf ("*and"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_or: iprintf ("*or"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_xor: iprintf ("*xor"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_mul: iprintf ("*mul"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_div: iprintf ("*div"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_mod: iprintf ("*mod"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_lsh: iprintf ("*lsh"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_rsh: iprintf ("*rsh"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_asadd: iprintf ("*asadd"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_assub: iprintf ("*assub"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_asand: iprintf ("*asand"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_asor: iprintf ("*asor"); type (ep->etp); iprintf ("%s", newline); g_icode (ep->v.p[0], indent + INDENTATION); g_icode (ep->v.p[1], indent + INDENTATION);; break; case en_asxor: iprintf ("*asxor");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -