Cthulhu  0.2.10
Cthulhu compiler collection
tree.c File Reference
#include "arena/arena.h"
#include "base/util.h"
#include "common.h"
#include "cthulhu/tree/query.h"
#include "notify/notify.h"
#include "std/vector.h"
#include "std/str.h"
#include "memory/memory.h"
#include "base/panic.h"
Include dependency graph for tree.c:

Go to the source code of this file.

Macros

#define EXPECT_TYPE(TYPE)   CTASSERTF(is_type(tree_get_kind(TYPE)), "expected type, found %s", tree_to_string(TYPE))
 
#define EXPECT_LOAD_TYPE(TYPE)   CTASSERTF(is_load_type(tree_get_kind(TYPE)), "expected load type, found %s", tree_to_string(TYPE))
 
#define TREE_EXPECT_ADDRESS(TYPE)   CTASSERTF(tree_is(TYPE, eTreeTypePointer) || tree_is(TYPE, eTreeTypeReference) || tree_is(TYPE, eTreeTypeOpaque) || tree_is(TYPE, eTreeError), "expected reference or pointer, found %s", tree_to_string(TYPE))
 must be either storage or a pointer More...
 

Functions

tree_ttree_new (tree_kind_t kind, const node_t *node, const tree_t *type)
 
tree_ttree_decl (tree_kind_t kind, const node_t *node, const tree_t *type, const char *name, tree_quals_t quals)
 
void tree_report (logger_t *reports, const tree_t *error)
 
tree_ttree_error (const node_t *node, const diagnostic_t *diagnostic, const char *message,...)
 
tree_ttree_raise (const node_t *node, logger_t *reports, const diagnostic_t *diagnostic, const char *message,...)
 
tree_ttree_type_empty (const node_t *node, const char *name)
 create an empty type, this is a type that has no values and can never be created in a well defined program More...
 
tree_ttree_type_unit (const node_t *node, const char *name)
 create a unit type, this is a type that has only one value. equivilent to void More...
 
tree_ttree_type_bool (const node_t *node, const char *name)
 create a bool type, this is a type that has only two values, true and false More...
 
tree_ttree_type_opaque (const node_t *node, const char *name)
 create an opaque pointer type More...
 
tree_ttree_type_digit (const node_t *node, const char *name, digit_t digit, sign_t sign)
 create a digit type More...
 
tree_ttree_type_closure (const node_t *node, const char *name, const tree_t *result, const vector_t *params, tree_arity_t arity)
 create a function pointer type More...
 
tree_ttree_type_pointer (const node_t *node, const char *name, const tree_t *pointer, size_t length)
 create a pointer type More...
 
tree_ttree_type_array (const node_t *node, const char *name, const tree_t *array, size_t length)
 create a new array type More...
 
tree_ttree_type_reference (const node_t *node, const char *name, const tree_t *reference)
 create a reference type More...
 
tree_ttree_expr_empty (const node_t *node, const tree_t *type)
 
tree_ttree_expr_unit (const node_t *node, const tree_t *type)
 
tree_ttree_expr_bool (const node_t *node, const tree_t *type, bool value)
 
tree_ttree_expr_digit (const node_t *node, const tree_t *type, const mpz_t value)
 
tree_ttree_expr_digit_int (const node_t *node, const tree_t *type, int value)
 
tree_ttree_expr_string (const node_t *node, const tree_t *type, const char *value, size_t length)
 create a string expression More...
 
tree_ttree_expr_cast (const node_t *node, const tree_t *type, const tree_t *expr, tree_cast_t cast)
 create a cast expression More...
 
tree_ttree_expr_load (const node_t *node, tree_t *expr)
 load a value from a pointer or storage More...
 
tree_ttree_expr_address (const node_t *node, tree_t *expr)
 create a reference to an object More...
 
tree_ttree_expr_unary (const node_t *node, unary_t unary, tree_t *expr)
 
tree_ttree_expr_binary (const node_t *node, const tree_t *type, binary_t binary, const tree_t *lhs, const tree_t *rhs)
 
tree_ttree_expr_compare (const node_t *node, const tree_t *type, compare_t compare, const tree_t *lhs, const tree_t *rhs)
 
tree_ttree_expr_field (const node_t *node, const tree_t *type, tree_t *object, tree_t *field)
 
tree_ttree_expr_offset (const node_t *node, const tree_t *type, tree_t *object, tree_t *offset)
 
tree_ttree_expr_call (const node_t *node, const tree_t *callee, const vector_t *args)
 
tree_ttree_stmt_block (const node_t *node, const vector_t *stmts)
 create a block statement More...
 
tree_ttree_stmt_return (const node_t *node, const tree_t *value)
 create a return statement More...
 
tree_ttree_stmt_assign (const node_t *node, tree_t *dst, const tree_t *src)
 
tree_ttree_stmt_init (const node_t *node, tree_t *dst, tree_t *src)
 
tree_ttree_stmt_loop (const node_t *node, tree_t *cond, tree_t *body, tree_t *other)
 
tree_ttree_stmt_branch (const node_t *node, tree_t *cond, tree_t *then, tree_t *other)
 
tree_ttree_stmt_jump (const node_t *node, tree_t *label, tree_jump_t jump)
 

Macro Definition Documentation

◆ EXPECT_LOAD_TYPE

#define EXPECT_LOAD_TYPE (   TYPE)    CTASSERTF(is_load_type(tree_get_kind(TYPE)), "expected load type, found %s", tree_to_string(TYPE))

Definition at line 116 of file tree.c.

◆ EXPECT_TYPE

#define EXPECT_TYPE (   TYPE)    CTASSERTF(is_type(tree_get_kind(TYPE)), "expected type, found %s", tree_to_string(TYPE))

Definition at line 114 of file tree.c.

◆ TREE_EXPECT_ADDRESS

#define TREE_EXPECT_ADDRESS (   TYPE)    CTASSERTF(tree_is(TYPE, eTreeTypePointer) || tree_is(TYPE, eTreeTypeReference) || tree_is(TYPE, eTreeTypeOpaque) || tree_is(TYPE, eTreeError), "expected reference or pointer, found %s", tree_to_string(TYPE))

must be either storage or a pointer

expressions

Definition at line 249 of file tree.c.

Function Documentation

◆ tree_decl()

tree_t* tree_decl ( tree_kind_t  kind,
const node_t node,
const tree_t type,
const char *  name,
tree_quals_t  quals 
)

Definition at line 35 of file tree.c.

◆ tree_new()

tree_t* tree_new ( tree_kind_t  kind,
const node_t node,
const tree_t type 
)

Definition at line 22 of file tree.c.