1 #ifndef GMQCC_PARSER_HDR
2 #define GMQCC_PARSER_HDR
12 std::vector<ast_value*> imm_float;
13 std::vector<ast_value*> imm_vector;
14 std::vector<ast_value*> imm_string;
15 hash_table_t *imm_string_untranslate; /* map<string, ast_value*> */
16 hash_table_t *imm_string_dotranslate; /* map<string, ast_value*> */
19 struct intrin_func_t {
20 ast_expression *(*intrin)(intrin_t *);
27 intrin_func_t *intrinsics; /* vector<intrin_func_t> */
28 ast_expression **generated; /* vector<ast_expression*> */
33 #define parser_ctx(p) ((p)->lex->tok.ctx)
41 std::vector<ast_expression *> globals;
42 std::vector<ast_expression *> fields;
43 std::vector<ast_function *> functions;
46 /* must be deleted first, they reference immediates and values */
47 std::vector<ast_value *> accessors;
50 ast_value *reserved_version;
55 ast_function *function;
58 /* All the labels the function defined...
59 * Should they be in ast_function instead?
61 std::vector<ast_label*> labels;
62 std::vector<ast_goto*> gotos;
63 std::vector<const char *> breaks;
64 std::vector<const char *> continues;
66 /* A list of hashtables for each scope */
72 /* not to be used directly, we use the hash table */
73 ast_expression **_locals;
75 ast_value **_typedefs;
76 size_t *_blocktypedefs;
77 lex_ctx_t *_block_ctx;
79 /* we store the '=' operator info */
80 const oper_info *assign_op;
83 ast_value *const_vec[3];
88 /* collected information */
89 size_t max_param_count;
97 char *parser_strdup (const char *str);
98 ast_expression *parser_find_global(parser_t *parser, const char *name);
101 fold_t *fold_init (parser_t *);
102 void fold_cleanup (fold_t *);
103 ast_expression *fold_constgen_float (fold_t *, qcfloat_t, bool);
104 ast_expression *fold_constgen_vector(fold_t *, vec3_t);
105 ast_expression *fold_constgen_string(fold_t *, const char *, bool);
106 bool fold_generate (fold_t *, ir_builder *);
107 ast_expression *fold_op (fold_t *, const oper_info *, ast_expression **);
108 ast_expression *fold_intrin (fold_t *, const char *, ast_expression **);
110 ast_expression *fold_binary (lex_ctx_t ctx, int, ast_expression *, ast_expression *);
111 int fold_cond_ifthen (ir_value *, ast_function *, ast_ifthen *);
112 int fold_cond_ternary (ir_value *, ast_function *, ast_ternary *);
115 intrin_t *intrin_init (parser_t *parser);
116 void intrin_cleanup (intrin_t *intrin);
117 ast_expression *intrin_fold (intrin_t *intrin, ast_value *, ast_expression **);
118 ast_expression *intrin_func (intrin_t *intrin, const char *name);
119 ast_expression *intrin_debug_typestring(intrin_t *intrin);