generators/iterators, raise/try/except, and slot-based object layout
- VM refactor: resumable CAT_VM_Frame (ip/sp/locals/handlers) - yield/next/generators: calling a yield-function returns a generator - for..in over any iterator, ends on explicit exhaustion status - raise/try/except: structured error values, nearest-handler unwinding - slots: C-declared member layout (offsetof), PyTypeObject/tp_members style - File now exposes path/mode/closed via slots - examples: generators.cat, errors.cat, slots.cat; 40/40 tests
This commit is contained in:
1 parent
52d118211f
commit
3c20496c78
19 files changed
+978
-99
No files matched your search
@@ -12,12 +12,17 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct CAT_VALUE_Value;
|
||||
|
||||
/* CAT_ERROR_Error -- an error slot passed into API calls. */
|
||||
/* `raised` becomes true when an operation fails; `message` is a */
|
||||
/* human-readable description (always NUL terminated when raised). */
|
||||
/* `value` optionally carries a catscript value (what `raise` was */
|
||||
/* given, or the message as text), which `try/except` binds. */
|
||||
typedef struct CAT_ERROR_Error {
|
||||
bool raised;
|
||||
char message[256];
|
||||
struct CAT_VALUE_Value *value;
|
||||
} CAT_ERROR_Error;
|
||||
|
||||
/* Clear an error slot back to the "no error" state. */
|
||||
@@ -26,4 +31,8 @@ void cat_error_clear(CAT_ERROR_Error *err);
|
||||
/* Raise (fill) an error slot with a printf-style message. */
|
||||
void cat_error_raise(CAT_ERROR_Error *err, const char *fmt, ...);
|
||||
|
||||
/* Raise with a carried catscript value (what `raise v` was given). */
|
||||
void cat_error_raise_value(CAT_ERROR_Error *err, struct CAT_VALUE_Value *v,
|
||||
const char *fmt, ...);
|
||||
|
||||
#endif /* CAT_ERROR_H */
|
||||
Reference in new issue
Block a user