1 | #ifndef MAD_VAR_H |
---|
2 | #define MAD_VAR_H |
---|
3 | |
---|
4 | // types |
---|
5 | |
---|
6 | struct in_cmd; |
---|
7 | struct name_list; |
---|
8 | struct command_list; |
---|
9 | struct expression; |
---|
10 | |
---|
11 | struct constant |
---|
12 | { |
---|
13 | char name[NAME_L]; |
---|
14 | struct expression* exp; /* pointer to defining expression (always) */ |
---|
15 | double value; |
---|
16 | int stamp; |
---|
17 | }; |
---|
18 | |
---|
19 | struct variable |
---|
20 | { |
---|
21 | char name[NAME_L]; |
---|
22 | int status; /* 0 value not evaluated, 1 evaluated */ |
---|
23 | int type; /* 0 constant, 1 direct, 2 deferred, 3 string */ |
---|
24 | int val_type; /* 0 int 1 double (0..2) */ |
---|
25 | char* string; /* pointer to string if 3 */ |
---|
26 | struct expression* expr; /* pointer to defining expression (0..2) */ |
---|
27 | double value; /* (0..2) */ |
---|
28 | int stamp; |
---|
29 | }; |
---|
30 | |
---|
31 | struct var_list /* contains list of variable pointers sorted by name */ |
---|
32 | { |
---|
33 | int stamp; |
---|
34 | char name[NAME_L]; |
---|
35 | int max, /* max. pointer array size */ |
---|
36 | curr; /* current occupation */ |
---|
37 | struct name_list* list; /* index list of names */ |
---|
38 | struct variable** vars; /* variable pointer list */ |
---|
39 | }; |
---|
40 | |
---|
41 | // interface |
---|
42 | |
---|
43 | void enter_variable(struct in_cmd*); /* stores variable contained in cmd */ |
---|
44 | struct variable* new_variable(char* name, double val, int val_type, int type, struct expression*, char* string); |
---|
45 | double variable_value(struct variable*); |
---|
46 | |
---|
47 | struct var_list* new_var_list(int length); |
---|
48 | struct var_list* clone_var_list(struct var_list*); |
---|
49 | struct var_list* delete_var_list(struct var_list*); |
---|
50 | void add_to_var_list(struct variable*, struct var_list*, int flag); |
---|
51 | struct variable* find_variable(char* name, struct var_list*); |
---|
52 | |
---|
53 | char* make_string_variable(char* string); |
---|
54 | void print_global(double delta); |
---|
55 | void write_vars(struct var_list*, struct command_list*, FILE*); |
---|
56 | void write_vars_8(struct var_list*, struct command_list*, FILE*); |
---|
57 | void set_variable(char* name, double* value); |
---|
58 | void set_stringvar(char* name, char* string); |
---|
59 | double get_variable(char* name); |
---|
60 | char* get_varstring(char* name); |
---|
61 | void get_defined_constants(void); |
---|
62 | |
---|
63 | #endif // MAD_VAR_H |
---|
64 | |
---|