コード例 #1
0
ファイル: overload.c プロジェクト: gilzoide/pq-lang
static inline pq_value *_pq_overload_for_types_variadic(pq_context *ctx, pq_overload *overload, size_t n, pq_type **types) {
	Word_t *pvalue;
	pq_type *argument_types_tuple;
	Pvoid_t by_argnum_table = overload->variadic_function_table, by_type_table;
	JLL(pvalue, by_argnum_table, n);
	while(pvalue != NULL) {
		by_type_table = (Pvoid_t)*pvalue;
		argument_types_tuple = pq_get_tuple_type(ctx, n, types);
		JLG(pvalue, by_type_table, (Word_t)argument_types_tuple);
		if(pvalue != NULL) {
			return (pq_value *)*pvalue;
		}
		JLG(pvalue, by_type_table, (Word_t)NULL);
		if(pvalue != NULL) {
			return (pq_value *)*pvalue;
		}
		JLP(pvalue, by_argnum_table, n);
	}
	return NULL;
}
コード例 #2
0
ファイル: dogma_internal.c プロジェクト: geoff-kruss/libdogma
int dogma_free_env(dogma_context_t* ctx, dogma_env_t* env) {
	int ret;
	dogma_key_t index = -1, index2, index3;
	dogma_env_t** child;
	dogma_array_t* modifiers;
	dogma_array_t* modifiers2;
	dogma_modifier_t** modifier;

	/* Clear our own target */
	if(env->target.context != NULL) {
		assert(dogma_set_target(ctx, env, NULL, NULL) == DOGMA_OK);
	}

	/* Clear any targets of things that have what we're about do
	 * delete as a target */
	if(env->targeted_by != NULL) {
		dogma_key_t index = 0;
		dogma_context_t** targeter;
		dogma_env_t* source;

		JLF(targeter, env->targeted_by, index);
		while(targeter != NULL) {
			source = (dogma_env_t*)index;
			assert(dogma_set_target(*targeter, source, NULL, NULL) == DOGMA_OK);

			JLN(targeter, env->targeted_by, index);
		}

		JLC(ret, env->targeted_by, 0, -1);
		assert(ret == 0);
		JLFA(ret, env->targeted_by);
		assert(ret == 0);
	}

	/* Clear any chance-based effects */
	if(env->chance_effects != NULL) {
		dogma_key_t effectid = 0;
		bool* val;

		JLF(val, env->chance_effects, effectid);
		while(val != NULL) {
			DOGMA_ASSUME_OK(dogma_toggle_chance_based_effect_env(ctx, env, effectid, false));
			JLN(val, env->chance_effects, effectid);
		}

		JLFA(ret, env->chance_effects);
	}

	JLL(child, env->children, index);
	while(child != NULL) {
		dogma_free_env(ctx, *child);
		JLP(child, env->children, index);
	}
	JLFA(ret, env->children);

	index = 0;
	JLF(modifiers, env->modifiers, index);
	while(modifiers != NULL) {
		index2 = 0;
		JLF(modifiers2, *modifiers, index2);
		while(modifiers2 != NULL) {
			index3 = 0;
			JLF(modifier, *modifiers2, index3);
			while(modifier != NULL) {
				free(*modifier);
				JLN(modifier, *modifiers2, index3);
			}

			JLFA(ret, *modifiers2);
			JLN(modifiers2, *modifiers, index2);
		}

		JLFA(ret, *modifiers);
		JLN(modifiers, env->modifiers, index);
	}
	JLFA(ret, env->modifiers);

	free(env);

	return DOGMA_OK;
}