00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef PLINT_DATA_TYPE_H
00026 #error Dont include me directly, but through data/type.h
00027 #endif
00028
00047 struct _plint_type_iface
00048 {
00049
00050 void (* neu)(plint_var_t VARIABLE);
00051 void (* cpy)(plint_ref_t DESTINATION, plint_var_t SOURCE);
00052 void (* fre)(plint_var_const_t CONST_VARIABLE);
00054 void (* idx)(plint_mem_t * PMEMORY, plint_ref_t * PREFERENCE, int INDEX);
00056 void (* fld)(plint_mem_t * PMEMORY, plint_ref_t * PREFERENCE, plint_str_t FIELD);
00059 void (* key)(plint_mem_t * PMEMORY, plint_ref_t * REFERENCE, plint_val_t * PVALUE, plint_typ_t TYPE);
00063 void (* get)(plint_idx_t * PINDEX);
00065 };
00066
00067
00073 struct _plint_var
00074 {
00075 plint_ptr_t ptr;
00077 plint_ref_t cpy;
00079 flag_t singleton:1;
00080 flag_t readonly :1;
00081 flag_t unity :1;
00083 plint_typkey_t key;
00084 void * data;
00086 struct _plint_gc_chunk _gc;
00087
00088 #define PLINT_VAR_NEW(__key__, __args__...) plint_var_new(__key__, PLINT_PTR_NEW(__args__))
00089
00090 };
00091
00092 __BEGIN_DECLS
00093
00094 plint_var_t plint_var_new(plint_typkey_t KEY, plint_ptr_t VALUE);
00095 void plint_var_fre(plint_var_t VARIABLE);
00096 plint_var_t plint_var_cpy(plint_var_t VARIABLE);
00097 inline plint_var_t plint_var_dup(plint_var_t VARIABLE);
00098 void plint_var_inc(plint_ref_t REFERENCE);
00099 void plint_var_dec(plint_ref_t REFERENCE);
00100
00101 #ifndef PLINT_SELF_REF
00102 inline
00103 #endif
00104 void plint_var_asg(plint_mem_t MEMORY, plint_ref_t DESTINATION, plint_var_t SOURCE, plint_easg_t TYPE);
00105
00106 __END_DECLS
00107
00108 #define plint_var_singleton(__v__) (__v__)->singleton
00109 #define plint_var_readonly(__v__) (__v__)->readonly
00110 #define plint_var_unity(__v__) (__v__)->unity
00111 #define plint_var_data(__v__) (__v__)->data
00112
00113 #define plint_var_val(__v__) ((__v__)->ptr)
00114
00115 #define plint_var_typ(__v__) (plint_var_val(__v__)->typ)
00116 #define plint_var_num_int(__v__) (plint_var_val(__v__)->val.num_int)
00117 #define plint_var_num_dbl(__v__) (plint_var_val(__v__)->val.num_dbl)
00118 #define plint_var_num(__v__) plint_val_num(&plint_var_val(__v__)->val, plint_var_typ(__v__))
00119 #define plint_var_pnt(__v__) (plint_var_val(__v__)->val.pnt)
00120 #define plint_var_str(__v__) (plint_var_val(__v__)->val.str)
00121 #define plint_var_bol(__v__) (plint_var_val(__v__)->val.bol)
00122 #define plint_var_tab(__v__) (plint_var_val(__v__)->val.tab)
00123 #define plint_var_hsh(__v__) (plint_var_val(__v__)->val.hsh)
00124