-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.h
executable file
·64 lines (55 loc) · 1.83 KB
/
env.h
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
#ifndef _ENV_H_
#define _ENV_H_
#include "type.h"
/**
* Returns the global environment.
*/
TYPE* get_global_env();
/**
* Given an unbound variable (i.e. symbol) find its value
* in the global environment.
*/
TYPE* lookup_unbound_var(TYPE* var);
int is_env(const TYPE* sexp);
/**
* Looks up var in the environment env.
*
* @requires var is not null and is a symbol.
* @requires env is a list
*
* @ensures lookup_variable_value(var, define_variable(var, val, _)) == val &
* lookup_variable_value(var, empty_env) throws exception
*/
TYPE* lookup_variable_value(TYPE* var, TYPE* env);
/**
* Adds the var, value association to a new frame in the environment env.
*
* @requires vars, vals and env are lists. vars is a list of symbols.
*
* @ensures let env = extend_environment(vars, vals, _)
forall var, val in vars, vals.
* lookup_variable_value(var, env) = val
*/
TYPE* extend_environment(TYPE* vars, TYPE* vals, TYPE* env);
/**
* Adds the binding var, val to the environment var has to be previosly defined
*
* @requires var is a symbol, env is a list
*
* @ensure lookup_variable_value(var,
* set_variable(var, val, define_variable(var, _, env))) == val &
* lookup_variable_value(var,
* set_variable_value(var,
* val,
* empty_env)) throws exception
*/
void set_variable_value(TYPE* var, TYPE* val, TYPE* env);
/**
* Adds the binding var, val to the environment
*
* @requires var is a symbol, env is a list
*
* @ensure lookup_variable_value(var, define_variable(var, val, env)) == val
*/
void define_variable(TYPE* var, TYPE* val, TYPE* env);
#endif