bool ext_include_variables_save
(struct sieve_binary_block *sblock,
	struct sieve_variable_scope_binary *global_vars)
{
	struct sieve_variable_scope *global_scope =
		sieve_variable_scope_binary_get(global_vars);
	unsigned int count = sieve_variable_scope_size(global_scope);
	sieve_size_t jump;

	sieve_binary_emit_unsigned(sblock, count);

	jump = sieve_binary_emit_offset(sblock, 0);

	if ( count > 0 ) {
		unsigned int size, i;
		struct sieve_variable *const *vars =
			sieve_variable_scope_get_variables(global_scope, &size);

		for ( i = 0; i < size; i++ ) {
			sieve_binary_emit_cstring(sblock, vars[i]->identifier);
		}
	}

	sieve_binary_resolve_offset(sblock, jump);

	return TRUE;
}
Beispiel #2
0
bool sieve_generate_test
(const struct sieve_codegen_env *cgenv, struct sieve_ast_node *tst_node,
	struct sieve_jumplist *jlist, bool jump_true)
{
	struct sieve_command *test;
	const struct sieve_command_def *tst_def;

	i_assert( tst_node->command != NULL && tst_node->command->def != NULL );

	test = tst_node->command;
	tst_def = test->def;

	if ( tst_def->control_generate != NULL ) {
		sieve_generate_debug_from_ast_node(cgenv, tst_node);

		if ( tst_def->control_generate(cgenv, test, jlist, jump_true) )
			return TRUE;

		return FALSE;
	}

	if ( tst_def->generate != NULL ) {
		sieve_generate_debug_from_ast_node(cgenv, tst_node);

		if ( tst_def->generate(cgenv, test) ) {

			if ( jump_true )
				sieve_operation_emit(cgenv->sblock, NULL, &sieve_jmptrue_operation);
			else
				sieve_operation_emit(cgenv->sblock, NULL, &sieve_jmpfalse_operation);
			sieve_jumplist_add(jlist, sieve_binary_emit_offset(cgenv->sblock, 0));

			return TRUE;
		}

		return FALSE;
	}

	return TRUE;
}
 * Binary symbol table
 */

bool ext_include_variables_save
(struct sieve_binary_block *sblock,
	struct sieve_variable_scope_binary *global_vars,
	enum sieve_error *error_r ATTR_UNUSED)
{
	struct sieve_variable_scope *global_scope =
		sieve_variable_scope_binary_get(global_vars);
	unsigned int count = sieve_variable_scope_size(global_scope);
	sieve_size_t jump;

	sieve_binary_emit_unsigned(sblock, count);

	jump = sieve_binary_emit_offset(sblock, 0);

	if ( count > 0 ) {
		unsigned int size, i;
		struct sieve_variable *const *vars =
			sieve_variable_scope_get_variables(global_scope, &size);

		for ( i = 0; i < size; i++ ) {
			sieve_binary_emit_cstring(sblock, vars[i]->identifier);
		}
	}

	sieve_binary_resolve_offset(sblock, jump);

	return TRUE;
}