int paramlstmatch(param_t *p1,param_t *p2) { return p1 == p2 || p1 && p2 && typematch(p1->Ptype,p2->Ptype,0) && paramlstmatch(p1->Pnext,p2->Pnext) ; }
int typematch(type *t1,type *t2,int relax) { tym_t t1ty, t2ty; tym_t tym; tym = ~(mTYimport | mTYnaked); return t1 == t2 || t1 && t2 && ( /* ignore name mangling */ (t1ty = (t1->Tty & tym)) == (t2ty = (t2->Tty & tym)) ) && (tybasic(t1ty) != TYarray || t1->Tdim == t2->Tdim || t1->Tflags & TFsizeunknown || t2->Tflags & TFsizeunknown) && (tybasic(t1ty) != TYstruct && tybasic(t1ty) != TYenum && tybasic(t1ty) != TYmemptr || t1->Ttag == t2->Ttag) && typematch(t1->Tnext,t2->Tnext, 0) && (!tyfunc(t1ty) || ((t1->Tflags & TFfixed) == (t2->Tflags & TFfixed) && paramlstmatch(t1->Tparamtypes,t2->Tparamtypes) )) ; }
STATIC void cpp_argument_list(type *t, int flag) { int i; tym_t ty; //printf("cpp_argument_list(flag = %d)\n", flag); // If a data type that encodes only into one character ty = tybasic(t->Tty); if (ty <= TYldouble && ty != TYenum && ty != TYbool // added for versions >= 8.1b9 #if OVERLOAD_CV_PARAM && !(t->Tty & (mTYconst | mTYvolatile)) #endif ) { cpp_primary_data_type(t); } else { // See if a match with a previously used type for (i = 0; 1; i++) { if (i == mangle.argi) // no match { #if OVERLOAD_CV_PARAM if (ty <= TYcldouble || ty == TYstruct) { int cvidx = cpp_cvidx(t->Tty); if (cvidx) { // Digital Mars extensions CHAR('_'); CHAR('N' + cvidx); // _O, _P, _Q prefix } } #endif if (flag && tybasic(t->Tty) == TYarray) { cpp_reference_data_type(t, flag); } else cpp_primary_data_type(t); if (mangle.argi < 10) mangle.arg[mangle.argi++] = t; break; } if (typematch(t,mangle.arg[i],0)) { CHAR('0' + i); // argument_replicator break; } } } }
static void return_stmt(void) { int lv[LV]; Token = scan(); if (Token != SEMI) { if (expr(lv)) rvalue(lv); if (!typematch(lv[LVPRIM], Prims[Thisfn])) error("incompatible type in 'return'", NULL); } else { if (Prims[Thisfn] != PVOID) error("missing value after 'return'", NULL); } genjump(Retlab); semi(); }
int main(int argc, char *argv[]) { unsigned int i; const char *type; const char *function = NULL; if (argc < 3) errx(1, "Usage: doc_extract [--function=<funcname>] TYPE <file>...\n" "Where TYPE is functions|author|license|maintainer|summary|description|example|see_also|all"); if (strstarts(argv[1], "--function=")) { function = argv[1] + strlen("--function="); argv++; argc--; } type = argv[1]; for (i = 2; i < argc; i++) { char *file, **lines; struct list_head *list; struct doc_section *d; file = grab_file(NULL, argv[i], NULL); if (!file) err(1, "Reading file %s", argv[i]); lines = strsplit(file, file, "\n"); list = extract_doc_sections(lines); if (list_empty(list)) errx(1, "No documentation in file %s", argv[i]); talloc_free(file); if (streq(type, "functions")) { const char *last = NULL; list_for_each(list, d, list) { if (d->function) { if (!last || !streq(d->function, last)) printf("%s\n", d->function); last = d->function; } } } else { unsigned int j; list_for_each(list, d, list) { if (function) { if (!d->function) continue; if (!streq(d->function, function)) continue; } if (streq(type, "all")) printf("%s:\n", d->type); else if (!typematch(d->type, type)) continue; for (j = 0; j < d->num_lines; j++) printf("%s\n", d->lines[j]); } } talloc_free(list); }