File: sieve-generator.h

package info (click to toggle)
dovecot 1:2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (114 lines) | stat: -rw-r--r-- 3,145 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
 */

#ifndef __SIEVE_GENERATOR_H
#define __SIEVE_GENERATOR_H

#include "sieve-common.h"

/*
 * Code generator
 */

struct sieve_generator;

struct sieve_codegen_env {
	struct sieve_generator *gentr;

	struct sieve_instance *svinst;
	enum sieve_compile_flags flags;

	struct sieve_script *script;
	struct sieve_ast *ast;

	struct sieve_binary *sbin;
	struct sieve_binary_block *sblock;
};

struct sieve_generator *sieve_generator_create
	(struct sieve_ast *ast, struct sieve_error_handler *ehandler,\
		enum sieve_compile_flags flags);
void sieve_generator_free(struct sieve_generator **generator);

/*
 * Accessors
 */

struct sieve_error_handler *sieve_generator_error_handler
	(struct sieve_generator *gentr);
pool_t sieve_generator_pool(struct sieve_generator *gentr);
struct sieve_script *sieve_generator_script
	(struct sieve_generator *gentr);
struct sieve_binary *sieve_generator_get_binary
	(struct sieve_generator *gentr);
struct sieve_binary_block *sieve_generator_get_block
	(struct sieve_generator *gentr);

/*
 * Error handling
 */

void sieve_generator_warning
(struct sieve_generator *gentr, unsigned int source_line,
	const char *fmt, ...) ATTR_FORMAT(3, 4);
void sieve_generator_error
(struct sieve_generator *gentr, unsigned int source_line,
	const char *fmt, ...) ATTR_FORMAT(3, 4);
void sieve_generator_critical
(struct sieve_generator *gentr, unsigned int source_line,
	const char *fmt, ...) ATTR_FORMAT(3, 4);

/*
 * Extension support
 */

void sieve_generator_extension_set_context
	(struct sieve_generator *gentr, const struct sieve_extension *ext,
		void *context);
const void *sieve_generator_extension_get_context
	(struct sieve_generator *gentr, const struct sieve_extension *ext);

/*
 * Jump list
 */

struct sieve_jumplist {
	pool_t pool;
	struct sieve_binary_block *block;
	ARRAY(sieve_size_t) jumps;
};

struct sieve_jumplist *sieve_jumplist_create
	(pool_t pool, struct sieve_binary_block *sblock);
void sieve_jumplist_init_temp
	(struct sieve_jumplist *jlist, struct sieve_binary_block *sblock);
void sieve_jumplist_reset
	(struct sieve_jumplist *jlist);
void sieve_jumplist_add
	(struct sieve_jumplist *jlist, sieve_size_t jump);
void sieve_jumplist_resolve(struct sieve_jumplist *jlist);

/*
 * Code generation API
 */

bool sieve_generate_argument
	(const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
		struct sieve_command *cmd);
bool sieve_generate_arguments
	(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd,
		struct sieve_ast_argument **last_arg_r);
bool sieve_generate_argument_parameters
	(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd,
		struct sieve_ast_argument *arg);

bool sieve_generate_block
	(const struct sieve_codegen_env *cgenv, struct sieve_ast_node *block);
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_binary *sieve_generator_run
	(struct sieve_generator *gentr, struct sieve_binary_block **sblock_r);

#endif /* __SIEVE_GENERATOR_H */