ctrump/analyzer/analyze.c File Reference

解析処理 More...

#include "ctrump/analyzer/analyze.h"
#include "ctrump/common/mempool.h"
#include "ctrump/ast/ast.h"
#include "ctrump/analyzer/cfg.h"
#include <stdlib.h>
#include "ctrump/common/abort.h"
#include "ctrump/common/varray.h"
#include "ctrump/common/intmap.h"

Include dependency graph for analyze.c:

Go to the source code of this file.

Data Structures

struct  analyze_allocator
 ID, メモリアロケータ. More...
struct  build_loop_tree_state
 loop tree構築に必要な情報 More...

Functions

static void init_build_loop_tree_state (struct build_loop_tree_state *st, struct ctrump_intmap *var_info_map, struct ctrump_varray *loops)
static void destroy_build_loop_tree_state (struct build_loop_tree_state *st)
static int analyze_loop_control_flow (struct build_loop_tree_state *st, struct ctrump_loop_cfg_info *attr, struct ctrump_cfg *cfg, struct ctrump_stmt *loop_body, struct ctrump_location *loc, struct analyze_allocator *alloc)
static void analyze_control_flow (struct build_loop_tree_state *st, struct ctrump_stmt *stmt, struct ctrump_cfg *cfg, struct analyze_allocator *alloc)
 コントロールフローの簡単な解析 ループ脱出が無いかどうかを解析する
static void build_loop_tree_compound_stmt (struct build_loop_tree_state *st, struct ctrump_compound_stmt *stmt, struct ctrump_cfg *cfg, struct analyze_allocator *alloc)
static void complicated_loop (struct build_loop_tree_state *st, enum ctrump_complicated_loop_reason_code code, struct ctrump_stmt *stmt)
static void append_root (struct ctrump_varray *roots, struct ctrump_varray *new_roots)
 loop treeのルートを追加する
static void build_loop_tree_func (struct ctrump_varray *loops, struct ctrump_fundef *func, struct ctrump_cfg *cfg, struct ctrump_intmap *var_info_map, const struct ctrump_abi *abi, struct analyze_allocator *alloc)
 loop treeを作る
int ctrump_analyze (struct ctrump_translation_unit *unit, const struct ctrump_abi *abi, struct ctrump_mempool *pool, struct ctrump_build_cfg_error *error, int num_ast, int id_base)
 プログラムを解析する 解析結果は unit の指すツリーの中に反映される


Detailed Description

解析処理

Definition in file analyze.c.


Function Documentation

static void analyze_control_flow ( struct build_loop_tree_state st,
struct ctrump_stmt stmt,
struct ctrump_cfg cfg,
struct analyze_allocator alloc 
) [static]

コントロールフローの簡単な解析 ループ脱出が無いかどうかを解析する

Definition at line 125 of file analyze.c.

References analyze_loop_control_flow(), ctrump_do_while_stmt::body, ctrump_while_stmt::body, ctrump_for_decl_stmt::body, ctrump_for_stmt::body, ctrump_switch_stmt::body, ctrump_if_stmt::body, build_loop_tree_compound_stmt(), ctrump_stmt::case_, ctrump_stmt::code, complicated_loop(), ctrump_stmt::compound, CTRUMP_COMPLICATED_LOOP_BREAK, CTRUMP_COMPLICATED_LOOP_GOTO, CTRUMP_COMPLICATED_LOOP_HAVE_COMPLICATED_NEST, CTRUMP_COMPLICATED_LOOP_NEST, CTRUMP_COMPLICATED_LOOP_RETURN, CTRUMP_STMT_ASM, CTRUMP_STMT_BREAK, CTRUMP_STMT_CASE, CTRUMP_STMT_COMPOUND, CTRUMP_STMT_CONTINUE, CTRUMP_STMT_DECL, CTRUMP_STMT_DEFAULT, CTRUMP_STMT_DEFINE, CTRUMP_STMT_DO_WHILE, CTRUMP_STMT_EMPTY, CTRUMP_STMT_EXPR, CTRUMP_STMT_FOR, CTRUMP_STMT_FOR_DECL, CTRUMP_STMT_GOTO, CTRUMP_STMT_IF, CTRUMP_STMT_IF_ELSE, CTRUMP_STMT_IFDEF, CTRUMP_STMT_LABELED, CTRUMP_STMT_LIST, CTRUMP_STMT_NEWLINE, CTRUMP_STMT_PRAGMA, CTRUMP_STMT_RETURN, CTRUMP_STMT_RETURN_EXPR, CTRUMP_STMT_SLAAST_COMMENT, CTRUMP_STMT_SLASLA_COMMENT, CTRUMP_STMT_SWITCH, CTRUMP_STMT_UNDEF, CTRUMP_STMT_WHILE, ctrump_unreachable, ctrump_stmt::default_, ctrump_stmt::do_while, ctrump_if_else_stmt::else_body, ctrump_stmt::for_, ctrump_stmt::for_decl, ctrump_stmt::if_, ctrump_stmt::if_else, ctrump_while_stmt::kwd_loc, ctrump_for_decl_stmt::kwd_loc, ctrump_for_stmt::kwd_loc, ctrump_stmt::labeled, ctrump_while_stmt::loop_cfg, ctrump_for_decl_stmt::loop_cfg, ctrump_for_stmt::loop_cfg, ctrump_default_stmt::stmt, ctrump_case_stmt::stmt, ctrump_labeled_stmt::stmt, ctrump_stmt::switch_, ctrump_if_else_stmt::then_body, ctrump_stmt::u, and ctrump_stmt::while_.

Referenced by analyze_loop_control_flow(), and build_loop_tree_compound_stmt().

static int analyze_loop_control_flow ( struct build_loop_tree_state st,
struct ctrump_loop_cfg_info attr,
struct ctrump_cfg cfg,
struct ctrump_stmt loop_body,
struct ctrump_location loc,
struct analyze_allocator alloc 
) [static]

static void append_root ( struct ctrump_varray roots,
struct ctrump_varray new_roots 
) [static]

loop treeのルートを追加する

Definition at line 232 of file analyze.c.

References ctrump_loop_info_node::children, ctrump_varray::elements, ctrump_varray::nelem, and VA_PUSH.

Referenced by analyze_loop_control_flow(), and build_loop_tree_func().

static void build_loop_tree_compound_stmt ( struct build_loop_tree_state st,
struct ctrump_compound_stmt stmt,
struct ctrump_cfg cfg,
struct analyze_allocator alloc 
) [static]

static void build_loop_tree_func ( struct ctrump_varray loops,
struct ctrump_fundef func,
struct ctrump_cfg cfg,
struct ctrump_intmap var_info_map,
const struct ctrump_abi abi,
struct analyze_allocator alloc 
) [static]

static void complicated_loop ( struct build_loop_tree_state st,
enum ctrump_complicated_loop_reason_code  code,
struct ctrump_stmt stmt 
) [static]

int ctrump_analyze ( struct ctrump_translation_unit unit,
const struct ctrump_abi abi,
struct ctrump_mempool pool,
struct ctrump_build_cfg_error error,
int  num_ast,
int  id_base 
)

static void destroy_build_loop_tree_state ( struct build_loop_tree_state st  )  [static]

static void init_build_loop_tree_state ( struct build_loop_tree_state st,
struct ctrump_intmap var_info_map,
struct ctrump_varray loops 
) [static]


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