summaryrefslogtreecommitdiffabout
path: root/src/prog.h
blob: c18ab87c826ca60964ce98537761c7d72aae205d (plain)
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
/* This file is part of mailfromd.
   Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

struct optab {
	char *name;
	instr_t instr;
	void (*dump) (prog_counter_t i);
	unsigned length;
};

typedef void *STKVAL;

struct eval_environ;

#define B2STACK(s) (s + sizeof(STKVAL) - 1) / sizeof(STKVAL)

void runtime_warning(eval_environ_t env, const char *fmt, ...);
void runtime_error(eval_environ_t env, const char *fmt, ...)
	           ATTRIBUTE_NORETURN;
STKVAL get_arg(eval_environ_t env, unsigned n);
char *get_string_arg(eval_environ_t env, unsigned n);
size_t get_numeric_arg(eval_environ_t env, unsigned n);
void push(eval_environ_t env, STKVAL val);
STKVAL pop(eval_environ_t env);
STKVAL *env_data_ref(eval_environ_t env, size_t off);
size_t heap_reserve(eval_environ_t env, size_t size);
size_t heap_reserve_words(eval_environ_t env, size_t size);
STKVAL heap_tempspace(eval_environ_t env, size_t size);
void heap_obstack_begin(eval_environ_t env);
STKVAL heap_obstack_finish(eval_environ_t env);
void *heap_obstack_grow(eval_environ_t env, void *ptr, size_t size);
void pushs(eval_environ_t env, char *s);
void advance_pc(eval_environ_t env, long cnt);
void adjust_stack(eval_environ_t env, unsigned cnt);
void unroll_stack(eval_environ_t env, unsigned cnt);
void prog_trace(eval_environ_t env, const char *fmt, ...);
void runtime_stack_trace(eval_environ_t env);
void env_var_inc(eval_environ_t env, size_t off);
char *env_dict_getsym(eval_environ_t env, char *string);
char *env_dict_install(eval_environ_t env, char *key, char *value);
const struct locus *env_get_locus(eval_environ_t env);
void *env_get_builtin_priv(eval_environ_t env, int id);
int builtin_priv_register(void *(*init)(void), void (*destroy)(void*));

void ensure_initialized_variable(const char *name, struct value *val);

void scan_code(prog_counter_t start, prog_counter_t end,
	       void (*fun)(prog_counter_t pc, struct optab *op, void *d),
	       void *data);

int within_loop(struct literal *lit);
void enter_loop(struct literal *lit,
		prog_counter_t *begptr, prog_counter_t *endptr);
void leave_loop(void);

extern instr_t *prog;
extern unsigned error_count; 
extern unsigned long prog_trace_option;

extern STKVAL *dataseg;
extern size_t datasize;

extern size_t *dataseg_reloc;
extern size_t dataseg_reloc_count;

Return to:

Send suggestions and report system problems to the System administrator.