diff options
Diffstat (limited to 'src/runtime/c/pgf/evaluator.h')
| -rw-r--r-- | src/runtime/c/pgf/evaluator.h | 87 |
1 files changed, 70 insertions, 17 deletions
diff --git a/src/runtime/c/pgf/evaluator.h b/src/runtime/c/pgf/evaluator.h index 3962e772f..a6a98cdf1 100644 --- a/src/runtime/c/pgf/evaluator.h +++ b/src/runtime/c/pgf/evaluator.h @@ -1,38 +1,91 @@ #ifndef PGF_EVALUATOR_H_ #define PGF_EVALUATOR_H_ -struct PgfEvalState { +typedef void *PgfFunction; + +typedef struct { + PgfFunction code; +} PgfClosure; + +typedef struct { + PgfClosure header; + PgfClosure* val; +} PgfIndirection; + +typedef struct { PgfPGF* pgf; + PgfEvalGates* eval_gates; // cached from pgf->abstr->eval_gates GuPool* pool; GuExn* err; - GuBuf* stack; -}; + PgfIndirection globals[]; // derived from gu_seq_data(pgf->abstr->eval_gates->defrules) +} PgfEvalState; -typedef struct PgfClosure PgfClosure; -typedef struct PgfEvalState PgfEvalState; +typedef struct PgfEnv PgfEnv; -typedef PgfClosure* (*PgfFunction)(PgfEvalState* state, PgfClosure* val); - -struct PgfClosure { - PgfFunction code; +struct PgfEnv { + PgfEnv* next; + PgfClosure* closure; }; typedef struct { PgfClosure header; + PgfEnv* env; + PgfExpr expr; +} PgfExprThunk; + +typedef struct { + PgfClosure header; PgfAbsFun* absfun; PgfClosure* args[]; } PgfValue; -PgfClosure* -pgf_evaluate_indirection(PgfEvalState* state, PgfClosure* closure); +typedef struct { + PgfClosure header; + int level; + size_t n_args; + PgfClosure* args[]; +} PgfValueGen; -PgfClosure* -pgf_evaluate_value(PgfEvalState* state, PgfClosure* closure); +typedef struct { + PgfClosure header; + PgfEnv* env; + PgfMetaId id; + size_t n_args; + PgfClosure* args[]; +} PgfValueMeta; -void -pgf_evaluate_save_variables(PgfEvalState* state, PgfValue* val); +typedef struct { + PgfClosure header; + PgfLiteral lit; +} PgfValueLit; -void -pgf_evaluate_slide(PgfEvalState* state, size_t a, size_t b); +typedef struct { + PgfClosure header; + PgfClosure* fun; + size_t n_args; + PgfClosure* args[]; +} PgfValuePAP; + +struct PgfEvalGates { + PgfFunction evaluate_expr_thunk; + PgfFunction evaluate_indirection; + PgfFunction evaluate_value; + PgfFunction evaluate_value_gen; + PgfFunction evaluate_value_meta; + PgfFunction evaluate_value_lit; + PgfFunction evaluate_value_pap; + PgfFunction evaluate_value_lambda; + + PgfFunction update_closure; + PgfFunction update_pap; + + PgfClosure* (*enter)(PgfEvalState* state, PgfClosure* closure); + + GuFinalizer fin; + GuSeq* defrules; +}; + +PgfClosure* +pgf_evaluate_expr_thunk(PgfEvalState* state, PgfClosure* closure); #endif |
