FANDOM


このページを編集する際は,編集に関する方針に従ってください. 編集

概要 編集

実装 編集

gcc-4.1.0/gcc/coretype.h内に,

44 union tree_node;
45 typedef union tree_node *tree;

とあって,これが tree 型変数の正体らしい.
tree 型変数は,struct tree_int_cststruct tree_real_cst … などなど,さまざまな構造体を指す.
しかし,struct tree_* 構造体は,かならず先頭メンバにstruct tree_common構造体を持っている.
そのため,tree 型変数が指している実体が何であれ,tree_foo->common の参照は, 必ず合法となる.

2799 /* Define the overall contents of a tree node.
2800    It may be any of the structures declared above
2801    for various types of node.  */
2802 
2803 union tree_node GTY ((ptr_alias (union lang_tree_node),
2804                       desc ("tree_node_structure (&%h)")))
2805 {
2806   struct tree_common GTY ((tag ("TS_COMMON"))) common;
2807   struct tree_int_cst GTY ((tag ("TS_INT_CST"))) int_cst;
2808   struct tree_real_cst GTY ((tag ("TS_REAL_CST"))) real_cst;
2809   struct tree_vector GTY ((tag ("TS_VECTOR"))) vector;
2810   struct tree_string GTY ((tag ("TS_STRING"))) string;
2811   struct tree_complex GTY ((tag ("TS_COMPLEX"))) complex;
2812   struct tree_identifier GTY ((tag ("TS_IDENTIFIER"))) identifier;
2813   struct tree_decl_minimal GTY((tag ("TS_DECL_MINIMAL"))) decl_minimal;
2814   struct tree_decl_common GTY ((tag ("TS_DECL_COMMON"))) decl_common;
2815   struct tree_decl_with_rtl GTY ((tag ("TS_DECL_WRTL"))) decl_with_rtl;
2816   struct tree_decl_non_common  GTY ((tag ("TS_DECL_NON_COMMON"))) decl_non_common;
2817   struct tree_parm_decl  GTY  ((tag ("TS_PARM_DECL"))) parm_decl;
2818   struct tree_decl_with_vis GTY ((tag ("TS_DECL_WITH_VIS"))) decl_with_vis;
2819   struct tree_var_decl GTY ((tag ("TS_VAR_DECL"))) var_decl;
2820   struct tree_field_decl GTY ((tag ("TS_FIELD_DECL"))) field_decl;
2821   struct tree_label_decl GTY ((tag ("TS_LABEL_DECL"))) label_decl;
2822   struct tree_result_decl GTY ((tag ("TS_RESULT_DECL"))) result_decl;
2823   struct tree_const_decl GTY ((tag ("TS_CONST_DECL"))) const_decl;
2824   struct tree_type_decl GTY ((tag ("TS_TYPE_DECL"))) type_decl;
2825   struct tree_function_decl GTY ((tag ("TS_FUNCTION_DECL"))) function_decl;
2826   struct tree_type GTY ((tag ("TS_TYPE"))) type;
2827   struct tree_list GTY ((tag ("TS_LIST"))) list;
2828   struct tree_vec GTY ((tag ("TS_VEC"))) vec;
2829   struct tree_exp GTY ((tag ("TS_EXP"))) exp;
2830   struct tree_ssa_name GTY ((tag ("TS_SSA_NAME"))) ssa_name;
2831   struct tree_phi_node GTY ((tag ("TS_PHI_NODE"))) phi;
2832   struct tree_block GTY ((tag ("TS_BLOCK"))) block;
2833   struct tree_binfo GTY ((tag ("TS_BINFO"))) binfo;
2834   struct tree_statement_list GTY ((tag ("TS_STATEMENT_LIST"))) stmt_list;
2835   struct tree_value_handle GTY ((tag ("TS_VALUE_HANDLE"))) value_handle;
2836   struct tree_constructor GTY ((tag ("TS_CONSTRUCTOR"))) constructor;
2837 };

common へのアクセスには,TREE_CODE マクロを使用する.



リンク元