ctrump/ast/ast.h File Reference

C99 構文木定義. More...

#include "ctrump/ast/types.h"
#include "ctrump/ast/location.h"
#include "ctrump/ast/source-string.h"
#include "ctrump/analyzer/loop.h"
#include "ctrump/analyzer/cfg.h"
#include "ctrump/ast/expr-code.h"
#include "ctrump/ast/abi.h"
#include "ctrump/common/dll.h"

Include dependency graph for ast.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ctrump_initializer
 初期化子 More...
struct  ctrump_designator_index
 配列の要素指示子 More...
struct  ctrump_designator_ident
 構造体の要素指示子 More...
struct  ctrump_designator
 指示 More...
struct  ctrump_initializer_list_elem
 初期化子リストの要素 More...
struct  ctrump_initializer_list
 初期化子リスト More...
struct  ctrump_record_definition
 union, struct の定義 More...
struct  ctrump_named_record_definition
 名前付き union, struct の定義 More...
struct  ctrump_anon_record_definition
 匿名 union, struct の定義 More...
struct  ctrump_typespec_record_name
 定義無し、名前のみの union, struct のtypespec More...
struct  ctrump_typespec_enum_name
 定義無し、名前のみの enum のtypespec More...
struct  ctrump_enum_list_elem
 列挙型定義 More...
struct  ctrump_enum_list
 列挙型定義並び More...
struct  ctrump_anon_enum_definition
 匿名列挙型定義 More...
struct  ctrump_named_enum_definition
 名前付き列挙型定義 More...
struct  ctrump_typespec_typedef_name
 typedefされた名前による型指定子 More...
struct  ctrump_typespec_builtin
 組み込み型による型指定子 More...
struct  ctrump_typespec
 型指定(type-specifier) More...
struct  ctrump_decl_specifier
 宣言指定子列 More...
struct  ctrump_binary_expr
 二項演算子式 More...
struct  ctrump_cond_expr
 条件演算子 More...
struct  ctrump_call_expr
 関数呼び出し More...
struct  ctrump_var
 変数 More...
struct  ctrump_varref_expr
 変数参照 More...
struct  ctrump_typename
 型名 More...
struct  ctrump_cast_expr
 キャスト More...
struct  ctrump_implicit_cast_expr
 暗黙のキャスト More...
struct  ctrump_initializer_expr
 複合リテラル More...
struct  ctrump_macro_expand_expr
 マクロ展開式(未実装) More...
struct  ctrump_sizeof_type
 sizeof (type) More...
struct  ctrump_member_ref
 メンバ選択 More...
struct  ctrump_string_literal
 文字列リテラル More...
struct  ctrump_string_literal_list
 文字列リテラルの並び More...
struct  ctrump_arr_ref_expr
 添字式 More...
struct  ctrump_paren_expr
 括弧でくくられた式 More...
struct  ctrump_unary_expr
 単項式 More...
struct  ctrump_float_literal
 浮動小数リテラル More...
struct  ctrump_integer_literal
 整数リテラル More...
struct  ctrump_ivtmp
 式をivに置きかえるノード(未実装) More...
struct  ctrump_expr
 式の定義 More...
struct  ctrump_declarator_pointer
 ポインタ宣言子 More...
struct  ctrump_declarator_array
 配列宣言子 More...
struct  ctrump_declarator_param
 型あり関数宣言子の仮引数 More...
struct  ctrump_declarator_param_typelist
 型あり関数宣言子 More...
struct  ctrump_declarator_idlist_param
 伝統的形式の関数宣言の識別子並びの引数 More...
struct  ctrump_declarator_param_idlist
 伝統的形式の関数宣言の識別子並び More...
struct  ctrump_declarator_identifier
 単純宣言子 More...
struct  ctrump_declarator_varlen_array
 可変長配列宣言子 More...
struct  ctrump_declarator_incomplete_array
 不完全配列宣言子 More...
struct  ctrump_declarator_paren
 括弧で括られた宣言子 More...
struct  ctrump_declarator_node
 宣言子 More...
struct  ctrump_declarator
 宣言子(declarator) More...
struct  ctrump_decl_with_init
 初期化子付き宣言子 More...
struct  ctrump_decl
 宣言(declaration) More...
struct  ctrump_struct_declarator
 メンバ宣言子(struct-declarator) More...
struct  ctrump_struct_decl_decl
 メンバ宣言 More...
struct  ctrump_struct_decl
 メンバ宣言 More...
struct  ctrump_ifdef_stmt
 ifdef ブロック (未実装) More...
struct  ctrump_labeled_stmt
 ラベル付き文 More...
struct  ctrump_case_stmt
 caseラベル付き文 More...
struct  ctrump_default_stmt
 defaultラベル付き文 More...
struct  ctrump_expr_stmt
 式文 More...
struct  ctrump_if_stmt
 条件文(else無し) More...
struct  ctrump_if_else_stmt
 条件文(else有り) More...
struct  ctrump_switch_stmt
 switch 文 More...
struct  ctrump_for_stmt
 for文(宣言無し) More...
struct  ctrump_for_decl_stmt
 for文(宣言あり) More...
struct  ctrump_while_stmt
 while 文 More...
struct  ctrump_do_while_stmt
 do-while文 More...
struct  ctrump_goto_stmt
 goto文 More...
struct  ctrump_return_expr_stmt
 値ありのreturn文 More...
struct  ctrump_compound_stmt
 複合文 More...
struct  ctrump_asm_stmt_reg
 asm文(未実装) More...
struct  ctrump_asm_stmt_clobber
 asm文(未実装) More...
struct  ctrump_asm_stmt
 asm文(未実装) More...
struct  ctrump_continue_stmt
 continue文 More...
struct  ctrump_break_stmt
 break文 More...
struct  ctrump_return_stmt
 値無しのreturn文 More...
struct  ctrump_empty_stmt
 空文 More...
struct  ctrump_stmt_list
 文リスト(トランスレータで使用) More...
struct  ctrump_stmt
 More...
struct  ctrump_fundef
 関数定義 More...
struct  ctrump_ext_include
 include 文(未実装) More...
struct  ctrump_ext_include_path
 include文(トランスレータが使用) More...
struct  ctrump_ext_ifdef_block
 ifdef 文(未実装) More...
struct  ctrump_ext_gcc_cpp_note
 GCC の CPPが出力する linemarker # line "path_str" [cpp_code]+. More...
struct  ctrump_extdecl
 最上位宣言 More...
struct  ctrump_translation_unit
 翻訳単位 More...

Defines

#define CTRUMP_INITIALIZER_HAVE_LAST_COMMA   (1<<0)
#define CTRUMP_ENUM_LIST_HAVE_LAST_COMMA   (1<<0)
#define CTRUMP_ASM_HAVE_OUTPUT   0
#define CTRUMP_ASM_HAVE_INPUT   1
#define CTRUMP_ASM_HAVE_CLOBBER   2

Enumerations

enum  ctrump_designator_code { CTRUMP_DESIGNATOR_IDENT, CTRUMP_DESIGNATOR_INDEX }
 要素指示子の種類 More...
enum  ctrump_initializer_code { CTRUMP_INITIALIZER_EMPTY, CTRUMP_INITIALIZER_EXPR, CTRUMP_INITIALIZER_NESTED }
 初期化子の種類 More...
enum  ctrump_typespec_code {
  CTRUMP_TYPESPEC_BUILTIN, CTRUMP_TYPESPEC_UNTYPED_SIGNED_INT, CTRUMP_TYPESPEC_TYPEDEF_NAME, CTRUMP_TYPESPEC_STRUCT_NAME,
  CTRUMP_TYPESPEC_STRUCT_DEFINITION, CTRUMP_TYPESPEC_UNION_NAME, CTRUMP_TYPESPEC_UNION_DEFINITION, CTRUMP_TYPESPEC_ANON_STRUCT_DEFINITION,
  CTRUMP_TYPESPEC_ANON_UNION_DEFINITION, CTRUMP_TYPESPEC_ENUM_NAME, CTRUMP_TYPESPEC_ENUM_DEFINITION, CTRUMP_TYPESPEC_ANON_ENUM_DEFINITION
}
 型指定子 More...
enum  ctrump_func_specifier { CTRUMP_FUNC_SPEC_INLINE, CTRUMP_FUNC_SPEC_UNSPECIFIED }
 関数指定子 More...
enum  ctrump_stor_class {
  CTRUMP_STOR_CLASS_EXTERN, CTRUMP_STOR_CLASS_STATIC, CTRUMP_STOR_CLASS_AUTO, CTRUMP_STOR_CLASS_REGISTER,
  CTRUMP_STOR_CLASS_TYPEDEF, CTRUMP_STOR_CLASS_AUTO_UNSPECIFIED, CTRUMP_STOR_CLASS_EXTDEF, CTRUMP_STOR_CLASS_ARGMENT,
  CTRUMP_STOR_CLASS_FIELD
}
 記憶域指定子 More...
enum  ctrump_declarator_code {
  CTRUMP_DECLARATOR_IDENTIFIER, CTRUMP_DECLARATOR_EMPTY, CTRUMP_DECLARATOR_POINTER, CTRUMP_DECLARATOR_ARRAY,
  CTRUMP_DECLARATOR_VARLEN_ARRAY, CTRUMP_DECLARATOR_INCOMPLETE_ARRAY, CTRUMP_DECLARATOR_PARAM_TYPELIST, CTRUMP_DECLARATOR_PARAM_IDENTIFIER_LIST,
  CTRUMP_DECLARATOR_PAREN
}
 宣言子の種類 More...
enum  ctrump_struct_decl_code { CTRUMP_STRUCT_DECL_EMPTY, CTRUMP_STRUCT_DECL_FIELDS }
 メンバ宣言の種類 More...
enum  ctrump_stmt_code {
  CTRUMP_STMT_LABELED, CTRUMP_STMT_CASE, CTRUMP_STMT_DEFAULT, CTRUMP_STMT_COMPOUND,
  CTRUMP_STMT_EXPR, CTRUMP_STMT_DECL, CTRUMP_STMT_IF, CTRUMP_STMT_IF_ELSE,
  CTRUMP_STMT_SWITCH, CTRUMP_STMT_FOR, CTRUMP_STMT_FOR_DECL, CTRUMP_STMT_WHILE,
  CTRUMP_STMT_DO_WHILE, CTRUMP_STMT_GOTO, CTRUMP_STMT_CONTINUE, CTRUMP_STMT_BREAK,
  CTRUMP_STMT_RETURN_EXPR, CTRUMP_STMT_RETURN, CTRUMP_STMT_PRAGMA, CTRUMP_STMT_SLASLA_COMMENT,
  CTRUMP_STMT_SLAAST_COMMENT, CTRUMP_STMT_IFDEF, CTRUMP_STMT_ASM, CTRUMP_STMT_DEFINE,
  CTRUMP_STMT_UNDEF, CTRUMP_STMT_NEWLINE, CTRUMP_STMT_LIST, CTRUMP_STMT_EMPTY
}
 文の種類 More...
enum  ctrump_extdef_code {
  CTRUMP_EXT_FUNCTION_DEFINITION, CTRUMP_EXT_OBJECT_DEFINITION, CTRUMP_EXT_EMPTY_DEFINITION, CTRUMP_EXT_INCLUDE,
  CTRUMP_EXT_IFDEF_BLOCK, CTRUMP_EXT_DEFINE, CTRUMP_EXT_UNDEF, CTRUMP_EXT_INCLUDE_PATH,
  CTRUMP_EXT_NEWLINE, CTRUMP_EXT_SLASLA_COMMENT, CTRUMP_EXT_SLAAST_COMMENT, CTRUMP_EXT_GCC_CPP_NOTE
}
 最上位宣言の種類 More...

Functions

CTRUMP_EXTDEF int ctrump_ast_fold_const_sint (const struct ctrump_expr *expr, int *is_const)
 定数畳み込み
CTRUMP_EXTDEF void ctrump_ast_fold_const_offset_sint (int *ret_offset, struct ctrump_expr **ret_expr, struct ctrump_expr *expr)
 加算される値の定数畳み込み fold (expr + offset)
CTRUMP_EXTDEF struct
ctrump_location 
ctrump_get_stmt_loc (const struct ctrump_stmt *stmt)
 文の開始位置取得
CTRUMP_EXTDEF int ctrump_expr_occur_var (const struct ctrump_expr *expr, const struct ctrump_var *v)
 check occurrence of v in expr
CTRUMP_EXTDEF int ctrump_print_expr_stderr (struct ctrump_expr *e, int is_print_internal)
 print expr to stdout (for debug)
CTRUMP_EXTDEF int ctrump_print_translation_unit_stderr (struct ctrump_translation_unit *u)
 print translation unit (for debug)

Variables

CTRUMP_EXTDEF int ctrump_expr_prec_table []
 式の優先順位 expr_code -> int 絶対値に意味は無い。値が大きいほど優先順位が高い


Detailed Description

C99 構文木定義.

未実装の箇所

以下の点が未実装

source_string : マクロ展開復元のために、もとのソーステキストを入れておくという意図があるが まだ詳細が詰まっていないので今は空文字列("") が入っている

数値、文字列リテラルのみ、もとのソーステキストが含まれている

oldstyle 関数宣言 :

動作確認していない

可変長配列 : sizeof(type) はコンパイル時定数にすべきではない

宣言指定子の位置 : unsigned, signed, 記憶域指定子, 型修飾子の順序が保存されない

関数のコンマの位置 : 関数のコンマの位置が保存されない

修飾子の位置: 型修飾子とGCC attributeの位置が保存されない

Definition in file ast.h.


Define Documentation

#define CTRUMP_ASM_HAVE_CLOBBER   2

Definition at line 1075 of file ast.h.

#define CTRUMP_ASM_HAVE_INPUT   1

Definition at line 1074 of file ast.h.

#define CTRUMP_ASM_HAVE_OUTPUT   0

Definition at line 1073 of file ast.h.

#define CTRUMP_ENUM_LIST_HAVE_LAST_COMMA   (1<<0)

Definition at line 237 of file ast.h.

Referenced by print_enum_list().

#define CTRUMP_INITIALIZER_HAVE_LAST_COMMA   (1<<0)

最後の要素がコンマを持っている

Definition at line 158 of file ast.h.

Referenced by print_initializer_list().


Enumeration Type Documentation

宣言子の種類

Enumerator:
CTRUMP_DECLARATOR_IDENTIFIER 
CTRUMP_DECLARATOR_EMPTY 
CTRUMP_DECLARATOR_POINTER 
CTRUMP_DECLARATOR_ARRAY 
CTRUMP_DECLARATOR_VARLEN_ARRAY 
CTRUMP_DECLARATOR_INCOMPLETE_ARRAY 
CTRUMP_DECLARATOR_PARAM_TYPELIST 
CTRUMP_DECLARATOR_PARAM_IDENTIFIER_LIST 
CTRUMP_DECLARATOR_PAREN 

Definition at line 611 of file ast.h.

要素指示子の種類

Enumerator:
CTRUMP_DESIGNATOR_IDENT  .identifier =
CTRUMP_DESIGNATOR_INDEX  [constant-expression] =

Definition at line 93 of file ast.h.

最上位宣言の種類

Enumerator:
CTRUMP_EXT_FUNCTION_DEFINITION 
CTRUMP_EXT_OBJECT_DEFINITION 
CTRUMP_EXT_EMPTY_DEFINITION 
CTRUMP_EXT_INCLUDE 
CTRUMP_EXT_IFDEF_BLOCK 
CTRUMP_EXT_DEFINE 
CTRUMP_EXT_UNDEF 
CTRUMP_EXT_INCLUDE_PATH 
CTRUMP_EXT_NEWLINE 
CTRUMP_EXT_SLASLA_COMMENT 
CTRUMP_EXT_SLAAST_COMMENT 
CTRUMP_EXT_GCC_CPP_NOTE 

Definition at line 1234 of file ast.h.

関数指定子

Enumerator:
CTRUMP_FUNC_SPEC_INLINE 
CTRUMP_FUNC_SPEC_UNSPECIFIED 

Definition at line 332 of file ast.h.

初期化子の種類

Enumerator:
CTRUMP_INITIALIZER_EMPTY  初期化子が無い
CTRUMP_INITIALIZER_EXPR 
CTRUMP_INITIALIZER_NESTED  ネストした初期化子 {initializer}

Definition at line 101 of file ast.h.

文の種類

Enumerator:
CTRUMP_STMT_LABELED 
CTRUMP_STMT_CASE 
CTRUMP_STMT_DEFAULT 
CTRUMP_STMT_COMPOUND 
CTRUMP_STMT_EXPR 
CTRUMP_STMT_DECL 
CTRUMP_STMT_IF 
CTRUMP_STMT_IF_ELSE 
CTRUMP_STMT_SWITCH 
CTRUMP_STMT_FOR 
CTRUMP_STMT_FOR_DECL 
CTRUMP_STMT_WHILE 
CTRUMP_STMT_DO_WHILE 
CTRUMP_STMT_GOTO 
CTRUMP_STMT_CONTINUE 
CTRUMP_STMT_BREAK 
CTRUMP_STMT_RETURN_EXPR 
CTRUMP_STMT_RETURN 
CTRUMP_STMT_PRAGMA 
CTRUMP_STMT_SLASLA_COMMENT 
CTRUMP_STMT_SLAAST_COMMENT 
CTRUMP_STMT_IFDEF 
CTRUMP_STMT_ASM 
CTRUMP_STMT_DEFINE 
CTRUMP_STMT_UNDEF 
CTRUMP_STMT_NEWLINE 
CTRUMP_STMT_LIST 
CTRUMP_STMT_EMPTY 

Definition at line 882 of file ast.h.

記憶域指定子

Enumerator:
CTRUMP_STOR_CLASS_EXTERN  extern
CTRUMP_STOR_CLASS_STATIC  static
CTRUMP_STOR_CLASS_AUTO  auto(付けた場合)
CTRUMP_STOR_CLASS_REGISTER  register
CTRUMP_STOR_CLASS_TYPEDEF  typedef
CTRUMP_STOR_CLASS_AUTO_UNSPECIFIED  何も指定しない場合のauto
CTRUMP_STOR_CLASS_EXTDEF  何も指定しない場合の外部定義
CTRUMP_STOR_CLASS_ARGMENT  引数
CTRUMP_STOR_CLASS_FIELD  構造体のフィールド

Definition at line 340 of file ast.h.

メンバ宣言の種類

Enumerator:
CTRUMP_STRUCT_DECL_EMPTY  空のメンバ宣言 ';'
CTRUMP_STRUCT_DECL_FIELDS  int a, b;

Definition at line 841 of file ast.h.

型指定子

Enumerator:
CTRUMP_TYPESPEC_BUILTIN 
CTRUMP_TYPESPEC_UNTYPED_SIGNED_INT 
CTRUMP_TYPESPEC_TYPEDEF_NAME 
CTRUMP_TYPESPEC_STRUCT_NAME 
CTRUMP_TYPESPEC_STRUCT_DEFINITION 
CTRUMP_TYPESPEC_UNION_NAME 
CTRUMP_TYPESPEC_UNION_DEFINITION 
CTRUMP_TYPESPEC_ANON_STRUCT_DEFINITION 
CTRUMP_TYPESPEC_ANON_UNION_DEFINITION 
CTRUMP_TYPESPEC_ENUM_NAME 
CTRUMP_TYPESPEC_ENUM_DEFINITION 
CTRUMP_TYPESPEC_ANON_ENUM_DEFINITION 

Definition at line 273 of file ast.h.


Function Documentation

CTRUMP_EXTDEF void ctrump_ast_fold_const_offset_sint ( int *  ret_offset,
struct ctrump_expr **  ret_expr,
struct ctrump_expr e 
)

加算される値の定数畳み込み fold (expr + offset)

3 + expr + 3 => ret_expr=expr, ret_offset = 6 3 => ret_expr = NULL, ret_offset=3

加算される値の定数畳み込み fold (expr + offset)

Parameters:
ret_offset [out] 定数値を返すポインタ
ret_expr [out] 定数値以外を返すポインタ
e 

Definition at line 75 of file fold.c.

References ctrump_expr::binary, ctrump_expr::code, ctrump_ast_fold_const_sint(), CTRUMP_EXPR_BIN_ADD, CTRUMP_EXPR_BIN_SUB, CTRUMP_EXPR_PAREN, CTRUMP_EXPR_SINT_LITERAL, ctrump_paren_expr::expr, ctrump_binary_expr::lhs, ctrump_expr::paren, ctrump_binary_expr::rhs, rhs, ctrump_expr::sint_literal, ctrump_expr::u, and ctrump_integer_literal::value.

Referenced by single_expr_subscripts_to_loop_subscript().

CTRUMP_EXTDEF int ctrump_ast_fold_const_sint ( const struct ctrump_expr expr,
int *  is_const 
)

定数畳み込み

Parameters:
expr 
is_const [out] 定数ならば1が入る。それ以外は0
Returns:
畳み込んだ値

Definition at line 46 of file fold.c.

References ctrump_expr::code, CTRUMP_EXPR_PAREN, CTRUMP_EXPR_SINT_LITERAL, ctrump_paren_expr::expr, ctrump_expr::paren, ctrump_expr::sint_literal, ctrump_expr::u, and ctrump_integer_literal::value.

Referenced by ctrump_ast_fold_const_offset_sint(), ctrump_env_handle_decl_node(), fold_const(), and recog_inductive().

CTRUMP_EXTDEF int ctrump_expr_occur_var ( const struct ctrump_expr expr,
const struct ctrump_var v 
)

CTRUMP_EXTDEF struct ctrump_location ctrump_get_stmt_loc ( const struct ctrump_stmt stmt  )  [read]

CTRUMP_EXTDEF int ctrump_print_expr_stderr ( struct ctrump_expr e,
int  is_print_internal 
)

print expr to stdout (for debug)

Definition at line 2260 of file pretty-printer.c.

References ctrump_print_expr().

CTRUMP_EXTDEF int ctrump_print_translation_unit_stderr ( struct ctrump_translation_unit u  ) 

print translation unit (for debug)

Definition at line 2277 of file pretty-printer.c.

References ctrump_print_translation_unit().


Variable Documentation

CTRUMP_EXTDEF int ctrump_expr_prec_table[]

式の優先順位 expr_code -> int 絶対値に意味は無い。値が大きいほど優先順位が高い

Definition at line 60 of file ast.c.

Referenced by expr_prec().


Generated on Tue Mar 31 20:19:24 2009 for ctrump by  doxygen 1.5.6