diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fwd/ast.h | 34 | ||||
| -rw-r--r-- | include/fwd/debug.h | 2 | ||||
| -rw-r--r-- | include/fwd/mod.h | 60 |
3 files changed, 57 insertions, 39 deletions
diff --git a/include/fwd/ast.h b/include/fwd/ast.h index 4359525..8af444c 100644 --- a/include/fwd/ast.h +++ b/include/fwd/ast.h @@ -229,8 +229,8 @@ enum ast_flag { AST_FLAG_ANALYZED = (1 << 0), AST_FLAG_PREANALYZIS = (1 << 1), AST_FLAG_NOMOVES = (1 << 2), - AST_FLAG_PUBLIC = (1 << 3), - AST_REQ_FRAME = (1 << 4), + AST_FLAG_PUBLIC = (1 << 3), + AST_REQ_FRAME = (1 << 4), AST_FLAG_LOWERED = (1 << 5) }; @@ -387,15 +387,23 @@ static inline bool is_trivially_copyable(struct type *type) return false; } -#define gen_str_type1(k, s, t, a, loc) gen_ast(k, a, NULL, NULL, NULL, \ - t, s, -1, 0., loc) +#define gen_str_type1(k, s, t, a, loc) \ + gen_ast(k, a, NULL, NULL, NULL, \ + t, s, -1, 0., loc \ + ) + #define gen_str_type(k, s, t, loc) gen_str_type1(k, s, t, NULL, loc) -#define gen_str3(k, s, a, b, c, loc) gen_ast(k, a, b, c, NULL, NULL, s, -1, 0., \ - loc) +#define gen_str3(k, s, a, b, c, loc) \ + gen_ast(k, a, b, c, NULL, NULL, s, \ + -1, 0., loc \ + ) + #define gen_str2(k, s, a, b, loc) gen_str3(k, s, a, b, NULL, loc) #define gen_str1(k, s, a, loc) gen_str2(k, s, a, NULL, loc) -#define gen_str(k, s, loc) gen_ast(k, NULL, NULL, NULL, NULL, NULL, s, -1, 0., \ - loc) +#define gen_str(k, s, loc) \ + gen_ast(k, NULL, NULL, NULL, NULL, NULL, \ + s, -1, 0., loc \ + ) #define gen4(k, a, b, c, d, loc) gen_ast(k, a, b, c, d, NULL, NULL, -1, 0., loc) #define gen3(k, a, b, c, loc) gen4(k, a, b, c, NULL, loc) @@ -496,7 +504,9 @@ static inline bool is_trivially_copyable(struct type *type) gen_str3(AST_TEMPLATE, id, types, params, body, loc) #define gen_supertemplate(id, types, params, inst, body, loc) \ - gen_ast(AST_SUPERTEMPLATE, types, params, inst, body, NULL, id, 0, 0., loc) + gen_ast(AST_SUPERTEMPLATE, types, params, inst, body, \ + NULL, id, 0, 0., loc \ + ) #define gen_self(loc) \ gen0(AST_SELF, loc) @@ -668,8 +678,10 @@ struct ast *ast_prepend(struct ast *list, struct ast *elem); typedef int (*ast_callback_t)(struct ast *, void *); typedef int (*type_callback_t)(struct type *, void *); -int ast_visit(ast_callback_t before, ast_callback_t after, struct ast *node, - void *data); + +int ast_visit(ast_callback_t before, ast_callback_t after, + struct ast *node, void *data); + int ast_visit_list(ast_callback_t before, ast_callback_t after, struct ast *node, void *data); diff --git a/include/fwd/debug.h b/include/fwd/debug.h index ac4dfdf..8927580 100644 --- a/include/fwd/debug.h +++ b/include/fwd/debug.h @@ -97,7 +97,7 @@ void semantic_error(struct scope *scope, struct ast *node, const char *fmt, ...); void type_error(struct scope *scope, struct type *type, const char *fmt, - ...); + ...); void loc_error(struct scope *scope, struct src_loc loc, const char *fmt, ...); diff --git a/include/fwd/mod.h b/include/fwd/mod.h index ef0448e..1a48130 100644 --- a/include/fwd/mod.h +++ b/include/fwd/mod.h @@ -47,10 +47,14 @@ typedef struct fwd_state fwd_state_t; typedef long (*fwd_extern_t)(fwd_extern_args_t args); typedef long (*fwd_open_t)(fwd_state_t *state); -extern int fwd_register(struct fwd_state *state, const char *name, fwd_extern_t func, fwd_type_t rtype, ...); +extern int fwd_register(struct fwd_state *state, const char *name, + fwd_extern_t func, fwd_type_t rtype, ...); -#define FWD_REGISTER(state, func, rtype, ...) \ - fwd_register(state, #func, func, rtype __VA_OPT__(,) __VA_ARGS__, FWD_END) +#define FWD_REGISTER(state, func, rtype, ...) \ + fwd_register(state, #func, func, \ + rtype __VA_OPT__( ,) __VA_ARGS__, \ + FWD_END \ + ) static inline void *fwd_arg(fwd_extern_args_t args, size_t idx, fwd_type_t id) { @@ -124,17 +128,18 @@ static inline fwd_arg_t fwd_ret_ptr(void *x) } /* unimplemented as of yet */ -#define FWD_RET(t, a, x) \ - (a).args[0] = _Generic((t)(0), \ - int8_t : fwd_ret_i8, \ - int16_t : fwd_ret_i16, \ - int32_t : fwd_ret_i32, \ - int64_t : fwd_ret_i64, \ - uint8_t : fwd_ret_u8, \ - uint16_t : fwd_ret_u16, \ - uint32_t : fwd_ret_u32, \ - uint64_t : fwd_ret_u64, \ - default : fwd_ret_ptr)((x)); +#define FWD_RET(t, a, x) \ + (a).args[0] = _Generic((t)(0), \ + int8_t: fwd_ret_i8, \ + int16_t: fwd_ret_i16, \ + int32_t: fwd_ret_i32, \ + int64_t: fwd_ret_i64, \ + uint8_t: fwd_ret_u8, \ + uint16_t: fwd_ret_u16, \ + uint32_t: fwd_ret_u32, \ + uint64_t: fwd_ret_u64, \ + default: fwd_ret_ptr \ + )((x)); static inline fwd_type_t fwd_t_signed(size_t s) { @@ -168,19 +173,20 @@ static inline fwd_type_t fwd_t_ptr(size_t s) return FWD_PTR; } -#define FWD_T(type) \ - _Generic((type)(0),\ - signed char : fwd_t_signed, \ - signed short : fwd_t_signed, \ - signed int : fwd_t_signed, \ - signed long : fwd_t_signed, \ - signed long long : fwd_t_signed, \ - unsigned char : fwd_t_unsigned, \ - unsigned short : fwd_t_unsigned, \ - unsigned int : fwd_t_unsigned, \ - unsigned long : fwd_t_unsigned, \ - unsigned long long : fwd_t_signed, \ - default: fwd_t_ptr)(sizeof(type)) +#define FWD_T(type) \ + _Generic((type)(0), \ + signed char : fwd_t_signed, \ + signed short : fwd_t_signed, \ + signed int : fwd_t_signed, \ + signed long : fwd_t_signed, \ + signed long long : fwd_t_signed, \ + unsigned char : fwd_t_unsigned, \ + unsigned short : fwd_t_unsigned, \ + unsigned int : fwd_t_unsigned, \ + unsigned long : fwd_t_unsigned, \ + unsigned long long : fwd_t_signed, \ + default: fwd_t_ptr \ + )(sizeof(type)) #endif /* FWD_MOD_H */ |
