Cthulhu  0.2.10
Cthulhu compiler collection
Tree intermediate form

Tree intermediate form generated by language drivers. More...

Collaboration diagram for Tree intermediate form:

Data Structures

struct  tree_attribs_t
 
struct  tree_resolve_info_t
 
struct  tree_t
 

Typedefs

typedef void(* tree_resolve_t) (tree_t *sema, tree_t *self, void *user)
 
typedef void(* tree_resolve_type_t) (tree_t *sema, tree_t *self, void *user)
 

Enumerations

enum  sema_tags_t {
  eSemaValues , eSemaTypes , eSemaProcs , eSemaModules ,
  eSemaCount
}
 

Functions

CT_TREE_API tree_t * tree_error (const node_t *node, const diagnostic_t *diagnostic, const char *message,...)
 
CT_TREE_API tree_t * tree_raise (const node_t *node, logger_t *reports, const diagnostic_t *diagnostic, const char *message,...)
 
CT_TREE_API void tree_report (logger_t *reports, const tree_t *error)
 
CT_TREE_API tree_t * tree_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...
 
CT_TREE_API tree_t * tree_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...
 
CT_TREE_API tree_t * tree_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...
 
CT_TREE_API tree_t * tree_type_opaque (const node_t *node, const char *name)
 create an opaque pointer type More...
 
CT_TREE_API tree_t * tree_type_digit (const node_t *node, const char *name, digit_t digit, sign_t sign)
 create a digit type More...
 
CT_TREE_API tree_t * tree_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...
 
CT_TREE_API tree_t * tree_type_pointer (const node_t *node, const char *name, const tree_t *pointer, size_t length)
 create a pointer type More...
 
CT_TREE_API tree_t * tree_type_reference (const node_t *node, const char *name, const tree_t *reference)
 create a reference type More...
 
CT_TREE_API tree_t * tree_type_array (const node_t *node, const char *name, const tree_t *array, size_t length)
 create a new array type More...
 
CT_TREE_API tree_t * tree_expr_empty (const node_t *node, const tree_t *type)
 
CT_TREE_API tree_t * tree_expr_unit (const node_t *node, const tree_t *type)
 
CT_TREE_API tree_t * tree_expr_bool (const node_t *node, const tree_t *type, bool value)
 
CT_TREE_API tree_t * tree_expr_digit (const node_t *node, const tree_t *type, const mpz_t value)
 
CT_TREE_API tree_t * tree_expr_digit_int (const node_t *node, const tree_t *type, int value)
 
CT_TREE_API tree_t * tree_expr_string (const node_t *node, const tree_t *type, const char *value, size_t length)
 create a string expression More...
 
CT_TREE_API tree_t * tree_expr_cast (const node_t *node, const tree_t *type, const tree_t *expr, tree_cast_t cast)
 create a cast expression More...
 
CT_TREE_API tree_t * tree_expr_load (const node_t *node, tree_t *expr)
 load a value from a pointer or storage More...
 
CT_TREE_API tree_t * tree_expr_address (const node_t *node, tree_t *expr)
 create a reference to an object More...
 
CT_TREE_API tree_t * tree_expr_unary (const node_t *node, unary_t unary, tree_t *expr)
 
CT_TREE_API tree_t * tree_expr_binary (const node_t *node, const tree_t *type, binary_t binary, const tree_t *lhs, const tree_t *rhs)
 
CT_TREE_API tree_t * tree_expr_compare (const node_t *node, const tree_t *type, compare_t compare, const tree_t *lhs, const tree_t *rhs)
 
CT_TREE_API tree_t * tree_expr_field (const node_t *node, const tree_t *type, tree_t *object, tree_t *field)
 
CT_TREE_API tree_t * tree_expr_offset (const node_t *node, const tree_t *type, tree_t *object, tree_t *offset)
 
CT_TREE_API tree_t * tree_expr_call (const node_t *node, const tree_t *callee, const vector_t *args)
 
CT_TREE_API tree_t * tree_stmt_block (const node_t *node, const vector_t *stmts)
 create a block statement More...
 
CT_TREE_API tree_t * tree_stmt_return (const node_t *node, const tree_t *value)
 create a return statement More...
 
CT_TREE_API tree_t * tree_stmt_assign (const node_t *node, tree_t *dst, const tree_t *src)
 
CT_TREE_API tree_t * tree_stmt_init (const node_t *node, tree_t *dst, tree_t *src)
 
CT_TREE_API tree_t * tree_stmt_loop (const node_t *node, tree_t *cond, tree_t *body, tree_t *other)
 
CT_TREE_API tree_t * tree_stmt_branch (const node_t *node, tree_t *cond, tree_t *then, tree_t *other)
 
CT_TREE_API tree_t * tree_stmt_jump (const node_t *node, tree_t *label, tree_jump_t jump)
 
CT_TREE_API tree_t * tree_resolve (tree_cookie_t *cookie, const tree_t *decl)
 
CT_TREE_API tree_t * tree_resolve_type (tree_cookie_t *cookie, const tree_t *decl)
 
CT_TREE_API tree_t * tree_open_decl (const node_t *node, const char *name, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_decl (tree_t *self, const tree_t *other)
 
CT_TREE_API tree_t * tree_decl_global (const node_t *node, const char *name, tree_storage_t storage, const tree_t *type, tree_t *initial)
 
CT_TREE_API tree_t * tree_open_global (const node_t *node, const char *name, const tree_t *type, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_global (tree_t *self, tree_t *value)
 
CT_TREE_API tree_t * tree_decl_function (const node_t *node, const char *name, const tree_t *signature, const vector_t *params, vector_t *locals, tree_t *body)
 
CT_TREE_API tree_t * tree_open_function (const node_t *node, const char *name, const tree_t *signature, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_function (tree_t *self, tree_t *body)
 
CT_TREE_API tree_t * tree_decl_struct (const node_t *node, const char *name, vector_t *fields)
 
CT_TREE_API tree_t * tree_open_struct (const node_t *node, const char *name, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_struct (tree_t *self, vector_t *fields)
 
CT_TREE_API tree_t * tree_decl_union (const node_t *node, const char *name, vector_t *fields)
 
CT_TREE_API tree_t * tree_open_union (const node_t *node, const char *name, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_union (tree_t *self, vector_t *fields)
 
CT_TREE_API tree_t * tree_decl_enum (const node_t *node, const char *name, const tree_t *underlying, vector_t *fields, tree_t *default_case)
 
CT_TREE_API tree_t * tree_open_enum (const node_t *node, const char *name, tree_resolve_info_t resolve)
 
CT_TREE_API void tree_close_enum (tree_t *self, const tree_t *underlying, vector_t *fields, tree_t *default_case)
 
CT_TREE_API tree_t * tree_decl_param (const node_t *node, const char *name, const tree_t *type)
 
CT_TREE_API tree_t * tree_decl_field (const node_t *node, const char *name, const tree_t *type)
 
CT_TREE_API tree_t * tree_decl_local (const node_t *node, const char *name, tree_storage_t storage, const tree_t *type)
 
CT_TREE_API tree_t * tree_decl_case (const node_t *node, const char *name, const tree_t *type, tree_t *expr)
 
CT_TREE_API void tree_add_local (tree_t *self, tree_t *decl)
 
CT_TREE_API void tree_add_enum (tree_t *self, tree_t *decl)
 
CT_TREE_API void tree_set_attrib (tree_t *self, const tree_attribs_t *attrib)
 
CT_TREE_API void tree_set_type (tree_t *self, const tree_t *type)
 
CT_TREE_API tree_t * tree_alias (const tree_t *tree, const char *name)
 
CT_TREE_API tree_t * tree_type_alias (const node_t *node, const char *name, const tree_t *type, tree_quals_t quals)
 
CT_TREE_API const tree_t * tree_follow_type (const tree_t *type)
 
CT_TREE_API tree_t * tree_module_root (logger_t *reports, tree_cookie_t *cookie, const node_t *node, const char *name, size_t decls, const size_t *sizes, arena_t *arena)
 
CT_TREE_API tree_t * tree_module (tree_t *parent, const node_t *node, const char *name, size_t decls, const size_t *sizes)
 create a new module More...
 
CT_TREE_API void * tree_module_get (tree_t *self, size_t tag, const char *name)
 recursively search for a declaration in a module More...
 
CT_TREE_API void * tree_module_find (tree_t *sema, size_t tag, const char *name, tree_t **module)
 search for a declaration in a module also returns the module that the declaration was found in More...
 
CT_TREE_API void * tree_module_set (tree_t *self, size_t tag, const char *name, void *value)
 set a declaration in the current module More...
 
CT_TREE_API map_t * tree_module_tag (const tree_t *self, size_t tag)
 
CT_TREE_API tree_cookie_t * tree_get_cookie (tree_t *sema)
 return a resolution cookie More...
 
enum  tree_kind_t { eTreeTotal }
 all tree node types More...
 
enum  tree_quals_t
 all type qualifiers More...
 
enum  binary_t { eBinaryTotal }
 all binary operators More...
 
enum  compare_t { eCompareTotal }
 all comparison operators More...
 
enum  unary_t { eUnaryTotal }
 all unary operators More...
 
enum  tree_cast_t { eCastTotal }
 all casts More...
 
enum  tree_arity_t { eArityTotal }
 all arities More...
 
enum  tree_linkage_t { eLinkTotal }
 the linkage of a declaration More...
 
enum  tree_jump_t { eJumpTotal }
 the type of jump More...
 
enum  tree_visibility_t { eVisibileTotal }
 symbol visibility More...
 
enum  digit_t { eDigitTotal }
 digit width More...
 
enum  sign_t { eSignTotal }
 integer sign More...
 
enum  eval_model_t
 tree evaluation model More...
 
CT_TREE_API const char * unary_name (unary_t op)
 get the pretty name of a unary operator More...
 
CT_TREE_API const char * binary_name (binary_t op)
 get the pretty name of a binary operator More...
 
CT_TREE_API const char * compare_name (compare_t op)
 get the pretty name of a comparison operator More...
 
CT_TREE_API const char * unary_symbol (unary_t op)
 get the C symbol of a unary operator More...
 
CT_TREE_API const char * binary_symbol (binary_t op)
 get the C symbol of a binary operator More...
 
CT_TREE_API const char * compare_symbol (compare_t op)
 get the C symbol of a comparison operator More...
 
CT_TREE_API const char * sign_name (sign_t sign)
 get the pretty name of a integer sign More...
 
CT_TREE_API const char * digit_name (digit_t digit)
 get the pretty name of a digit More...
 
CT_TREE_API const char * quals_string (tree_quals_t quals)
 get the name of a set of qualifiers More...
 
CT_TREE_API const char * linkage_string (tree_linkage_t link)
 get the name of a linkage More...
 
CT_TREE_API const char * visibility_string (tree_visibility_t vis)
 get the name of visibility More...
 

Detailed Description

Tree intermediate form generated by language drivers.

Typedef Documentation

◆ tree_resolve_t

typedef void(* tree_resolve_t) (tree_t *sema, tree_t *self, void *user)

Definition at line 31 of file tree.h.

◆ tree_resolve_type_t

typedef void(* tree_resolve_type_t) (tree_t *sema, tree_t *self, void *user)

Definition at line 32 of file tree.h.

Enumeration Type Documentation

◆ binary_t

enum binary_t

all binary operators

Enumerator
eBinaryTotal 

Definition at line 31 of file ops.h.

◆ compare_t

enum compare_t

all comparison operators

Enumerator
eCompareTotal 

Definition at line 39 of file ops.h.

◆ digit_t

enum digit_t

digit width

Enumerator
eDigitTotal 

Definition at line 95 of file ops.h.

◆ eval_model_t

tree evaluation model

Definition at line 111 of file ops.h.

◆ sema_tags_t

Enumerator
eSemaValues 
eSemaTypes 
eSemaProcs 
eSemaModules 
eSemaCount 

Definition at line 34 of file tree.h.

◆ sign_t

enum sign_t

integer sign

Enumerator
eSignTotal 

Definition at line 103 of file ops.h.

◆ tree_arity_t

all arities

Enumerator
eArityTotal 

Definition at line 63 of file ops.h.

◆ tree_cast_t

all casts

Enumerator
eCastTotal 

Definition at line 55 of file ops.h.

◆ tree_jump_t

the type of jump

Enumerator
eJumpTotal 

Definition at line 79 of file ops.h.

◆ tree_kind_t

all tree node types

Enumerator
eTreeTotal 

Definition at line 16 of file ops.h.

◆ tree_linkage_t

the linkage of a declaration

Enumerator
eLinkTotal 

Definition at line 71 of file ops.h.

◆ tree_quals_t

all type qualifiers

Definition at line 24 of file ops.h.

◆ tree_visibility_t

symbol visibility

Enumerator
eVisibileTotal 

Definition at line 87 of file ops.h.

◆ unary_t

enum unary_t

all unary operators

Enumerator
eUnaryTotal 

Definition at line 47 of file ops.h.

Function Documentation

◆ binary_name()

CT_TREE_API const char* binary_name ( binary_t  op)

get the pretty name of a binary operator

Parameters
opthe operator to get the name of
Returns
the name of op

Definition at line 42 of file ops.c.

◆ binary_symbol()

CT_TREE_API const char* binary_symbol ( binary_t  op)

get the C symbol of a binary operator

Parameters
opthe operator to get the symbol of
Returns
the symbol of op

Definition at line 54 of file ops.c.

◆ compare_name()

CT_TREE_API const char* compare_name ( compare_t  op)

get the pretty name of a comparison operator

Parameters
opthe operator to get the name of
Returns
the name of op

Definition at line 66 of file ops.c.

◆ compare_symbol()

CT_TREE_API const char* compare_symbol ( compare_t  op)

get the C symbol of a comparison operator

Parameters
opthe operator to get the symbol of
Returns
the symbol of op

Definition at line 78 of file ops.c.

◆ digit_name()

CT_TREE_API const char* digit_name ( digit_t  digit)

get the pretty name of a digit

Parameters
digitthe digit to get the name of
Returns
the name of op

Definition at line 102 of file ops.c.

◆ linkage_string()

CT_TREE_API const char* linkage_string ( tree_linkage_t  link)

get the name of a linkage

Parameters
linkthe linkage to get the name of
Returns
the name of link

Definition at line 141 of file ops.c.

◆ quals_string()

CT_TREE_API const char* quals_string ( tree_quals_t  quals)

get the name of a set of qualifiers

Parameters
qualsthe qualifiers to get the name of
Returns
the name of quals

Definition at line 109 of file ops.c.

◆ sign_name()

CT_TREE_API const char* sign_name ( sign_t  sign)

get the pretty name of a integer sign

Parameters
signthe sign to get the name of
Returns
the name of op

Definition at line 90 of file ops.c.

◆ tree_add_enum()

CT_TREE_API void tree_add_enum ( tree_t *  self,
tree_t *  decl 
)

◆ tree_add_local()

CT_TREE_API void tree_add_local ( tree_t *  self,
tree_t *  decl 
)

various helpers

Definition at line 243 of file decl.c.

◆ tree_alias()

CT_TREE_API tree_t* tree_alias ( const tree_t *  tree,
const char *  name 
)

Definition at line 258 of file decl.c.

◆ tree_close_decl()

CT_TREE_API void tree_close_decl ( tree_t *  self,
const tree_t *  other 
)

Definition at line 217 of file decl.c.

◆ tree_close_enum()

CT_TREE_API void tree_close_enum ( tree_t *  self,
const tree_t *  underlying,
vector_t *  fields,
tree_t *  default_case 
)

Definition at line 383 of file decl.c.

◆ tree_close_function()

CT_TREE_API void tree_close_function ( tree_t *  self,
tree_t *  body 
)

Definition at line 168 of file decl.c.

◆ tree_close_global()

CT_TREE_API void tree_close_global ( tree_t *  self,
tree_t *  value 
)

Definition at line 162 of file decl.c.

◆ tree_close_struct()

CT_TREE_API void tree_close_struct ( tree_t *  self,
vector_t *  fields 
)

Definition at line 315 of file decl.c.

◆ tree_close_union()

CT_TREE_API void tree_close_union ( tree_t *  self,
vector_t *  fields 
)

Definition at line 343 of file decl.c.

◆ tree_decl_case()

CT_TREE_API tree_t* tree_decl_case ( const node_t *  node,
const char *  name,
const tree_t *  type,
tree_t *  expr 
)

Definition at line 205 of file decl.c.

◆ tree_decl_enum()

CT_TREE_API tree_t* tree_decl_enum ( const node_t *  node,
const char *  name,
const tree_t *  underlying,
vector_t *  fields,
tree_t *  default_case 
)

enum decls

Definition at line 366 of file decl.c.

◆ tree_decl_field()

CT_TREE_API tree_t* tree_decl_field ( const node_t *  node,
const char *  name,
const tree_t *  type 
)

Definition at line 193 of file decl.c.

◆ tree_decl_function()

CT_TREE_API tree_t* tree_decl_function ( const node_t *  node,
const char *  name,
const tree_t *  signature,
const vector_t *  params,
vector_t *  locals,
tree_t *  body 
)

function decls

Definition at line 224 of file decl.c.

◆ tree_decl_global()

CT_TREE_API tree_t* tree_decl_global ( const node_t *  node,
const char *  name,
tree_storage_t  storage,
const tree_t *  type,
tree_t *  initial 
)

global decls

Definition at line 123 of file decl.c.

◆ tree_decl_local()

CT_TREE_API tree_t* tree_decl_local ( const node_t *  node,
const char *  name,
tree_storage_t  storage,
const tree_t *  type 
)

Definition at line 198 of file decl.c.

◆ tree_decl_param()

CT_TREE_API tree_t* tree_decl_param ( const node_t *  node,
const char *  name,
const tree_t *  type 
)

other decls

Definition at line 188 of file decl.c.

◆ tree_decl_struct()

CT_TREE_API tree_t* tree_decl_struct ( const node_t *  node,
const char *  name,
vector_t *  fields 
)

struct decls

Definition at line 298 of file decl.c.

◆ tree_decl_union()

CT_TREE_API tree_t* tree_decl_union ( const node_t *  node,
const char *  name,
vector_t *  fields 
)

union decls

unions

Definition at line 326 of file decl.c.

◆ tree_error()

CT_TREE_API tree_t* tree_error ( const node_t *  node,
const diagnostic_t *  diagnostic,
const char *  message,
  ... 
)

tree error handling

Definition at line 67 of file tree.c.

◆ tree_expr_address()

CT_TREE_API tree_t* tree_expr_address ( const node_t *  node,
tree_t *  expr 
)

create a reference to an object

Parameters
nodethe location of the reference
exprthe object to reference
Returns
tree_t* the reference

Definition at line 281 of file tree.c.

◆ tree_expr_binary()

CT_TREE_API tree_t* tree_expr_binary ( const node_t *  node,
const tree_t *  type,
binary_t  binary,
const tree_t *  lhs,
const tree_t *  rhs 
)

Definition at line 298 of file tree.c.

◆ tree_expr_bool()

CT_TREE_API tree_t* tree_expr_bool ( const node_t *  node,
const tree_t *  type,
bool  value 
)

Definition at line 208 of file tree.c.

◆ tree_expr_call()

CT_TREE_API tree_t* tree_expr_call ( const node_t *  node,
const tree_t *  callee,
const vector_t *  args 
)

Definition at line 344 of file tree.c.

◆ tree_expr_cast()

CT_TREE_API tree_t* tree_expr_cast ( const node_t *  node,
const tree_t *  type,
const tree_t *  expr,
tree_cast_t  cast 
)

create a cast expression

Note
there are various rules around casting depending on the type of the expression and the destination type.
  1. any cast that involves eTreeTypePointer, eTreeTypeArray, or eTreeTypeOpaque must be an eCastBit cast.
  2. eTreeTypeUnit and eTreeTypeEmpty can never be involed in a cast expression.
  3. rules around eTreeTypeReference are not yet defined.
Parameters
nodethe location of the cast
typethe type to cast to
exprthe expression to cast
castthe kind of cast to perform
Returns
tree_t* the cast expression

Definition at line 251 of file tree.c.

◆ tree_expr_compare()

CT_TREE_API tree_t* tree_expr_compare ( const node_t *  node,
const tree_t *  type,
compare_t  compare,
const tree_t *  lhs,
const tree_t *  rhs 
)

Definition at line 307 of file tree.c.

◆ tree_expr_digit()

CT_TREE_API tree_t* tree_expr_digit ( const node_t *  node,
const tree_t *  type,
const mpz_t  value 
)

Definition at line 217 of file tree.c.

◆ tree_expr_digit_int()

CT_TREE_API tree_t* tree_expr_digit_int ( const node_t *  node,
const tree_t *  type,
int  value 
)

Definition at line 226 of file tree.c.

◆ tree_expr_empty()

CT_TREE_API tree_t* tree_expr_empty ( const node_t *  node,
const tree_t *  type 
)

tree expr interface

literal expressions

Definition at line 198 of file tree.c.

◆ tree_expr_field()

CT_TREE_API tree_t* tree_expr_field ( const node_t *  node,
const tree_t *  type,
tree_t *  object,
tree_t *  field 
)

Definition at line 319 of file tree.c.

◆ tree_expr_load()

CT_TREE_API tree_t* tree_expr_load ( const node_t *  node,
tree_t *  expr 
)

load a value from a pointer or storage

Parameters
nodethe location of the load
exprthe pointer or storage to load from
Returns
tree_t* the loaded value

Definition at line 261 of file tree.c.

◆ tree_expr_offset()

CT_TREE_API tree_t* tree_expr_offset ( const node_t *  node,
const tree_t *  type,
tree_t *  object,
tree_t *  offset 
)

Definition at line 333 of file tree.c.

◆ tree_expr_string()

CT_TREE_API tree_t* tree_expr_string ( const node_t *  node,
const tree_t *  type,
const char *  value,
size_t  length 
)

create a string expression

Parameters
nodea node to attach the expression to
typethe type of the expression
valuea null terminated string
lengththe length of the string not including the null terminator
Returns
tree_t*

Definition at line 235 of file tree.c.

◆ tree_expr_unary()

CT_TREE_API tree_t* tree_expr_unary ( const node_t *  node,
unary_t  unary,
tree_t *  expr 
)

Definition at line 290 of file tree.c.

◆ tree_expr_unit()

CT_TREE_API tree_t* tree_expr_unit ( const node_t *  node,
const tree_t *  type 
)

Definition at line 203 of file tree.c.

◆ tree_follow_type()

CT_TREE_API const tree_t* tree_follow_type ( const tree_t *  type)

Definition at line 274 of file decl.c.

◆ tree_get_cookie()

CT_TREE_API tree_cookie_t* tree_get_cookie ( tree_t *  sema)

return a resolution cookie

Parameters
semathe module
Returns
the cookie

Definition at line 136 of file sema.c.

◆ tree_module()

CT_TREE_API tree_t* tree_module ( tree_t *  parent,
const node_t *  node,
const char *  name,
size_t  decls,
const size_t *  sizes 
)

create a new module

Parameters
parentthe parent module
nodelocation of the module
namethe name of the module
declsthe number of declaration categories in the module
sizesthe size of each declaration category
Returns
the module

Definition at line 52 of file sema.c.

◆ tree_module_find()

CT_TREE_API void* tree_module_find ( tree_t *  sema,
size_t  tag,
const char *  name,
tree_t **  module 
)

search for a declaration in a module also returns the module that the declaration was found in

Parameters
semathe module
tagthe declaration category
namethe name of the declaration
[out]modulethe module that the declaration was found in
Returns
the declaration or NULL if it does not exist

Definition at line 82 of file sema.c.

◆ tree_module_get()

CT_TREE_API void* tree_module_get ( tree_t *  self,
size_t  tag,
const char *  name 
)

recursively search for a declaration in a module

Parameters
selfthe module
tagthe declaration category
namethe name of the declaration
Returns
the declaration or NULL if it does not exist

Definition at line 59 of file sema.c.

◆ tree_module_root()

CT_TREE_API tree_t* tree_module_root ( logger_t *  reports,
tree_cookie_t *  cookie,
const node_t *  node,
const char *  name,
size_t  decls,
const size_t *  sizes,
arena_t *  arena 
)

tree sema interface

Definition at line 42 of file sema.c.

◆ tree_module_set()

CT_TREE_API void* tree_module_set ( tree_t *  self,
size_t  tag,
const char *  name,
void *  value 
)

set a declaration in the current module

Note
if the declaration already exists it will not be replaced
Parameters
selfthe module
tagthe declaration category
namethe name of the declaration
valuethe value of the declaration
Returns
a previous declaration or NULL if it did not exist

Definition at line 111 of file sema.c.

◆ tree_module_tag()

CT_TREE_API map_t* tree_module_tag ( const tree_t *  self,
size_t  tag 
)

Definition at line 125 of file sema.c.

◆ tree_open_decl()

CT_TREE_API tree_t* tree_open_decl ( const node_t *  node,
const char *  name,
tree_resolve_info_t  resolve 
)

Definition at line 212 of file decl.c.

◆ tree_open_enum()

CT_TREE_API tree_t* tree_open_enum ( const node_t *  node,
const char *  name,
tree_resolve_info_t  resolve 
)

Definition at line 373 of file decl.c.

◆ tree_open_function()

CT_TREE_API tree_t* tree_open_function ( const node_t *  node,
const char *  name,
const tree_t *  signature,
tree_resolve_info_t  resolve 
)

Definition at line 147 of file decl.c.

◆ tree_open_global()

CT_TREE_API tree_t* tree_open_global ( const node_t *  node,
const char *  name,
const tree_t *  type,
tree_resolve_info_t  resolve 
)

Definition at line 140 of file decl.c.

◆ tree_open_struct()

CT_TREE_API tree_t* tree_open_struct ( const node_t *  node,
const char *  name,
tree_resolve_info_t  resolve 
)

Definition at line 307 of file decl.c.

◆ tree_open_union()

CT_TREE_API tree_t* tree_open_union ( const node_t *  node,
const char *  name,
tree_resolve_info_t  resolve 
)

Definition at line 335 of file decl.c.

◆ tree_raise()

CT_TREE_API tree_t* tree_raise ( const node_t *  node,
logger_t *  reports,
const diagnostic_t *  diagnostic,
const char *  message,
  ... 
)

Definition at line 76 of file tree.c.

◆ tree_report()

CT_TREE_API void tree_report ( logger_t *  reports,
const tree_t *  error 
)

Definition at line 49 of file tree.c.

◆ tree_resolve()

CT_TREE_API tree_t* tree_resolve ( tree_cookie_t *  cookie,
const tree_t *  decl 
)

tree decl interface

Definition at line 47 of file decl.c.

◆ tree_resolve_type()

CT_TREE_API tree_t* tree_resolve_type ( tree_cookie_t *  cookie,
const tree_t *  decl 
)

Definition at line 102 of file decl.c.

◆ tree_set_attrib()

CT_TREE_API void tree_set_attrib ( tree_t *  self,
const tree_attribs_t *  attrib 
)

Definition at line 251 of file decl.c.

◆ tree_set_type()

CT_TREE_API void tree_set_type ( tree_t *  self,
const tree_t *  type 
)

Definition at line 150 of file context.c.

◆ tree_stmt_assign()

CT_TREE_API tree_t* tree_stmt_assign ( const node_t *  node,
tree_t *  dst,
const tree_t *  src 
)

Definition at line 391 of file tree.c.

◆ tree_stmt_block()

CT_TREE_API tree_t* tree_stmt_block ( const node_t *  node,
const vector_t *  stmts 
)

create a block statement

tree statement interface

Parameters
nodethe location of the block statement
stmtsthe statements in the block
Returns
the block statement

statements

Definition at line 359 of file tree.c.

◆ tree_stmt_branch()

CT_TREE_API tree_t* tree_stmt_branch ( const node_t *  node,
tree_t *  cond,
tree_t *  then,
tree_t *  other 
)

Definition at line 413 of file tree.c.

◆ tree_stmt_init()

CT_TREE_API tree_t* tree_stmt_init ( const node_t *  node,
tree_t *  dst,
tree_t *  src 
)

Definition at line 396 of file tree.c.

◆ tree_stmt_jump()

CT_TREE_API tree_t* tree_stmt_jump ( const node_t *  node,
tree_t *  label,
tree_jump_t  jump 
)

Definition at line 425 of file tree.c.

◆ tree_stmt_loop()

CT_TREE_API tree_t* tree_stmt_loop ( const node_t *  node,
tree_t *  cond,
tree_t *  body,
tree_t *  other 
)

Definition at line 401 of file tree.c.

◆ tree_stmt_return()

CT_TREE_API tree_t* tree_stmt_return ( const node_t *  node,
const tree_t *  value 
)

create a return statement

Note
this is only valid in a function
Parameters
nodethe location of the return statement
valuethe value to return
Returns
the return statement

Definition at line 368 of file tree.c.

◆ tree_type_alias()

CT_TREE_API tree_t* tree_type_alias ( const node_t *  node,
const char *  name,
const tree_t *  type,
tree_quals_t  quals 
)

Definition at line 268 of file decl.c.

◆ tree_type_array()

CT_TREE_API tree_t* tree_type_array ( const node_t *  node,
const char *  name,
const tree_t *  array,
size_t  length 
)

create a new array type

Parameters
nodethe location of the array
namethe name of the type
arraythe element type of the array
lengththe length of the array
Returns
the array type

Definition at line 175 of file tree.c.

◆ tree_type_bool()

CT_TREE_API tree_t* tree_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

Parameters
nodewhere this type was defined
namethe name of the type
Returns
a bool type

Definition at line 128 of file tree.c.

◆ tree_type_closure()

CT_TREE_API tree_t* tree_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

Parameters
nodewhere this type was defined
namethe name of the type
resultreturn type of the function
paramsthe parameters of the function
aritydoes this function have variadic arguments
Returns
tree_t* the function pointer type

Definition at line 146 of file tree.c.

◆ tree_type_digit()

CT_TREE_API tree_t* tree_type_digit ( const node_t *  node,
const char *  name,
digit_t  digit,
sign_t  sign 
)

create a digit type

Parameters
nodewhere this type was defined
namethe name of the type
digitthe width of the digit
signthe sign of the digit
Returns
a digit type

Definition at line 138 of file tree.c.

◆ tree_type_empty()

CT_TREE_API tree_t* tree_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

tree type interface

Parameters
nodewhere this type was defined
namethe name of the type
Returns
an empty type

Definition at line 118 of file tree.c.

◆ tree_type_opaque()

CT_TREE_API tree_t* tree_type_opaque ( const node_t *  node,
const char *  name 
)

create an opaque pointer type

Parameters
nodewhere this type was defined
namethe name of the type
Returns
tree_t*

Definition at line 133 of file tree.c.

◆ tree_type_pointer()

CT_TREE_API tree_t* tree_type_pointer ( const node_t *  node,
const char *  name,
const tree_t *  pointer,
size_t  length 
)

create a pointer type

Parameters
nodewhere this type was defined
namethe name of the type
pointerthe type that this pointer points to
lengththe optional length of the pointer
Returns
tree_t* the pointer type

Definition at line 165 of file tree.c.

◆ tree_type_reference()

CT_TREE_API tree_t* tree_type_reference ( const node_t *  node,
const char *  name,
const tree_t *  reference 
)

create a reference type

Parameters
nodethe location of the reference
namethe name of the type
referencethe type that this reference references
Returns
tree_t* the reference type

Definition at line 185 of file tree.c.

◆ tree_type_unit()

CT_TREE_API tree_t* tree_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

Parameters
nodewhere this type was defined
namethe name of the type
Returns
a unit type

Definition at line 123 of file tree.c.

◆ unary_name()

CT_TREE_API const char* unary_name ( unary_t  op)

get the pretty name of a unary operator

Parameters
opthe operator to get the name of
Returns
the name of op

Definition at line 18 of file ops.c.

◆ unary_symbol()

CT_TREE_API const char* unary_symbol ( unary_t  op)

get the C symbol of a unary operator

Parameters
opthe operator to get the symbol of
Returns
the symbol of op

Definition at line 30 of file ops.c.

◆ visibility_string()

CT_TREE_API const char* visibility_string ( tree_visibility_t  vis)

get the name of visibility

Parameters
visthe visibility to get the name of
Returns
the name of vis

Definition at line 153 of file ops.c.