LCC编译器的源程序分析(64)符号表的结构注释

#001 //符号表结构.
#002 //
#003 //蔡军生 2007/08/10 QQ:9073204
#004 //
#005 struct symbol
#006 {
#007  char *name; //符号的名称,大多数情况是源程序的符号.
#008  int scope; //符号作用域.
#009  Coordinate src; //符号出现在文件中的行号和列号.
#010  Symbol up; //
#011  List uses;
#012  int sclass; //符号的类型.
#013  unsigned structarg:1; //结构参数标志.
#014 
#015  unsigned addressed:1; //地址访问的变量.
#016  unsigned computed:1; //地址树的标志.addrtree函数处理.
#017  unsigned temporary:1; //生成的临时变量标志.
#018  unsigned generated:1; //生成的符号标志.
#019  unsigned defined:1; //符号被定义了,避免声明多次.
#020  Type type; //变量或者常量的类型.
#021  float ref; //标号或变量的引用计数.
#022  union
#023  {
#024         //保存标号.
#025          struct
#026         {              
#027               int label; //全局分配唯一的标号,这时name保存标号字符串.
#028               Symbol equatedto;
#029         } l;
#030 
#031         struct
#032         {
#033               unsigned cfields:1;
#034               unsigned vfields:1;
#035               Table ftab;       /* omit */
#036               Field flist;
#037         } s;
#038 
#039         int value;
#040         Symbol *idlist;
#041 
#042         struct
#043         {
#044               Value min, max;
#045         } limits;
#046 
#047         //保存常量的结构.
#048         struct
#049         {
#050               Value v; //保存实际的常量值.
#051               Symbol loc; //指向符号表的入口.
#052         } c;
#053        
#054         struct
#055         {
#056               Coordinate pt;
#057               int label;
#058               int ncalls;
#059               Symbol *callee;
#060         } f;
#061        
#062         //全局变量或静态变量给出定义的段.
#063         int seg;
#064 
#065         Symbol alias;
#066        
#067         struct
#068         {
#069               //前端生成多次引用公共表达式的临时变量的DAG节点.
#070               Node cse;
#071 
#072               //
#073               int replace;
#074               Symbol next;
#075         } t;
#076 
#077  } u;
#078 
#079  Xsymbol x; //后端使用的符号扩展。
#080 };

留下评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据