From: Dale Weiler Date: Thu, 15 Jan 2015 23:12:54 +0000 (-0500) Subject: Forgot about this file X-Git-Tag: xonotic-v0.8.2~32 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7e0e041527e812a112635fe511fb1ad566b6c7fe;p=xonotic%2Fgmqcc.git Forgot about this file --- diff --git a/intrin.h b/intrin.h new file mode 100644 index 0000000..d3d2df3 --- /dev/null +++ b/intrin.h @@ -0,0 +1,75 @@ +#ifndef GMQCC_INTRIN_HDR +#define GMQCC_INTRIN_HDR +#include "gmqcc.h" + +struct fold_t; +struct parser_t; + +struct ast_function; +struct ast_expression; +struct ast_value; + +struct intrin; + +struct intrin_func_t { + ast_expression *(intrin::*function)(); + const char *name; + const char *alias; + size_t args; +}; + +struct intrin { + intrin() = default; + intrin(parser_t *parser); + + ast_expression *debug_typestring(); + ast_expression *fold(ast_value *val, ast_expression **exprs); + ast_expression *func_try(size_t offset, const char *compare); + ast_expression *func_self(const char *name, const char *from); + ast_expression *func(const char *name); + +protected: + lex_ctx_t ctx() const; + ast_function *value(ast_value **out, const char *name, qcint_t vtype); + void reg(ast_value *const value, ast_function *const func); + + ast_expression *nullfunc(); + ast_expression *isfinite_(); + ast_expression *isinf_(); + ast_expression *isnan_(); + ast_expression *isnormal_(); + ast_expression *signbit_(); + ast_expression *acosh_(); + ast_expression *asinh_(); + ast_expression *atanh_(); + ast_expression *exp_(); + ast_expression *exp2_(); + ast_expression *expm1_(); + ast_expression *pow_(); + ast_expression *mod_(); + ast_expression *fabs_(); + ast_expression *epsilon_(); + ast_expression *nan_(); + ast_expression *inf_(); + ast_expression *ln_(); + ast_expression *log_variant(const char *name, float base); + ast_expression *log_(); + ast_expression *log10_(); + ast_expression *log2_(); + ast_expression *logb_(); + ast_expression *shift_variant(const char *name, size_t instr); + ast_expression *lshift(); + ast_expression *rshift(); + + void error(const char *fmt, ...); + +private: + parser_t *m_parser; + fold_t *m_fold; + std::vector m_intrinsics; + std::vector m_generated; + +}; + + +#endif