Debian Codegraph @

terps/bocfel/stack.h

raw symbols SCIP
1 // vim: set ft=cpp:
2
3 #ifndef ZTERP_STACK_H
4 #define ZTERP_STACK_H
5
6 #include <stdexcept>
7 #include <vector>
8
9 #include "types.h"
10
11 static constexpr unsigned long DEFAULT_STACK_SIZE = 0x4000;
12 static constexpr unsigned long DEFAULT_CALL_DEPTH = 0x400;
13
14 class RestoreError : public std::runtime_error {
15 public:
16 using std::runtime_error::runtime_error;
17 };
18
19 extern bool seen_save_undo;
20
21 void init_stack(bool first_run);
22
23 uint16_t variable(uint16_t var);
24 void store_variable(uint16_t var, uint16_t n);
25
26 void start_v6();
27 uint16_t internal_call(uint16_t routine, std::vector<uint16_t> args = {});
28 void do_return(uint16_t retval);
29
30 enum class SaveType {
31 Normal,
32 Meta,
33 Autosave,
34 AutosaveLib,
35 };
36
37 enum class SaveOpcode {
38 None = -1,
39 Read = 0,
40 ReadChar = 1,
41 // Yes, we can autosave in the middle of a @save or @restore! It’s the
42 // fileref prompt that does it, not the save operation.
43 Save = 2,
44 Restore = 3,
45 };
46
47 bool do_save(SaveType savetype, SaveOpcode saveopcode);
48 bool do_restore(SaveType savetype, SaveOpcode &saveopcode);
49
50 enum class SaveStackType {
51 Game,
52 User
53 };
54
55 enum class SaveResult {
56 Success,
57 Failure,
58 Unavailable,
59 };
60
61 SaveResult push_save(SaveStackType type, SaveType savetype, SaveOpcode saveopcode, const char *desc);
62 bool pop_save(SaveStackType type, size_t saveno, SaveOpcode &saveopcode);
63 bool drop_save(SaveStackType type, size_t i);
64 void list_saves(SaveStackType type);
65
66 void zpush();
67 void zpull();
68 void zload();
69 void zstore();
70 void zret_popped();
71 void zpop();
72 void zcatch();
73 void zthrow();
74 void zret();
75 void zrtrue();
76 void zrfalse();
77 void zcheck_arg_count();
78 void zpop_stack();
79 void zpush_stack();
80 void zsave_undo();
81 void zrestore_undo();
82 void zsave();
83 void zrestore();
84
85 void zcall_store();
86 void zcall_nostore();
87
88 #define zcall zcall_store
89 #define zcall_1n zcall_nostore
90 #define zcall_1s zcall_store
91 #define zcall_2n zcall_nostore
92 #define zcall_2s zcall_store
93 #define zcall_vn zcall_nostore
94 #define zcall_vn2 zcall_nostore
95 #define zcall_vs2 zcall_store
96
97 #endif