mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-06 09:42:50 -06:00
now a complete JIT compiler and ByteCode compiler for the def rules in the abstract syntax. there might be some bugs yet to be found, meta variables and computation under lambda is only partially supported
This commit is contained in:
@@ -1,21 +1,37 @@
|
||||
#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 PgfEnv PgfEnv;
|
||||
|
||||
struct PgfEnv {
|
||||
PgfEnv* next;
|
||||
PgfClosure* closure;
|
||||
};
|
||||
|
||||
typedef struct PgfClosure PgfClosure;
|
||||
typedef struct PgfEvalState PgfEvalState;
|
||||
|
||||
typedef PgfClosure* (*PgfFunction)(PgfEvalState* state, PgfClosure* val);
|
||||
|
||||
struct PgfClosure {
|
||||
PgfFunction code;
|
||||
};
|
||||
typedef struct {
|
||||
PgfClosure header;
|
||||
PgfEnv* env;
|
||||
PgfExpr expr;
|
||||
} PgfExprThunk;
|
||||
|
||||
typedef struct {
|
||||
PgfClosure header;
|
||||
@@ -23,16 +39,53 @@ typedef struct {
|
||||
PgfClosure* args[];
|
||||
} PgfValue;
|
||||
|
||||
PgfClosure*
|
||||
pgf_evaluate_indirection(PgfEvalState* state, PgfClosure* closure);
|
||||
typedef struct {
|
||||
PgfClosure header;
|
||||
int level;
|
||||
size_t n_args;
|
||||
PgfClosure* args[];
|
||||
} PgfValueGen;
|
||||
|
||||
typedef struct {
|
||||
PgfClosure header;
|
||||
PgfEnv* env;
|
||||
PgfMetaId id;
|
||||
size_t n_args;
|
||||
PgfClosure* args[];
|
||||
} PgfValueMeta;
|
||||
|
||||
typedef struct {
|
||||
PgfClosure header;
|
||||
PgfLiteral lit;
|
||||
} PgfValueLit;
|
||||
|
||||
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_value(PgfEvalState* state, PgfClosure* closure);
|
||||
|
||||
void
|
||||
pgf_evaluate_save_variables(PgfEvalState* state, PgfValue* val);
|
||||
|
||||
void
|
||||
pgf_evaluate_slide(PgfEvalState* state, size_t a, size_t b);
|
||||
pgf_evaluate_expr_thunk(PgfEvalState* state, PgfClosure* closure);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user