Cthulhu  0.2.10
Cthulhu compiler collection
ast.c File Reference
#include "oberon/ast.h"
#include "oberon/driver.h"
#include "cthulhu/broker/scan.h"
#include "notify/notify.h"
#include "scan/node.h"
#include "std/str.h"
#include "std/vector.h"
#include "arena/arena.h"
#include "base/util.h"
#include "base/panic.h"
#include "memory/memory.h"
Include dependency graph for ast.c:

Go to the source code of this file.

Macros

#define EXPAND_INNER(fn, scan, ...)
 

Functions

obr_tobr_module (scan_t *scan, where_t where, char *name, char *end, const vector_t *imports, vector_t *decls, vector_t *init)
 
obr_tobr_import (scan_t *scan, where_t where, char *name, char *symbol)
 
obr_tobr_decl_type (scan_t *scan, where_t where, obr_symbol_t *symbol, obr_t *type)
 
obr_tobr_decl_var (obr_symbol_t *symbol, obr_t *type)
 
obr_tobr_decl_const (scan_t *scan, where_t where, obr_symbol_t *symbol, obr_t *value)
 
obr_tobr_decl_procedure (scan_t *scan, where_t where, obr_symbol_t *symbol, obr_t *receiver, const vector_t *params, obr_t *result, vector_t *locals, vector_t *body, char *end)
 
obr_tobr_expr_name (scan_t *scan, where_t where, char *name)
 
obr_tobr_expr_field (scan_t *scan, where_t where, obr_t *expr, char *field)
 
obr_tobr_expr_cast (scan_t *scan, where_t where, obr_t *expr, obr_t *cast)
 
obr_tobr_expr_call (scan_t *scan, where_t where, obr_t *expr, const vector_t *args)
 
obr_tobr_expr_is (scan_t *scan, where_t where, obr_t *lhs, obr_t *rhs)
 
obr_tobr_expr_in (scan_t *scan, where_t where, obr_t *lhs, obr_t *rhs)
 
obr_tobr_expr_compare (scan_t *scan, where_t where, compare_t op, obr_t *lhs, obr_t *rhs)
 
obr_tobr_expr_binary (scan_t *scan, where_t where, binary_t op, obr_t *lhs, obr_t *rhs)
 
obr_tobr_expr_unary (scan_t *scan, where_t where, unary_t op, obr_t *expr)
 
obr_tobr_expr_digit (scan_t *scan, where_t where, const mpz_t digit)
 
obr_tobr_expr_string (scan_t *scan, where_t where, char *text, size_t length)
 
obr_tobr_stmt_return (scan_t *scan, where_t where, obr_t *expr)
 
obr_tobr_stmt_while (scan_t *scan, where_t where, obr_t *cond, vector_t *then)
 
obr_tobr_stmt_loop (scan_t *scan, where_t where, vector_t *loop)
 
obr_tobr_stmt_break (scan_t *scan, where_t where)
 
obr_tobr_stmt_repeat (scan_t *scan, where_t where, vector_t *repeat, obr_t *until)
 
obr_tobr_stmt_assign (scan_t *scan, where_t where, obr_t *dst, obr_t *src)
 
obr_tobr_stmt_block (scan_t *scan, where_t where, vector_t *stmts)
 
obr_tobr_stmt_branch (scan_t *scan, where_t where, obr_t *cond, vector_t *then, obr_t *other)
 
obr_tobr_type_name (scan_t *scan, where_t where, char *name)
 
obr_tobr_type_qual (scan_t *scan, where_t where, char *name, char *symbol)
 
obr_tobr_type_pointer (scan_t *scan, where_t where, obr_t *type)
 
obr_tobr_type_array (scan_t *scan, where_t where, const vector_t *sizes, obr_t *type)
 
obr_tobr_type_record (scan_t *scan, where_t where, vector_t *fields)
 
obr_tobr_field (obr_symbol_t *symbol, obr_t *type)
 
obr_tobr_param (obr_symbol_t *symbol, obr_t *type, bool mut)
 
obr_tobr_receiver (scan_t *scan, where_t where, bool mut, char *name, char *type)
 
obr_symbol_tobr_symbol (scan_t *scan, where_t where, char *name, obr_visibility_t visibility)
 
vector_tobr_expand_vars (scan_t *scan, vector_t *symbols, obr_t *type)
 
vector_tobr_expand_fields (scan_t *scan, vector_t *symbols, obr_t *type)
 
vector_tobr_expand_params (scan_t *scan, vector_t *symbols, obr_t *type, bool mut)
 

Macro Definition Documentation

◆ EXPAND_INNER

#define EXPAND_INNER (   fn,
  scan,
  ... 
)
Value:
do \
{ \
scan_context_t *ctx = scan_get_context(scan); \
arena_t *arena = ctx->arena; \
size_t len = vector_len(symbols); \
vector_t *result = vector_of(len, arena); \
for (size_t i = 0; i < len; i++) \
{ \
obr_symbol_t *symbol = vector_get(symbols, i); \
obr_t *decl = fn(symbol, __VA_ARGS__); \
vector_set(result, i, decl); \
} \
return result; \
} while (0)
CT_NODISCARD CT_PUREFN CT_SCAN_API void * scan_get_context(const scan_t *scan)
get the context of a scanner
Definition: scan.c:88
CT_NODISCARD CT_PUREFN CT_STD_API void * vector_get(const vector_t *vector, size_t index)
get a value from a vector
Definition: vector.c:134
CT_NODISCARD CT_STD_API vector_t * vector_of(size_t len, arena_t *arena)
create a new vector with a specified length
Definition: vector.c:71
CT_NODISCARD CT_PUREFN CT_STD_API size_t vector_len(const vector_t *vector)
get the length of a vector
Definition: vector.c:152

Definition at line 363 of file ast.c.

Function Documentation

◆ obr_decl_const()

obr_t* obr_decl_const ( scan_t scan,
where_t  where,
obr_symbol_t symbol,
obr_t value 
)

Definition at line 108 of file ast.c.

◆ obr_decl_procedure()

obr_t* obr_decl_procedure ( scan_t scan,
where_t  where,
obr_symbol_t symbol,
obr_t receiver,
const vector_t params,
obr_t result,
vector_t locals,
vector_t body,
char *  end 
)

Definition at line 115 of file ast.c.

◆ obr_decl_type()

obr_t* obr_decl_type ( scan_t scan,
where_t  where,
obr_symbol_t symbol,
obr_t type 
)

Definition at line 94 of file ast.c.

◆ obr_decl_var()

obr_t* obr_decl_var ( obr_symbol_t symbol,
obr_t type 
)

Definition at line 101 of file ast.c.

◆ obr_expand_fields()

vector_t* obr_expand_fields ( scan_t scan,
vector_t symbols,
obr_t type 
)

Definition at line 384 of file ast.c.

◆ obr_expand_params()

vector_t* obr_expand_params ( scan_t scan,
vector_t symbols,
obr_t type,
bool  mut 
)

Definition at line 389 of file ast.c.

◆ obr_expand_vars()

vector_t* obr_expand_vars ( scan_t scan,
vector_t symbols,
obr_t type 
)

Definition at line 379 of file ast.c.

◆ obr_expr_binary()

obr_t* obr_expr_binary ( scan_t scan,
where_t  where,
binary_t  op,
obr_t lhs,
obr_t rhs 
)

Definition at line 193 of file ast.c.

◆ obr_expr_call()

obr_t* obr_expr_call ( scan_t scan,
where_t  where,
obr_t expr,
const vector_t args 
)

Definition at line 160 of file ast.c.

◆ obr_expr_cast()

obr_t* obr_expr_cast ( scan_t scan,
where_t  where,
obr_t expr,
obr_t cast 
)

Definition at line 152 of file ast.c.

◆ obr_expr_compare()

obr_t* obr_expr_compare ( scan_t scan,
where_t  where,
compare_t  op,
obr_t lhs,
obr_t rhs 
)

Definition at line 184 of file ast.c.

◆ obr_expr_digit()

obr_t* obr_expr_digit ( scan_t scan,
where_t  where,
const mpz_t  digit 
)

Definition at line 210 of file ast.c.

◆ obr_expr_field()

obr_t* obr_expr_field ( scan_t scan,
where_t  where,
obr_t expr,
char *  field 
)

Definition at line 144 of file ast.c.

◆ obr_expr_in()

obr_t* obr_expr_in ( scan_t scan,
where_t  where,
obr_t lhs,
obr_t rhs 
)

Definition at line 176 of file ast.c.

◆ obr_expr_is()

obr_t* obr_expr_is ( scan_t scan,
where_t  where,
obr_t lhs,
obr_t rhs 
)

Definition at line 168 of file ast.c.

◆ obr_expr_name()

obr_t* obr_expr_name ( scan_t scan,
where_t  where,
char *  name 
)

Definition at line 137 of file ast.c.

◆ obr_expr_string()

obr_t* obr_expr_string ( scan_t scan,
where_t  where,
char *  text,
size_t  length 
)

Definition at line 217 of file ast.c.

◆ obr_expr_unary()

obr_t* obr_expr_unary ( scan_t scan,
where_t  where,
unary_t  op,
obr_t expr 
)

Definition at line 202 of file ast.c.

◆ obr_field()

obr_t* obr_field ( obr_symbol_t symbol,
obr_t type 
)

Definition at line 327 of file ast.c.

◆ obr_import()

obr_t* obr_import ( scan_t scan,
where_t  where,
char *  name,
char *  symbol 
)

Definition at line 85 of file ast.c.

◆ obr_module()

obr_t* obr_module ( scan_t scan,
where_t  where,
char *  name,
char *  end,
const vector_t imports,
vector_t decls,
vector_t init 
)

Definition at line 72 of file ast.c.

◆ obr_param()

obr_t* obr_param ( obr_symbol_t symbol,
obr_t type,
bool  mut 
)

Definition at line 334 of file ast.c.

◆ obr_receiver()

obr_t* obr_receiver ( scan_t scan,
where_t  where,
bool  mut,
char *  name,
char *  type 
)

Definition at line 342 of file ast.c.

◆ obr_stmt_assign()

obr_t* obr_stmt_assign ( scan_t scan,
where_t  where,
obr_t dst,
obr_t src 
)

Definition at line 262 of file ast.c.

◆ obr_stmt_block()

obr_t* obr_stmt_block ( scan_t scan,
where_t  where,
vector_t stmts 
)

Definition at line 270 of file ast.c.

◆ obr_stmt_branch()

obr_t* obr_stmt_branch ( scan_t scan,
where_t  where,
obr_t cond,
vector_t then,
obr_t other 
)

Definition at line 277 of file ast.c.

◆ obr_stmt_break()

obr_t* obr_stmt_break ( scan_t scan,
where_t  where 
)

Definition at line 249 of file ast.c.

◆ obr_stmt_loop()

obr_t* obr_stmt_loop ( scan_t scan,
where_t  where,
vector_t loop 
)

Definition at line 242 of file ast.c.

◆ obr_stmt_repeat()

obr_t* obr_stmt_repeat ( scan_t scan,
where_t  where,
vector_t repeat,
obr_t until 
)

Definition at line 254 of file ast.c.

◆ obr_stmt_return()

obr_t* obr_stmt_return ( scan_t scan,
where_t  where,
obr_t expr 
)

Definition at line 227 of file ast.c.

◆ obr_stmt_while()

obr_t* obr_stmt_while ( scan_t scan,
where_t  where,
obr_t cond,
vector_t then 
)

Definition at line 234 of file ast.c.

◆ obr_symbol()

obr_symbol_t* obr_symbol ( scan_t scan,
where_t  where,
char *  name,
obr_visibility_t  visibility 
)

Definition at line 352 of file ast.c.

◆ obr_type_array()

obr_t* obr_type_array ( scan_t scan,
where_t  where,
const vector_t sizes,
obr_t type 
)

Definition at line 310 of file ast.c.

◆ obr_type_name()

obr_t* obr_type_name ( scan_t scan,
where_t  where,
char *  name 
)

Definition at line 288 of file ast.c.

◆ obr_type_pointer()

obr_t* obr_type_pointer ( scan_t scan,
where_t  where,
obr_t type 
)

Definition at line 303 of file ast.c.

◆ obr_type_qual()

obr_t* obr_type_qual ( scan_t scan,
where_t  where,
char *  name,
char *  symbol 
)

Definition at line 295 of file ast.c.

◆ obr_type_record()

obr_t* obr_type_record ( scan_t scan,
where_t  where,
vector_t fields 
)

Definition at line 318 of file ast.c.