| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef VMBIFTAD_H |
| 19 |
#define VMBIFTAD_H |
| 20 |
|
| 21 |
#include "os.h" |
| 22 |
#include "vmbif.h" |
| 23 |
#include "utf8.h" |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include "vmisaac.h" |
| 31 |
#include "vmmersenne.h" |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class CVmBifTADS: public CVmBif |
| 40 |
{ |
| 41 |
public: |
| 42 |
|
| 43 |
static vm_bif_desc bif_table[]; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
static void datatype(VMG_ uint argc); |
| 49 |
static void getarg(VMG_ uint argc); |
| 50 |
static void firstobj(VMG_ uint argc); |
| 51 |
static void nextobj(VMG_ uint argc); |
| 52 |
static void randomize(VMG_ uint argc); |
| 53 |
static void rand(VMG_ uint argc); |
| 54 |
static void toString(VMG_ uint argc); |
| 55 |
static void toInteger(VMG_ uint argc); |
| 56 |
static void toNumber(VMG_ uint argc); |
| 57 |
static void gettime(VMG_ uint argc); |
| 58 |
static void re_match(VMG_ uint argc); |
| 59 |
static void re_search(VMG_ uint argc); |
| 60 |
static void re_group(VMG_ uint argc); |
| 61 |
static void re_replace(VMG_ uint argc); |
| 62 |
static void savepoint(VMG_ uint argc); |
| 63 |
static void undo(VMG_ uint argc); |
| 64 |
static void save(VMG_ uint argc); |
| 65 |
static void restore(VMG_ uint argc); |
| 66 |
static void restart(VMG_ uint argc); |
| 67 |
static void get_max(VMG_ uint argc); |
| 68 |
static void get_min(VMG_ uint argc); |
| 69 |
static void make_string(VMG_ uint argc); |
| 70 |
static void get_func_params(VMG_ uint argc); |
| 71 |
static void sprintf(VMG_ uint argc); |
| 72 |
static void make_list(VMG_ uint argc); |
| 73 |
static void get_abs(VMG_ uint argc); |
| 74 |
static void get_sgn(VMG_ uint argc); |
| 75 |
static void concat(VMG_ uint argc); |
| 76 |
static void re_search_back(VMG_ uint argc); |
| 77 |
|
| 78 |
|
| 79 |
static void toString(VMG_ vm_val_t *retval, const vm_val_t *srcval, |
| 80 |
int radix, int flags); |
| 81 |
|
| 82 |
|
| 83 |
static vm_obj_id_t format_datetime_list(VMG_ os_time_t timer); |
| 84 |
|
| 85 |
protected: |
| 86 |
|
| 87 |
template<int dir> inline static void re_search_common(VMG_ uint argc); |
| 88 |
|
| 89 |
|
| 90 |
static void enum_objects(VMG_ uint argc, vm_obj_id_t start_obj); |
| 91 |
|
| 92 |
|
| 93 |
static void toIntOrNum(VMG_ uint argc, int int_only); |
| 94 |
}; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
#define VMBT_RNGID_ISAAC 1 |
| 102 |
#define VMBT_RNGID_LCG 2 |
| 103 |
#define VMBT_RNGID_MT19937 3 |
| 104 |
#define VMBT_RNGID_BITSHIFT 4 |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
class CVmBifTADSGlobals |
| 114 |
{ |
| 115 |
public: |
| 116 |
|
| 117 |
CVmBifTADSGlobals(VMG0_); |
| 118 |
|
| 119 |
|
| 120 |
~CVmBifTADSGlobals(); |
| 121 |
|
| 122 |
|
| 123 |
class CRegexParser *rex_parser; |
| 124 |
class CRegexSearcherSimple *rex_searcher; |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
struct vm_globalvar_t *last_rex_str; |
| 132 |
|
| 133 |
|
| 134 |
int rng_id; |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
int32_t lcg_rand_seed; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
#ifdef VMBIFTADS_RNG_BITSHIFT |
| 148 |
|
| 149 |
|
| 150 |
int32_t bits_rand_seed; |
| 151 |
|
| 152 |
#endif |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
struct isaacctx *isaac_ctx; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
class CVmMT19937 *mt_ctx; |
| 166 |
}; |
| 167 |
|
| 168 |
|
| 169 |
#endif |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
#ifdef VMBIF_DEFINE_VECTOR |
| 182 |
|
| 183 |
|
| 184 |
vm_bif_desc CVmBifTADS::bif_table[] = |
| 185 |
{ |
| 186 |
{ &CVmBifTADS::datatype, 1, 0, FALSE }, |
| 187 |
{ &CVmBifTADS::getarg, 1, 0, FALSE }, |
| 188 |
{ &CVmBifTADS::firstobj, 0, 2, FALSE }, |
| 189 |
{ &CVmBifTADS::nextobj, 1, 2, FALSE }, |
| 190 |
{ &CVmBifTADS::randomize, 0, 0, FALSE }, |
| 191 |
{ &CVmBifTADS::rand, 0, 0, TRUE }, |
| 192 |
{ &CVmBifTADS::toString, 1, 2, FALSE }, |
| 193 |
{ &CVmBifTADS::toInteger, 1, 1, FALSE }, |
| 194 |
{ &CVmBifTADS::gettime, 0, 1, FALSE }, |
| 195 |
{ &CVmBifTADS::re_match, 2, 1, FALSE }, |
| 196 |
{ &CVmBifTADS::re_search, 2, 1, FALSE }, |
| 197 |
{ &CVmBifTADS::re_group, 1, 0, FALSE }, |
| 198 |
{ &CVmBifTADS::re_replace, 3, 2, FALSE }, |
| 199 |
{ &CVmBifTADS::savepoint, 0, 0, FALSE }, |
| 200 |
{ &CVmBifTADS::undo, 0, 0, FALSE }, |
| 201 |
{ &CVmBifTADS::save, 1, 0, FALSE }, |
| 202 |
{ &CVmBifTADS::restore, 1, 0, FALSE }, |
| 203 |
{ &CVmBifTADS::restart, 0, 0, FALSE }, |
| 204 |
{ &CVmBifTADS::get_max, 1, 0, TRUE }, |
| 205 |
{ &CVmBifTADS::get_min, 1, 0, TRUE }, |
| 206 |
{ &CVmBifTADS::make_string, 1, 1, FALSE }, |
| 207 |
{ &CVmBifTADS::get_func_params, 1, 0, FALSE }, |
| 208 |
{ &CVmBifTADS::toNumber, 1, 1, FALSE }, |
| 209 |
{ &CVmBifTADS::sprintf, 1, 0, TRUE }, |
| 210 |
{ &CVmBifTADS::make_list, 1, 1, FALSE }, |
| 211 |
{ &CVmBifTADS::get_abs, 1, 0, FALSE }, |
| 212 |
{ &CVmBifTADS::get_sgn, 1, 0, FALSE }, |
| 213 |
{ &CVmBifTADS::concat, 0, 0, TRUE }, |
| 214 |
{ &CVmBifTADS::re_search_back, 2, 1, FALSE } |
| 215 |
}; |
| 216 |
|
| 217 |
#endif |