Skip to content

Commit

Permalink
Restructure the unlang interpreter to get rid of the majority of the …
Browse files Browse the repository at this point in the history
…gotos

Two loops, one handles going back up the stack, the other handles executing instructions, and pushing new frames onto the stack.
  • Loading branch information
arr2036 committed Nov 11, 2017
1 parent 64c14ca commit a7bc554
Show file tree
Hide file tree
Showing 2 changed files with 270 additions and 207 deletions.
8 changes: 7 additions & 1 deletion src/include/interpreter.h
Expand Up @@ -90,6 +90,12 @@ typedef enum {
UNLANG_ACTION_STOP_PROCESSING //!< Break out of processing the current request (unwind).
} unlang_action_t;

typedef enum {
UNLANG_FRAME_ACTION_POP = 1,
UNLANG_FRAME_ACTION_CONTINUE,
UNLANG_FRAME_ACTION_YIELD
} unlang_frame_action_t;

typedef enum {
UNLANG_GROUP_TYPE_SIMPLE = 0, //!< Execute each of the children sequentially, until we execute
//!< all of the children, or one returns #UNLANG_ACTION_BREAK.
Expand Down Expand Up @@ -278,7 +284,7 @@ typedef struct {
unlang_type_t unwind; //!< Unwind to this one if it exists.
///< This is used for break and return.

bool resume : 1; //!< resume the current section after calling a sub-section
bool repeat : 1; //!< resume the current section after calling a sub-section
bool top_frame : 1; //!< are we the top frame of the stack?

union {
Expand Down

0 comments on commit a7bc554

Please sign in to comment.