| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef VMLST_H |
| 21 |
#define VMLST_H |
| 22 |
|
| 23 |
#include <stdlib.h> |
| 24 |
#include "vmtype.h" |
| 25 |
#include "vmobj.h" |
| 26 |
#include "vmcoll.h" |
| 27 |
#include "vmglob.h" |
| 28 |
#include "vmstack.h" |
| 29 |
#include "vmrun.h" |
| 30 |
|
| 31 |
|
| 32 |
class CVmObjList: public CVmObjCollection |
| 33 |
{ |
| 34 |
friend class CVmMetaclassList; |
| 35 |
|
| 36 |
public: |
| 37 |
|
| 38 |
static class CVmMetaclass *metaclass_reg_; |
| 39 |
class CVmMetaclass *get_metaclass_reg() const { return metaclass_reg_; } |
| 40 |
|
| 41 |
|
| 42 |
virtual int is_of_metaclass(class CVmMetaclass *meta) const |
| 43 |
{ |
| 44 |
|
| 45 |
return (meta == metaclass_reg_ |
| 46 |
|| CVmObjCollection::is_of_metaclass(meta)); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
static vm_obj_id_t create_from_stack(VMG_ const uchar **pc_ptr, |
| 51 |
uint argc); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
static vm_obj_id_t create_from_params(VMG_ uint idx, uint cnt); |
| 60 |
|
| 61 |
|
| 62 |
static int call_stat_prop(VMG_ vm_val_t *result, |
| 63 |
const uchar **pc_ptr, uint *argc, |
| 64 |
vm_prop_id_t prop); |
| 65 |
|
| 66 |
|
| 67 |
virtual void reserve_const_data(VMG_ class CVmConstMapper *mapper, |
| 68 |
vm_obj_id_t self); |
| 69 |
|
| 70 |
|
| 71 |
virtual void convert_to_const_data(VMG_ class CVmConstMapper *mapper, |
| 72 |
vm_obj_id_t self); |
| 73 |
|
| 74 |
|
| 75 |
virtual vm_datatype_t get_convert_to_const_data_type() const |
| 76 |
{ return VM_LIST; } |
| 77 |
|
| 78 |
|
| 79 |
static vm_obj_id_t create(VMG_ int in_root_set); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
static vm_obj_id_t create(VMG_ int in_root_set, size_t element_count); |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
static vm_obj_id_t create(VMG_ int in_root_set, const char *lst); |
| 92 |
|
| 93 |
|
| 94 |
void get_element(size_t idx, vm_val_t *val) const |
| 95 |
{ |
| 96 |
|
| 97 |
vmb_get_dh(get_element_ptr(idx), val); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
void cons_set_element(size_t idx, const vm_val_t *val); |
| 113 |
|
| 114 |
|
| 115 |
void cons_uniquify(VMG0_); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
void cons_copy_elements(size_t start_idx, const char *orig_list); |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
void cons_copy_data(size_t start_idx, const char *ele_array, |
| 133 |
size_t ele_count); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
void cons_set_len(size_t len) |
| 144 |
{ vmb_put_len(ext_, len); } |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
void cons_ensure_space(VMG_ size_t idx, size_t margin); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
void cons_clear(size_t start_idx, size_t end_idx); |
| 166 |
|
| 167 |
|
| 168 |
void cons_clear() |
| 169 |
{ |
| 170 |
if (get_ele_count() != 0) |
| 171 |
cons_clear(0, get_ele_count() - 1); |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
void notify_delete(VMG_ int in_root_set); |
| 176 |
|
| 177 |
|
| 178 |
void set_prop(VMG_ class CVmUndo *undo, |
| 179 |
vm_obj_id_t self, vm_prop_id_t prop, const vm_val_t *val); |
| 180 |
|
| 181 |
|
| 182 |
int get_prop(VMG_ vm_prop_id_t prop, vm_val_t *val, |
| 183 |
vm_obj_id_t self, vm_obj_id_t *source_obj, uint *argc); |
| 184 |
|
| 185 |
|
| 186 |
void notify_new_savept() { } |
| 187 |
void apply_undo(VMG_ struct CVmUndoRecord *) { } |
| 188 |
void mark_undo_ref(VMG_ struct CVmUndoRecord *) { } |
| 189 |
void remove_stale_undo_weak_ref(VMG_ struct CVmUndoRecord *) { } |
| 190 |
|
| 191 |
|
| 192 |
void mark_refs(VMG_ uint state); |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
void remove_stale_weak_refs(VMG0_) { } |
| 199 |
|
| 200 |
|
| 201 |
void load_from_image(VMG_ vm_obj_id_t, const char *ptr, size_t) |
| 202 |
{ ext_ = (char *)ptr; } |
| 203 |
|
| 204 |
|
| 205 |
virtual ulong rebuild_image(VMG_ char *buf, ulong buflen); |
| 206 |
|
| 207 |
|
| 208 |
void save_to_file(VMG_ class CVmFile *fp); |
| 209 |
|
| 210 |
|
| 211 |
void restore_from_file(VMG_ vm_obj_id_t self, |
| 212 |
class CVmFile *fp, class CVmObjFixup *fixups); |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
const char *cast_to_string(VMG_ vm_obj_id_t self, |
| 220 |
vm_val_t *new_str) const |
| 221 |
{ |
| 222 |
|
| 223 |
vm_val_t self_val; |
| 224 |
self_val.set_obj(self); |
| 225 |
|
| 226 |
|
| 227 |
join(vmg_ new_str, &self_val, ",", 1); |
| 228 |
|
| 229 |
|
| 230 |
return new_str->get_as_string(vmg0_); |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
virtual const char *explicit_to_string( |
| 235 |
VMG_ vm_obj_id_t self, vm_val_t *new_str, int radix, int flags) const |
| 236 |
{ |
| 237 |
|
| 238 |
vm_val_t self_val; |
| 239 |
self_val.set_obj(self); |
| 240 |
|
| 241 |
|
| 242 |
return list_to_string(vmg_ new_str, &self_val, radix, flags); |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
static const char *list_to_string( |
| 250 |
VMG_ vm_val_t *result, const vm_val_t *self, int radix, int flags); |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
int add_val(VMG_ vm_val_t *result, |
| 261 |
vm_obj_id_t self, const vm_val_t *val); |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
int index_val_q(VMG_ vm_val_t *result, vm_obj_id_t self, |
| 267 |
const vm_val_t *index_val); |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
int set_index_val_q(VMG_ vm_val_t *new_container, vm_obj_id_t self, |
| 275 |
const vm_val_t *index_val, const vm_val_t *new_val); |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
int sub_val(VMG_ vm_val_t *result, |
| 284 |
vm_obj_id_t self, const vm_val_t *val); |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
const char *get_as_list() const { return ext_; } |
| 291 |
|
| 292 |
|
| 293 |
int is_listlike(VMG_ vm_obj_id_t ) { return TRUE; } |
| 294 |
int ll_length(VMG_ vm_obj_id_t ) { return get_ele_count(); } |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
int equals(VMG_ vm_obj_id_t self, const vm_val_t *val, int depth) const; |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
static void add_to_list(VMG_ vm_val_t *result, |
| 316 |
vm_obj_id_t self, const char *lstval, |
| 317 |
const vm_val_t *val); |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
static void sub_from_list(VMG_ vm_val_t *result, |
| 332 |
const vm_val_t *lstval, const char *lstmem, |
| 333 |
const vm_val_t *val); |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
static int const_equals(VMG_ const vm_val_t *lstval, const char *lstmem, |
| 348 |
const vm_val_t *val, int depth); |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
uint calc_hash(VMG_ vm_obj_id_t self, int depth) const; |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
static uint const_calc_hash(VMG_ const vm_val_t *self_val, |
| 359 |
const char *lst, int depth); |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
static void index_list(VMG_ vm_val_t *result, |
| 369 |
const char *lst, const vm_val_t *index_val); |
| 370 |
|
| 371 |
|
| 372 |
static void index_list(VMG_ vm_val_t *result, const char *lst, uint idx); |
| 373 |
|
| 374 |
|
| 375 |
static void index_and_push(VMG_ const char *lst, uint idx) |
| 376 |
{ |
| 377 |
vm_val_t *p; |
| 378 |
|
| 379 |
|
| 380 |
p = G_stk->push(); |
| 381 |
|
| 382 |
|
| 383 |
index_list(vmg_ p, lst, idx); |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
static void set_index_list(VMG_ vm_val_t *result, |
| 392 |
const char *lst, const vm_val_t *index_val, |
| 393 |
const vm_val_t *new_val); |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
static int find_in_list(VMG_ const vm_val_t *lst, |
| 402 |
const vm_val_t *val, size_t *idxp); |
| 403 |
|
| 404 |
|
| 405 |
static int find_last_in_list(VMG_ const vm_val_t *lst, |
| 406 |
const vm_val_t *val, size_t *idxp); |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
static int const_get_prop(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 414 |
const char *lst, vm_prop_id_t prop, |
| 415 |
vm_obj_id_t *srcobj, uint *argc); |
| 416 |
|
| 417 |
|
| 418 |
static int getp_undef(VMG_ vm_val_t *, const vm_val_t *, |
| 419 |
const char *, uint *) |
| 420 |
{ return FALSE; } |
| 421 |
|
| 422 |
|
| 423 |
static int getp_subset(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 424 |
const char *lst, uint *argc); |
| 425 |
|
| 426 |
|
| 427 |
static int getp_map(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 428 |
const char *lst, uint *argc); |
| 429 |
|
| 430 |
|
| 431 |
static int getp_len(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 432 |
const char *lst, uint *argc); |
| 433 |
|
| 434 |
|
| 435 |
static int getp_sublist(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 436 |
const char *lst, uint *argc); |
| 437 |
|
| 438 |
|
| 439 |
static int getp_intersect(VMG_ vm_val_t *retval, |
| 440 |
const vm_val_t *self_val, |
| 441 |
const char *lst, uint *argc); |
| 442 |
|
| 443 |
|
| 444 |
static int getp_index_of(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 445 |
const char *lst, uint *argc); |
| 446 |
|
| 447 |
|
| 448 |
static int getp_car(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 449 |
const char *lst, uint *argc); |
| 450 |
|
| 451 |
|
| 452 |
static int getp_cdr(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 453 |
const char *lst, uint *argc); |
| 454 |
|
| 455 |
|
| 456 |
static int getp_index_which(VMG_ vm_val_t *retval, |
| 457 |
const vm_val_t *self_val, |
| 458 |
const char *lst, uint *argc); |
| 459 |
|
| 460 |
|
| 461 |
static int getp_for_each(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 462 |
const char *lst, uint *argc); |
| 463 |
|
| 464 |
|
| 465 |
static int getp_for_each_assoc(VMG_ vm_val_t *retval, |
| 466 |
const vm_val_t *self_val, |
| 467 |
const char *lst, uint *argc); |
| 468 |
|
| 469 |
|
| 470 |
static int getp_val_which(VMG_ vm_val_t *retval, |
| 471 |
const vm_val_t *self_val, |
| 472 |
const char *lst, uint *argc); |
| 473 |
|
| 474 |
|
| 475 |
static int getp_last_index_of(VMG_ vm_val_t *retval, |
| 476 |
const vm_val_t *self_val, |
| 477 |
const char *lst, uint *argc); |
| 478 |
|
| 479 |
|
| 480 |
static int getp_last_index_which(VMG_ vm_val_t *retval, |
| 481 |
const vm_val_t *self_val, |
| 482 |
const char *lst, uint *argc); |
| 483 |
|
| 484 |
|
| 485 |
static int getp_last_val_which(VMG_ vm_val_t *retval, |
| 486 |
const vm_val_t *self_val, |
| 487 |
const char *lst, uint *argc); |
| 488 |
|
| 489 |
|
| 490 |
static int getp_count_of(VMG_ vm_val_t *retval, |
| 491 |
const vm_val_t *self_val, |
| 492 |
const char *lst, uint *argc); |
| 493 |
|
| 494 |
|
| 495 |
static int getp_count_which(VMG_ vm_val_t *retval, |
| 496 |
const vm_val_t *self_val, |
| 497 |
const char *lst, uint *argc); |
| 498 |
|
| 499 |
|
| 500 |
static int gen_index_which(VMG_ vm_val_t *retval, |
| 501 |
const vm_val_t *self_val, |
| 502 |
const char *lst, uint *argc, |
| 503 |
int forward, vm_rcdesc *rc); |
| 504 |
|
| 505 |
|
| 506 |
static int getp_get_unique(VMG_ vm_val_t *retval, |
| 507 |
const vm_val_t *self_val, |
| 508 |
const char *lst, uint *argc); |
| 509 |
|
| 510 |
|
| 511 |
static int getp_append_unique(VMG_ vm_val_t *retval, |
| 512 |
const vm_val_t *self_val, |
| 513 |
const char *lst, uint *argc); |
| 514 |
|
| 515 |
|
| 516 |
static void append_unique(VMG_ vm_val_t *retval, |
| 517 |
const vm_val_t *self, const vm_val_t *other); |
| 518 |
|
| 519 |
|
| 520 |
static int getp_append(VMG_ vm_val_t *retval, |
| 521 |
const vm_val_t *self_val, |
| 522 |
const char *lst, uint *argc); |
| 523 |
|
| 524 |
|
| 525 |
static int getp_sort(VMG_ vm_val_t *retval, |
| 526 |
const vm_val_t *self_val, |
| 527 |
const char *lst, uint *argc); |
| 528 |
|
| 529 |
|
| 530 |
static int getp_insert_at(VMG_ vm_val_t *retval, |
| 531 |
const vm_val_t *self_val, |
| 532 |
const char *lst, uint *argc); |
| 533 |
|
| 534 |
|
| 535 |
static int getp_prepend(VMG_ vm_val_t *retval, |
| 536 |
const vm_val_t *self_val, |
| 537 |
const char *lst, uint *argc); |
| 538 |
|
| 539 |
|
| 540 |
static int getp_remove_element_at(VMG_ vm_val_t *retval, |
| 541 |
const vm_val_t *self_val, |
| 542 |
const char *lst, uint *argc); |
| 543 |
|
| 544 |
|
| 545 |
static int getp_remove_range(VMG_ vm_val_t *retval, |
| 546 |
const vm_val_t *self_val, |
| 547 |
const char *lst, uint *argc); |
| 548 |
|
| 549 |
|
| 550 |
static int getp_splice(VMG_ vm_val_t *retval, |
| 551 |
const vm_val_t *self_val, |
| 552 |
const char *lst, uint *argc); |
| 553 |
|
| 554 |
|
| 555 |
static int getp_join(VMG_ vm_val_t *retval, |
| 556 |
const vm_val_t *self_val, |
| 557 |
const char *lst, uint *argc); |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
static void join(VMG_ vm_val_t *retval, |
| 565 |
const vm_val_t *self_val, |
| 566 |
const char *sep, size_t sep_len); |
| 567 |
|
| 568 |
|
| 569 |
static int getp_generate(VMG_ vm_val_t *retval, |
| 570 |
const vm_val_t * , |
| 571 |
const char * , uint *argc) |
| 572 |
{ return static_getp_generate(vmg_ retval, argc); } |
| 573 |
|
| 574 |
|
| 575 |
static int static_getp_generate(VMG_ vm_val_t *retval, uint *argc); |
| 576 |
|
| 577 |
|
| 578 |
static int getp_indexOfMin(VMG_ vm_val_t *retval, |
| 579 |
const vm_val_t *self_val, |
| 580 |
const char *lst, uint *argc); |
| 581 |
|
| 582 |
|
| 583 |
static int getp_minVal(VMG_ vm_val_t *retval, |
| 584 |
const vm_val_t *self_val, |
| 585 |
const char *lst, uint *argc); |
| 586 |
|
| 587 |
|
| 588 |
static int getp_indexOfMax(VMG_ vm_val_t *retval, |
| 589 |
const vm_val_t *self_val, |
| 590 |
const char *lst, uint *argc); |
| 591 |
|
| 592 |
|
| 593 |
static int getp_maxVal(VMG_ vm_val_t *retval, |
| 594 |
const vm_val_t *self_val, |
| 595 |
const char *lst, uint *argc); |
| 596 |
|
| 597 |
|
| 598 |
protected: |
| 599 |
|
| 600 |
static int for_each_gen(VMG_ vm_val_t *retval, |
| 601 |
const vm_val_t *self_val, |
| 602 |
const char *lst, uint *argc, |
| 603 |
int send_idx_to_cb, vm_rcdesc *rc); |
| 604 |
|
| 605 |
|
| 606 |
static int get_minmax(VMG_ vm_val_t *retval, |
| 607 |
const vm_val_t *self_val, |
| 608 |
const char *lst, uint *in_argc, |
| 609 |
const vm_rcdesc *rc, |
| 610 |
int sense, int want_index); |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
static vm_obj_id_t intersect(VMG_ const vm_val_t *l1, |
| 617 |
const vm_val_t *l2); |
| 618 |
|
| 619 |
|
| 620 |
static void insert_elements(VMG_ vm_val_t *retval, |
| 621 |
const vm_val_t *self_val, |
| 622 |
const char *lst, uint argc, int idx); |
| 623 |
|
| 624 |
|
| 625 |
static void remove_range(VMG_ vm_val_t *retval, |
| 626 |
const vm_val_t *self_val, |
| 627 |
const char *lst, int start_idx, int del_cnt); |
| 628 |
|
| 629 |
|
| 630 |
virtual void new_iterator(VMG_ vm_val_t *retval, |
| 631 |
const vm_val_t *self_val); |
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
virtual void new_live_iterator(VMG_ vm_val_t *retval, |
| 638 |
const vm_val_t *self_val) |
| 639 |
{ new_iterator(vmg_ retval, self_val); } |
| 640 |
|
| 641 |
|
| 642 |
size_t get_ele_count() const { return vmb_get_len(ext_); } |
| 643 |
|
| 644 |
|
| 645 |
static size_t get_ele_count_const(const char *lstval) |
| 646 |
{ return vmb_get_len(lstval); } |
| 647 |
|
| 648 |
|
| 649 |
static void get_element_const(const char *lstval, size_t idx, |
| 650 |
vm_val_t *val) |
| 651 |
{ |
| 652 |
|
| 653 |
vmb_get_dh(get_element_ptr_const(lstval, idx), val); |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
char *get_element_ptr(size_t idx) const |
| 658 |
{ |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
return ext_ + VMB_LEN + (idx * VMB_DATAHOLDER); |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
static const char *get_element_ptr_const(const char *lstval, size_t idx) |
| 671 |
{ |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
return lstval + VMB_LEN + (idx * VMB_DATAHOLDER); |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
static void inc_element_ptr(char **p) |
| 684 |
{ |
| 685 |
|
| 686 |
*p += VMB_DATAHOLDER; |
| 687 |
} |
| 688 |
|
| 689 |
|
| 690 |
static void inc_const_element_ptr(const char **p) |
| 691 |
{ |
| 692 |
|
| 693 |
*p += VMB_DATAHOLDER; |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
CVmObjList() { ext_ = 0; } |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
CVmObjList(VMG_ size_t element_count); |
| 704 |
|
| 705 |
|
| 706 |
CVmObjList(VMG_ const char *lst); |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
static size_t calc_alloc(size_t elecnt) |
| 714 |
{ return (VMB_LEN + (elecnt * VMB_DATAHOLDER)); } |
| 715 |
|
| 716 |
|
| 717 |
void alloc_list(VMG_ size_t element_count); |
| 718 |
|
| 719 |
|
| 720 |
static int (*func_table_[])(VMG_ vm_val_t *retval, |
| 721 |
const vm_val_t *self_val, |
| 722 |
const char *lst, uint *argc); |
| 723 |
}; |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
class CVmObjListConst: public CVmObjList |
| 736 |
{ |
| 737 |
public: |
| 738 |
|
| 739 |
void notify_delete(VMG_ int ) |
| 740 |
{ |
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
} |
| 746 |
|
| 747 |
|
| 748 |
static vm_obj_id_t create(VMG_ const char *const_ptr); |
| 749 |
|
| 750 |
protected: |
| 751 |
|
| 752 |
CVmObjListConst(VMG_ const char *const_ptr) |
| 753 |
{ |
| 754 |
|
| 755 |
ext_ = (char *)const_ptr; |
| 756 |
} |
| 757 |
}; |
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
class CVmMetaclassList: public CVmMetaclass |
| 764 |
{ |
| 765 |
public: |
| 766 |
|
| 767 |
const char *get_meta_name() const { return "list/030008"; } |
| 768 |
|
| 769 |
|
| 770 |
void create_for_image_load(VMG_ vm_obj_id_t id) |
| 771 |
{ |
| 772 |
new (vmg_ id) CVmObjList(); |
| 773 |
G_obj_table->set_obj_gc_characteristics(id, TRUE, FALSE); |
| 774 |
} |
| 775 |
|
| 776 |
|
| 777 |
void create_for_restore(VMG_ vm_obj_id_t id) |
| 778 |
{ |
| 779 |
new (vmg_ id) CVmObjList(); |
| 780 |
G_obj_table->set_obj_gc_characteristics(id, TRUE, FALSE); |
| 781 |
} |
| 782 |
|
| 783 |
|
| 784 |
vm_obj_id_t create_from_stack(VMG_ const uchar **pc_ptr, uint argc) |
| 785 |
{ return CVmObjList::create_from_stack(vmg_ pc_ptr, argc); } |
| 786 |
|
| 787 |
|
| 788 |
int call_stat_prop(VMG_ vm_val_t *result, |
| 789 |
const uchar **pc_ptr, uint *argc, |
| 790 |
vm_prop_id_t prop) |
| 791 |
{ |
| 792 |
return CVmObjList::call_stat_prop(vmg_ result, pc_ptr, argc, prop); |
| 793 |
} |
| 794 |
|
| 795 |
|
| 796 |
CVmMetaclass *get_supermeta_reg() const |
| 797 |
{ return CVmObjCollection::metaclass_reg_; } |
| 798 |
}; |
| 799 |
|
| 800 |
#endif |
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
VM_REGISTER_METACLASS(CVmObjList) |
| 806 |
|