static int private_proc_types_check (t_proc_t const * self, t_proc_t const * other, int (*pred)(type_t const*, type_t const*)) { if (!pred (self->ret_type, other->ret_type)) return 0; // NULL means "any number of arguments of any type". if (self->arg_types == NULL || other->arg_types == NULL) return 1; slist_it_t * it1 = slist_iter (self->arg_types); slist_it_t * it2 = slist_iter (other->arg_types); int ret = 0; while (slist_it_has (it1) && slist_it_has (it2)) { type_t * t1 = slist_it_get (it1); type_t * t2 = slist_it_get (it2); if (!pred (t1, t2)) // leave ret at 0 and jump away goto cleanup; slist_it_next (it1); slist_it_next (it2); } // so far, all types were compatible // also require same number of arguments ret = slist_it_has (it1) == slist_it_has (it2); cleanup: delete_slist_it (it1); delete_slist_it (it2); return ret; }
int is_metatype (type_t const * self) { assert (self != NULL); while (1) { if (self->base.kind == tk_unknown || self->base.kind == tk_implicit || self->base.kind == tk_any) return 1; else if (self->base.kind == tk_array) self = self->t_array.host; else if (self->base.kind == tk_own) self = self->t_own.host; else if (self->base.kind == tk_proc) { if (is_metatype (self->t_proc.ret_type)) return 1; slist_it_t * it = slist_iter (self->t_proc.arg_types); int ret = 0; for (; slist_it_has (it); slist_it_next (it)) if (is_metatype (a60_as_type (slist_it_get (it)))) { ret = 1; break; } delete_slist_it (it); return ret; } else return 0; } }
slist_t * label_add_boundspairs_with (label_t * self, slist_t * bps) { assert (self != NULL); assert (bps != NULL); slist_t * list = label_add_boundspairs (self); slist_it_t * it = slist_iter (bps); for (; slist_it_has (it); slist_it_next (it)) slist_pushback (list, slist_it_get (it)); delete_slist_it (it); return list; }
static void private_switch_resolve_symbols (type_t * tself, container_t * context, logger_t * log) { slist_t * switchlist = tself->t_switch.switchlist; slist_it_t * it = slist_iter (switchlist); for (; slist_it_has (it); slist_it_next (it)) { desig_expr_t * de = slist_it_get (it); // 5.3.5 Influence of Scopes: states that variables are bound at // declaration site, not at use site. We got lucky this time. desig_expr_resolve_symbols (de, context, log); } delete_slist_it (it); }
static void master_update_pseudo_status( resource_t *rsc, gboolean *demoting, gboolean *promoting) { if(rsc->children) { slist_iter(child, resource_t, rsc->children, lpc, master_update_pseudo_status(child, demoting, promoting) ); return; } CRM_ASSERT(demoting != NULL); CRM_ASSERT(promoting != NULL); slist_iter( action, action_t, rsc->actions, lpc, if(*promoting && *demoting) { return; } else if(action->optional) {
static void private_type_to_str (type_t const * self, estring_t * buf, int canon) { static char const* typestrs [] = { [tk_unknown] = "<unknown>", [tk_implicit] = "<implicit>", [tk_any] = "<any>", [tk_int] = "'integer'", [tk_void] = "<void>", [tk_real] = "'real'", [tk_string] = "'string'", [tk_bool] = "'Boolean'", [tk_label] = "<label>" }; if ((self->base.kind < sizeof (typestrs) / sizeof (*typestrs)) && typestrs[self->base.kind]) { estr_assign_cstr (buf, typestrs[self->base.kind]); return; } switch (self->base.kind) { case tk_unknown: case tk_implicit: case tk_any: case tk_int: case tk_void: case tk_real: case tk_string: case tk_bool: case tk_label: assert (!"Should already be covered!"); case tk_switch: { estring_t * tmp = NULL; estr_append_cstr (buf, "'switch'"); slist_t * switchlist = self->t_switch.switchlist; if (!slist_empty (switchlist)) { estr_push (buf, ' '); slist_it_t * it = slist_iter (switchlist); for (; slist_it_has (it); ) { desig_expr_t * de = slist_it_get (it); tmp = desig_expr_to_str (de, tmp); estr_append (buf, tmp); slist_it_next (it); if (slist_it_has (it)) estr_append_cstr (buf, ", "); } delete_slist_it (it); } } case tk_array: { type_t * host = self->t_array.host; private_type_to_str (host, buf, canon); if (!canon || host->base.kind != tk_array) estr_append_cstr (buf, " 'array'"); return; } case tk_own: { private_type_to_str (self->t_own.host, buf, canon); estr_prepend_cstr (buf, "'own' "); return; } case tk_proc: { estr_assign_cstr (buf, "<proc ("); estring_t * tmp = new_estring (); if (!slist_empty (self->t_proc.arg_types)) { slist_it_t * it = slist_iter (self->t_proc.arg_types); while (1) { type_t * t = slist_it_get (it); private_type_to_str (t, tmp, canon); estr_append (buf, tmp); slist_it_next (it); if (slist_it_has (it)) estr_append_cstr (buf, ", "); else break; } delete_slist_it (it); } estr_append_cstr (buf, ") -> "); private_type_to_str (self->t_proc.ret_type, tmp, canon); estr_append (buf, tmp); estr_append_cstr (buf, ">"); delete_estring (tmp); return; } }; assert (!"Should never get there!"); }