一、前言
很忙,很久没更新博客了,继续没写完的gcc分析,争取在传说将要用C++重写的gcc 5出来之前初略分析完。
二、符号表(GENERIC)
前篇介绍了gcc的语法分析,在语法分析过程中,所有识别出来的语言部件都用一个叫TREE的变量保存着。这个TREE就是gcc语法树,叫做GENERIC。实际上它也是gcc的符号表,因为变量名、类型等等这些信息都由TREE关联起来。
GENERIC的节点都定义在gcc/tree.h头文件里。它将GENERIC按类别分为若干类:
enum tree_code_class {
tcc_exceptional, /* An exceptional code (fits no category). */
tcc_constant, /* A constant. */
/* Order of tcc_type and tcc_declaration is important. */
tcc_type, /* A type object code. */
tcc_declaration, /* A declaration (also serving as variable refs). */
tcc_reference, /* A reference to storage. */
tcc_comparison, /* A comparison expression. */
tcc_unary, /* A unary arithmetic expression. */
tcc_binary, /* A