void component_spec_iterate(nesc_declaration c, void (*iterator)(data_declaration fndecl, void *data), void *data, bool interfaces, bool otherdecls) { const char *ifname; void *ifentry; env_scanner scanifs; env_scan(c->env->id_env, &scanifs); while (env_next(&scanifs, &ifname, &ifentry)) { data_declaration idecl = ifentry; if (!otherdecls && !(idecl->kind == decl_interface_ref || idecl->kind == decl_function)) continue; if (idecl->kind != decl_interface_ref || interfaces) iterator(idecl, data); if (idecl->kind == decl_interface_ref) { env_scanner scanfns; const char *fnname; void *fnentry; interface_scan(idecl, &scanfns); while (env_next(&scanfns, &fnname, &fnentry)) iterator(fnentry, data); } } }
void copy_interface_functions(region r, nesc_declaration container, data_declaration iref, environment fns) { environment icopy = new_environment(r, NULL, TRUE, FALSE); env_scanner scanif; const char *fnname; void *fnentry; env_scan(fns->id_env, &scanif); while (env_next(&scanif, &fnname, &fnentry)) { data_declaration fndecl = fnentry, fncopy; /* Strings acquire a magic_string decl which we don't care about legal example: command int (*init())[sizeof "aa"]; */ if (fndecl->kind == decl_magic_string) continue; fncopy = declare(icopy, fndecl, FALSE); fncopy->fn_uses = NULL; fncopy->nuses = NULL; fncopy->instanceof = fndecl; fncopy->container = container; fncopy->interface = iref; /* required events and provided commands are defined */ fncopy->defined = (fncopy->ftype == function_command) ^ iref->required; } iref->functions = icopy; }
void set_interface_functions_gparms(environment fns, typelist gparms) { env_scanner scanif; const char *fnname; void *fnentry; env_scan(fns->id_env, &scanif); while (env_next(&scanif, &fnname, &fnentry)) { data_declaration fndecl = fnentry; /* Push generic args onto fn type and decl */ fndecl->gparms = gparms; fndecl->type = make_generic_type(fndecl->type, gparms); } }
static int SetVal (Config_t *cp, char const *str) { switch (cp->arg_type) { case CHAR: *(cp->var.CharP) = (char) str[0]; break; case BYTE: *(cp->var.ByteP) = (char) atoi (str); break; case U_BYTE: *(cp->var.UByteP) = (u_char) atoi (str); break; case SHORT: *(cp->var.ShortP) = (int16) atoi (str); break; case U_SHORT: *(cp->var.UShortP) = (uint16) atoi (str); break; case INT: *(cp->var.IntP) = (int32) atoi (str); break; case U_INT: *(cp->var.UIntP) = (u_int) atoi (str); break; case FLOAT: *(cp->var.FloatP) = (float) atof (str); break; case DOUBLE: *(cp->var.DoubleP) = (double) atof (str); break; case BOOL: if ((mystrcasecmp ("on", str) == 0) || (mystrcasecmp ("1", str) == 0) || (mystrcasecmp ("t", str) == 0) || (mystrcasecmp ("true", str) == 0) || (mystrcasecmp ("y", str) == 0) || (mystrcasecmp ("yes", str) == 0)) *(cp->var.BoolP) = TRUE; else if ((mystrcasecmp ("off", str) == 0) || (mystrcasecmp ("0", str) == 0) || (mystrcasecmp ("f", str) == 0) || (mystrcasecmp ("false", str) == 0) || (mystrcasecmp ("n", str) == 0) || (mystrcasecmp ("no", str) == 0)) *(cp->var.BoolP) = FALSE; else return (-1); break; case STRING: *(cp->var.StringP) = env_scan(str); break; case DATA_SRC: if (mystrcasecmp("hsa", str) == 0) *(cp->var.DataSrcP) = SRC_HSA; else if (mystrcasecmp("vqfile", str) == 0) *(cp->var.DataSrcP) = SRC_VQFILE; else if (mystrcasecmp("adcfile", str) == 0) *(cp->var.DataSrcP) = SRC_ADCFILE; else { printf ("Unknown data source %s\n", str); exit (-1); } break; default: fprintf (stderr, "bad param type %d\n", cp->arg_type); return (-1); } return (0); }
void component_scan(data_declaration cref, env_scanner *scan) { env_scan(cref->ctype->env->id_env, scan); }
void interface_scan(data_declaration iref, env_scanner *scan) { env_scan(iref->functions->id_env, scan); }