5 * Copyright 2002 Ove Kaaven
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 /* Berkeley yacc (byacc) doesn't seem to know about these */
41 /* Some *BSD supplied versions do define these though */
43 # define YYEMPTY (-1) /* Empty lookahead value of yychar */
46 # define YYLEX yylex()
49 #elif defined(YYBISON)
50 /* Bison was used for original development */
51 /* #define YYEMPTY -2 */
52 /* #define YYLEX yylex() */
55 /* No yacc we know yet */
56 # if !defined(YYEMPTY) || !defined(YYLEX)
57 # error Yacc version/type unknown. This version needs to be verified for settings of YYEMPTY and YYLEX.
58 # elif defined(__GNUC__) /* gcc defines the #warning directive */
59 # warning Yacc version/type unknown. It defines YYEMPTY and YYLEX, but is not tested
60 /* #else we just take a chance that it works... */
64 static attr_t *make_attr(enum attr_type type);
65 static attr_t *make_attrv(enum attr_type type, DWORD val);
66 static attr_t *make_attrp(enum attr_type type, void *val);
67 static expr_t *make_expr(enum expr_type type);
68 static expr_t *make_exprl(enum expr_type type, long val);
69 static expr_t *make_exprs(enum expr_type type, char *val);
70 static expr_t *make_exprt(enum expr_type type, typeref_t *tref, expr_t *expr);
71 static expr_t *make_expr1(enum expr_type type, expr_t *expr);
72 static expr_t *make_expr2(enum expr_type type, expr_t *exp1, expr_t *exp2);
73 static type_t *make_type(BYTE type, type_t *ref);
74 static typeref_t *make_tref(char *name, type_t *ref);
75 static typeref_t *uniq_tref(typeref_t *ref);
76 static type_t *type_ref(typeref_t *ref);
77 static void set_type(var_t *v, typeref_t *ref, expr_t *arr);
78 static var_t *make_var(char *name);
79 static func_t *make_func(var_t *def, var_t *args);
81 static type_t *reg_type(type_t *type, char *name, int t);
82 static type_t *reg_types(type_t *type, var_t *names, int t);
83 static type_t *find_type(char *name, int t);
84 static type_t *find_type2(char *name, int t);
85 static type_t *get_type(BYTE type, char *name, int t);
86 static type_t *get_typev(BYTE type, var_t *name, int t);
88 static var_t *reg_const(var_t *var);
89 static var_t *find_const(char *name, int f);
95 static type_t std_bool = { "boolean" };
96 static type_t std_int = { "int" };
97 static type_t std_int64 = { "__int64" };
98 static type_t std_uhyper = { "MIDL_uhyper" };
113 %token <str> aIDENTIFIER
114 %token <str> aKNOWNTYPE
115 %token <num> aNUM aHEXNUM
120 %token tAGGREGATABLE tALLOCATE tAPPOBJECT tARRAYS tASYNC tASYNCUUID
121 %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
122 %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
123 %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
124 %token tCONTEXTHANDLESERIALIZE tCONTROL tCPPQUOTE
127 %token tENUM tERRORSTATUST
134 %token tIMPORT tIMPORTLIB
135 %token tIN tINCLUDE tINLINE
141 %token tOBJECT tODL tOLEAUTOMATION
143 %token tPOINTERDEFAULT
147 %token tSIZEIS tSIZEOF
149 %token tSTRING tSTRUCT
150 %token tSWITCH tSWITCHIS tSWITCHTYPE
159 %token tWCHAR tWIREMARSHAL
164 %type <attr> m_attributes attributes attrib_list attribute
165 %type <expr> m_exprs /* exprs expr_list */ m_expr expr expr_list_const expr_const
166 %type <expr> array array_list
167 %type <type> inherit interface interfacehdr interfacedef lib_statements
168 %type <type> base_type int_std
169 %type <type> enumdef structdef typedef uniondef
171 %type <var> m_args no_args args arg
172 %type <var> fields field s_field cases case enums enum_list enum constdef externdef
173 %type <var> m_ident t_ident ident p_ident pident pident_list
174 %type <func> funcdef int_statements
175 %type <num> pointer_type version
190 input: lib_statements { /* FIXME */ }
193 lib_statements: { $$ = NULL; }
194 | lib_statements interface ';' { if (!parse_only) write_forward($2); }
195 | lib_statements interfacedef { LINK($2, $1); $$ = $2; }
196 /* | lib_statements librarydef (when implemented) */
197 | lib_statements statement
200 int_statements: { $$ = NULL; }
201 | int_statements funcdef ';' { LINK($2, $1); $$ = $2; }
202 | int_statements statement
206 | constdef ';' { if (!parse_only) { write_constdef($1); } }
208 | enumdef ';' { if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
209 | externdef ';' { if (!parse_only) { write_externdef($1); } }
211 /* | interface ';' {} */
212 /* | interfacedef {} */
213 | structdef ';' { if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
215 | uniondef ';' { if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
218 cppquote: tCPPQUOTE '(' aSTRING ')' { if (!parse_only) fprintf(header, "%s\n", $3); }
220 import_start: tIMPORT aSTRING ';' { assert(yychar == YYEMPTY);
221 if (!do_import($2)) yychar = aEOF; }
223 import: import_start input aEOF {}
226 m_args: { $$ = NULL; }
230 no_args: tVOID { $$ = NULL; }
234 | args ',' arg { LINK($3, $1); $$ = $3; }
238 /* split into two rules to get bison to resolve a tVOID conflict */
239 arg: attributes type pident array { $$ = $3;
240 set_type($$, $2, $4);
243 | type pident array { $$ = $2;
244 set_type($$, $1, $3);
246 | attributes type pident '(' m_args ')' { $$ = $3;
248 set_type($$, $2, NULL);
252 | type pident '(' m_args ')' { $$ = $2;
254 set_type($$, $1, NULL);
259 array: { $$ = NULL; }
260 | '[' array_list ']' { $$ = $2; }
261 | '[' '*' ']' { $$ = make_expr(EXPR_VOID); }
264 array_list: m_expr /* size of first dimension is optional */
265 | array_list ',' expr { LINK($3, $1); $$ = $3; }
266 | array_list ']' '[' expr { LINK($4, $1); $$ = $4; }
269 m_attributes: { $$ = NULL; }
274 '[' attrib_list ']' { $$ = $2; }
277 attrib_list: attribute
278 | attrib_list ',' attribute { LINK($3, $1); $$ = $3; }
279 | attrib_list ']' '[' attribute { LINK($4, $1); $$ = $4; }
283 tASYNC { $$ = make_attr(ATTR_ASYNC); }
284 | tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); }
285 | tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); }
286 | tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); }
287 | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ }
288 | tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ }
289 | tDEFAULT { $$ = make_attr(ATTR_DEFAULT); }
290 | tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); }
291 | tIIDIS '(' ident ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
292 | tIN { $$ = make_attr(ATTR_IN); }
293 | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
294 | tLOCAL { $$ = make_attr(ATTR_LOCAL); }
295 | tOBJECT { $$ = make_attr(ATTR_OBJECT); }
296 | tOLEAUTOMATION { $$ = make_attr(ATTR_OLEAUTOMATION); }
297 | tOUT { $$ = make_attr(ATTR_OUT); }
298 | tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv(ATTR_POINTERDEFAULT, $3); }
299 | tSIZEIS '(' m_exprs ')' { $$ = make_attrp(ATTR_SIZEIS, $3); }
300 | tSTRING { $$ = make_attr(ATTR_STRING); }
301 | tSWITCHIS '(' expr ')' { $$ = make_attrp(ATTR_SWITCHIS, $3); }
302 | tSWITCHTYPE '(' type ')' { $$ = make_attrp(ATTR_SWITCHTYPE, type_ref($3)); }
303 | tUUID '(' aUUID ')' { $$ = make_attrp(ATTR_UUID, $3); }
304 | tV1ENUM { $$ = make_attr(ATTR_V1ENUM); }
305 | tVERSION '(' version ')' { $$ = make_attrv(ATTR_VERSION, $3); }
306 | tWIREMARSHAL '(' type ')' { $$ = make_attrp(ATTR_WIREMARSHAL, type_ref($3)); }
307 | pointer_type { $$ = make_attrv(ATTR_POINTERTYPE, $1); }
314 cases: { $$ = NULL; }
315 | cases case { if ($2) { LINK($2, $1); $$ = $2; }
320 case: tCASE expr ':' field { attr_t *a = make_attrp(ATTR_CASE, $2);
321 $$ = $4; if (!$$) $$ = make_var(NULL);
322 LINK(a, $$->attrs); $$->attrs = a;
324 | tDEFAULT ':' field { attr_t *a = make_attr(ATTR_DEFAULT);
325 $$ = $3; if (!$$) $$ = make_var(NULL);
326 LINK(a, $$->attrs); $$->attrs = a;
330 constdef: tCONST type ident '=' expr_const { $$ = reg_const($3);
331 set_type($$, $2, NULL);
337 enums: { $$ = NULL; }
338 | enum_list ',' { $$ = $1; }
343 | enum_list ',' enum { LINK($3, $1); $$ = $3;
345 $3->lval = $1->lval + 1;
349 enum: ident '=' expr_const { $$ = reg_const($1);
353 | ident { $$ = reg_const($1);
354 $$->lval = 0; /* default for first enum entry */
358 enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM);
365 | m_exprs ',' m_expr { LINK($3, $1); $$ = $3; }
369 exprs: { $$ = make_expr(EXPR_VOID); }
374 | expr_list ',' expr { LINK($3, $1); $$ = $3; }
378 m_expr: { $$ = make_expr(EXPR_VOID); }
382 expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
383 | aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
384 | aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
385 | expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
386 | expr '&' expr { $$ = make_expr2(EXPR_AND, $1, $3); }
387 | expr '+' expr { $$ = make_expr2(EXPR_ADD, $1, $3); }
388 | expr '-' expr { $$ = make_expr2(EXPR_SUB, $1, $3); }
389 | expr '*' expr { $$ = make_expr2(EXPR_MUL, $1, $3); }
390 | expr '/' expr { $$ = make_expr2(EXPR_DIV, $1, $3); }
391 | expr SHL expr { $$ = make_expr2(EXPR_SHL, $1, $3); }
392 | expr SHR expr { $$ = make_expr2(EXPR_SHR, $1, $3); }
393 | '~' expr { $$ = make_expr1(EXPR_NOT, $2); }
394 | '-' expr %prec NEG { $$ = make_expr1(EXPR_NEG, $2); }
395 | '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); }
396 | '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
397 | tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
398 | '(' expr ')' { $$ = $2; }
401 expr_list_const: expr_const
402 | expr_list_const ',' expr_const { LINK($3, $1); $$ = $3; }
405 expr_const: expr { $$ = $1;
406 if (!$$->is_const) yyerror("expression is not constant\n");
410 externdef: tEXTERN tCONST type ident { $$ = $4;
411 set_type($$, $3, NULL);
415 fields: { $$ = NULL; }
416 | fields field { if ($2) { LINK($2, $1); $$ = $2; }
421 field: s_field ';' { $$ = $1; }
422 | m_attributes uniondef ';' { $$ = make_var(NULL); $$->type = $2; $$->attrs = $1; }
423 | attributes ';' { $$ = make_var(NULL); $$->attrs = $1; }
427 s_field: m_attributes type pident array { $$ = $3; set_type($$, $2, $4); $$->attrs = $1; }
431 m_attributes type callconv pident
432 '(' m_args ')' { set_type($4, $2, NULL);
434 $$ = make_func($4, $6);
438 m_ident: { $$ = NULL; }
442 t_ident: { $$ = NULL; }
443 | aIDENTIFIER { $$ = make_var($1); }
444 | aKNOWNTYPE { $$ = make_var($1); }
447 ident: aIDENTIFIER { $$ = make_var($1); }
448 /* some "reserved words" used in attributes are also used as field names in some MS IDL files */
449 | tVERSION { $$ = make_var($<str>1); }
452 base_type: tBYTE { $$ = make_type(RPC_FC_BYTE, NULL); }
453 | tWCHAR { $$ = make_type(RPC_FC_WCHAR, NULL); }
455 | tSIGNED int_std { $$ = $2; $$->sign = 1; }
456 | tUNSIGNED int_std { $$ = $2; $$->sign = -1;
458 case RPC_FC_SMALL: $$->type = RPC_FC_USMALL; break;
459 case RPC_FC_SHORT: $$->type = RPC_FC_USHORT; break;
460 case RPC_FC_LONG: $$->type = RPC_FC_ULONG; break;
462 if (!$$->ref) { $$->ref = &std_uhyper; $$->sign = 0; }
467 | tFLOAT { $$ = make_type(RPC_FC_FLOAT, NULL); }
468 | tDOUBLE { $$ = make_type(RPC_FC_DOUBLE, NULL); }
469 | tBOOLEAN { $$ = make_type(RPC_FC_BYTE, &std_bool); /* ? */ }
470 | tERRORSTATUST { $$ = make_type(RPC_FC_ERROR_STATUS_T, NULL); }
471 | tHANDLET { $$ = make_type(RPC_FC_BIND_PRIMITIVE, NULL); /* ? */ }
478 int_std: tINT { $$ = make_type(RPC_FC_LONG, &std_int); } /* win32 only */
479 | tSHORT m_int { $$ = make_type(RPC_FC_SHORT, NULL); }
480 | tLONG m_int { $$ = make_type(RPC_FC_LONG, NULL); }
481 | tHYPER m_int { $$ = make_type(RPC_FC_HYPER, NULL); }
482 | tINT64 { $$ = make_type(RPC_FC_HYPER, &std_int64); }
483 | tCHAR { $$ = make_type(RPC_FC_CHAR, NULL); }
486 inherit: { $$ = NULL; }
487 | ':' aKNOWNTYPE { $$ = find_type2($2, 0); }
490 interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); }
491 | tINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); }
494 interfacehdr: attributes interface { $$ = $2;
495 if ($$->defined) yyerror("multiple definition error\n");
498 if (!parse_only) write_forward($$);
502 interfacedef: interfacehdr inherit
503 '{' int_statements '}' { $$ = $1;
506 if (!parse_only) write_interface($$);
508 /* MIDL is able to import the definition of a base class from inside the
509 * definition of a derived class, I'll try to support it with this rule */
510 | interfacehdr ':' aIDENTIFIER
511 '{' import int_statements '}' { $$ = $1;
512 $$->ref = find_type2($3, 0);
513 if (!$$->ref) yyerror("base class %s not found in import\n", $3);
515 if (!parse_only) write_interface($$);
519 p_ident: '*' pident %prec PPTR { $$ = $2; $$->ptr_level++; }
520 | tCONST p_ident { $$ = $2; /* FIXME */ }
525 | '(' pident ')' { $$ = $2; }
530 | pident_list ',' pident { LINK($3, $1); $$ = $3; }
534 tREF { $$ = RPC_FC_RP; }
535 | tUNIQUE { $$ = RPC_FC_UP; }
538 structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, tsSTRUCT);
544 type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }
545 | aKNOWNTYPE { $$ = make_tref($1, find_type($1, 0)); }
546 | base_type { $$ = make_tref(NULL, $1); }
547 | tCONST type { $$ = uniq_tref($2); $$->ref->is_const = TRUE; }
548 | enumdef { $$ = make_tref(NULL, $1); }
549 | tENUM aIDENTIFIER { $$ = make_tref(NULL, find_type2($2, tsENUM)); }
550 | structdef { $$ = make_tref(NULL, $1); }
551 | tSTRUCT aIDENTIFIER { $$ = make_tref(NULL, get_type(RPC_FC_STRUCT, $2, tsSTRUCT)); }
552 | uniondef { $$ = make_tref(NULL, $1); }
553 | tUNION aIDENTIFIER { $$ = make_tref(NULL, find_type2($2, tsUNION)); }
556 typedef: tTYPEDEF m_attributes type pident_list { typeref_t *tref = uniq_tref($3);
557 $4->tname = tref->name;
561 if (!parse_only) write_typedef($$, $4);
562 reg_types($$, $4, 0);
566 uniondef: tUNION t_ident '{' fields '}' { $$ = get_typev(RPC_FC_NON_ENCAPSULATED_UNION, $2, tsUNION);
571 tSWITCH '(' s_field ')'
572 m_ident '{' cases '}' { var_t *u = $7;
573 $$ = get_typev(RPC_FC_ENCAPSULATED_UNION, $2, tsUNION);
574 if (!u) u = make_var("tagged_union");
575 u->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL);
576 u->type->fields = $9;
577 u->type->defined = TRUE;
578 LINK(u, $5); $$->fields = u;
584 aNUM { $$ = MAKELONG($1, 0); }
585 | aNUM '.' aNUM { $$ = MAKELONG($1, $3); }
590 static attr_t *make_attr(enum attr_type type)
592 attr_t *a = xmalloc(sizeof(attr_t));
599 static attr_t *make_attrv(enum attr_type type, DWORD val)
601 attr_t *a = xmalloc(sizeof(attr_t));
608 static attr_t *make_attrp(enum attr_type type, void *val)
610 attr_t *a = xmalloc(sizeof(attr_t));
617 static expr_t *make_expr(enum expr_type type)
619 expr_t *e = xmalloc(sizeof(expr_t));
628 static expr_t *make_exprl(enum expr_type type, long val)
630 expr_t *e = xmalloc(sizeof(expr_t));
636 /* check for numeric constant */
637 if (type == EXPR_NUM || type == EXPR_HEXNUM) {
644 static expr_t *make_exprs(enum expr_type type, char *val)
647 e = xmalloc(sizeof(expr_t));
653 /* check for predefined constants */
654 if (type == EXPR_IDENTIFIER) {
655 var_t *c = find_const(val, 0);
666 static expr_t *make_exprt(enum expr_type type, typeref_t *tref, expr_t *expr)
669 e = xmalloc(sizeof(expr_t));
675 /* check for cast of constant expression */
676 if (type == EXPR_CAST && expr->is_const) {
678 e->cval = expr->cval;
683 static expr_t *make_expr1(enum expr_type type, expr_t *expr)
686 e = xmalloc(sizeof(expr_t));
692 /* check for compile-time optimization */
693 if (expr->is_const) {
697 e->cval = -expr->cval;
700 e->cval = ~expr->cval;
710 static expr_t *make_expr2(enum expr_type type, expr_t *expr1, expr_t *expr2)
713 e = xmalloc(sizeof(expr_t));
719 /* check for compile-time optimization */
720 if (expr1->is_const && expr2->is_const) {
724 e->cval = expr1->cval + expr2->cval;
727 e->cval = expr1->cval - expr2->cval;
730 e->cval = expr1->cval * expr2->cval;
733 e->cval = expr1->cval / expr2->cval;
736 e->cval = expr1->cval | expr2->cval;
739 e->cval = expr1->cval & expr2->cval;
742 e->cval = expr1->cval << expr2->cval;
745 e->cval = expr1->cval >> expr2->cval;
755 static type_t *make_type(BYTE type, type_t *ref)
757 type_t *t = xmalloc(sizeof(type_t));
765 t->ignore = parse_only;
774 static typeref_t *make_tref(char *name, type_t *ref)
776 typeref_t *t = xmalloc(sizeof(typeref_t));
779 t->uniq = ref ? 0 : 1;
783 static typeref_t *uniq_tref(typeref_t *ref)
787 if (t->uniq) return t;
788 tp = make_type(0, t->ref);
796 static type_t *type_ref(typeref_t *ref)
798 type_t *t = ref->ref;
799 if (ref->name) free(ref->name);
804 static void set_type(var_t *v, typeref_t *ref, expr_t *arr)
807 v->tname = ref->name;
813 static var_t *make_var(char *name)
815 var_t *v = xmalloc(sizeof(var_t));
828 static func_t *make_func(var_t *def, var_t *args)
830 func_t *f = xmalloc(sizeof(func_t));
833 f->ignore = parse_only;
841 static int hash_ident(const char *name)
843 const char *p = name;
845 /* a simple sum hash is probably good enough */
850 return sum & (HASHMAX-1);
853 /***** type repository *****/
862 struct rtype *type_hash[HASHMAX];
864 static type_t *reg_type(type_t *type, char *name, int t)
869 yyerror("registering named type without name\n");
872 hash = hash_ident(name);
873 nt = xmalloc(sizeof(struct rtype));
877 nt->next = type_hash[hash];
878 type_hash[hash] = nt;
882 static type_t *reg_types(type_t *type, var_t *names, int t)
888 var_t *next = NEXT_LINK(names);
891 int cptr = names->ptr_level;
893 while (cptr > ptrc) {
894 cur = ptr = make_type(RPC_FC_FP, cur); /* FIXME: pointer type from attrs? */
898 while (cptr < ptrc) {
903 reg_type(cur, names->name, t);
911 static type_t *find_type(char *name, int t)
913 struct rtype *cur = type_hash[hash_ident(name)];
914 while (cur && (cur->t != t || strcmp(cur->name, name)))
917 yyerror("type %s not found\n", name);
923 static type_t *find_type2(char *name, int t)
925 type_t *tp = find_type(name, t);
930 int is_type(const char *name)
932 struct rtype *cur = type_hash[hash_ident(name)];
933 while (cur && (cur->t || strcmp(cur->name, name)))
935 if (cur) return TRUE;
939 static type_t *get_type(BYTE type, char *name, int t)
941 struct rtype *cur = NULL;
944 cur = type_hash[hash_ident(name)];
945 while (cur && (cur->t != t || strcmp(cur->name, name)))
952 tp = make_type(type, NULL);
954 if (!name) return tp;
955 return reg_type(tp, name, t);
958 static type_t *get_typev(BYTE type, var_t *name, int t)
965 return get_type(type, sname, t);
968 /***** constant repository *****/
976 struct rconst *const_hash[HASHMAX];
978 static var_t *reg_const(var_t *var)
983 yyerror("registering constant without name\n");
986 hash = hash_ident(var->name);
987 nc = xmalloc(sizeof(struct rconst));
988 nc->name = var->name;
990 nc->next = const_hash[hash];
991 const_hash[hash] = nc;
995 static var_t *find_const(char *name, int f)
997 struct rconst *cur = const_hash[hash_ident(name)];
998 while (cur && strcmp(cur->name, name))
1001 if (f) yyerror("constant %s not found\n", name);