X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.h;h=62d2a12269959a2ae149c4693c1c24d1d1ba5ce5;hp=248efbbe68ca162f8331b8535572c22ccbc6f8f5;hb=14969a8b4386d7c38e90775e1c57886c9bf3839e;hpb=aa338e1f515a21d83284c83d780d2dc075192c4d diff --git a/src/context.h b/src/context.h index 248efbb..62d2a12 100644 --- a/src/context.h +++ b/src/context.h @@ -26,6 +26,8 @@ #ifndef PSI_CONTEXT_H #define PSI_CONTEXT_H +#include "token.h" + /* zend_function_entry */ #include "Zend/zend_API.h" @@ -33,23 +35,40 @@ struct psi_context; struct psi_token; struct psi_parser; struct psi_call_frame; -struct impl_vararg; struct psi_decl; struct psi_impl; - -enum psi_context_query { - PSI_CONTEXT_QUERY_SELF, /* ffi/jit */ - PSI_CONTEXT_QUERY_TYPE, /* impl type token_t to native ffi_type/jit_type */ -}; +struct psi_decl_arg; +struct psi_decl_extvar; +struct psi_let_exp; struct psi_context_ops { - ZEND_RESULT_CODE (*load)(void); + /* library */ + const char *name; + /* called once */ + bool (*load)(void); void (*free)(void); - void (*init)(struct psi_context *C); + /* called for each new context */ + bool (*init)(struct psi_context *C); void (*dtor)(struct psi_context *C); - zend_function_entry *(*compile)(struct psi_context *C); + /* compiler */ + bool (*composite_init)(struct psi_context *C, struct psi_decl_arg *darg); + void (*composite_dtor)(struct psi_context *C, struct psi_decl_arg *darg); + bool (*extvar_init)(struct psi_context *C, struct psi_decl_extvar *evar); + void (*extvar_dtor)(struct psi_context *C, struct psi_decl_extvar *evar); + bool (*decl_init)(struct psi_context *C, struct psi_decl *decl); + void (*decl_dtor)(struct psi_context *C, struct psi_decl *decl); + bool (*impl_init)(struct psi_context *C, struct psi_impl *impl, zif_handler *zh); + void (*impl_dtor)(struct psi_context *C, struct psi_impl *impl); + bool (*cb_init)(struct psi_context *C, struct psi_let_exp *cb, struct psi_impl *impl); + void (*cb_dtor)(struct psi_context *C, struct psi_let_exp *cb, struct psi_impl *impl); + /* calls */ void (*call)(struct psi_call_frame *frame); - void *(*query)(struct psi_context *C, enum psi_context_query q, void *arg); + void (*call_va)(struct psi_call_frame *frame); + /* types */ + void *(*typeof_impl)(struct psi_context *C, token_t impl_type); + void *(*typeof_decl)(struct psi_context *C, token_t decl_type); + void *(*copyof_type)(struct psi_context *C, void *orig_type); + void (*layoutof_type)(struct psi_context *C, void *orig_type, struct psi_layout *l); }; #include "data.h" @@ -73,7 +92,13 @@ struct psi_context_call_data { struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_ops *ops, psi_error_cb error, unsigned flags); void psi_context_build(struct psi_context *C, const char *path); -zend_function_entry *psi_context_compile(struct psi_context *C); +void psi_context_compile(struct psi_context *C); + +void **psi_context_composite_type_elements(struct psi_context *C, + struct psi_decl_arg *darg, struct psi_plist **eles); +void *psi_context_decl_arg_call_type(struct psi_context *C, struct psi_decl_arg *arg); +void *psi_context_decl_arg_full_type(struct psi_context *C, struct psi_decl_arg *arg); + ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *execute_data, zval *return_value, struct psi_impl *impl); void psi_context_dump(struct psi_dump *dump, struct psi_context *C); void psi_context_dtor(struct psi_context *C);