/* void test_pipes1() { enum {frame_START, frame_SIZE, A, B, C, frame_END}; ENTER_FRAME_ENUM(frame); A = gc_alloc_int(1); // 1 assert(vm->heap_num==1); PUSH_VM(vm1); assert(vm->heap_num==0); frame[B] = test_new_vm2(A); assert(vm->heap_num==4); frame[B] = test_new_vm2(frame[B]); assert(vm->heap_num==8); frame[B] = test_new_vm2(frame[B]); assert(vm->heap_num==12); printf("id change check.........\n"); POP_VM(vm1,frame[B]); assert(vm->heap_num==8); printf("id change check.........\n"); gc_collect(); assert(vm->heap_num==7); LEAVE_FRAME(frame); } void test_pipes2() { enum {frame_START, frame_SIZE, A, B, C, frame_END}; ENTER_FRAME_ENUM(frame); A = gc_alloc_int(1); // 1 assert(vm->heap_num==1); PUSH_VM(vm1); assert(vm->heap_num==0); frame[B] = test_new_vm2(A); // 生きているのが2つ死んでいるのが2つ assert(vm->heap_num==4); gc_collect_pipe(frame[B]);// bだけコピーして後は消す assert(vm->heap_num==2); frame[B] = test_new_vm2(frame[B]);// bを渡すと 2つのデータが入ってるのを渡す assert(vm->heap_num==6); // 生きてる4、死んでる2 gc_collect_pipe(frame[B]);// bだけコピーして後は消す assert(vm->heap_num==4);// 生きてる4 frame[B] = test_new_vm2(frame[B]);// 4+4= assert(vm->heap_num==8);// 4 + 4 = 8 生きてる6死んでる2と gc_collect_pipe(frame[B]);// bだけコピーして後は消す assert(vm->heap_num==6);// 生きてる6 printf("id change check.........\n"); POP_VM(vm1, frame[B]); // 世界が終わる // ヒープ上には、元のデータ1と世界のデータ1と6つの生きているで8個 assert(vm->heap_num==8); printf("id change check.........\n"); gc_collect();// gcで世界のデータが消える。 assert(vm->heap_num==7); LEAVE_FRAME(frame); } */ void test_multi_vm() { ENTER_FRAME(frame,8); Object* A = pool(gc_alloc_int(1)); assert(vm->heap_num==1); VM* tmp_vm = pool(vm); VM* VM1 = pool(vm_new());// 世界を作る VM* VM2 = pool(vm_new());// 世界を作る assert(vm->heap_num==3); vm = VM1;// 世界を移動 assert(vm->heap_num==0); vm->record = test_int(A->intv);// 計算する assert(vm->heap_num==1); Object* C; vm = VM2;// 世界を移動 assert(vm->heap_num==0); C = pool(test_int(A->intv));// 計算する assert(vm->heap_num==1); vm_end(C, tmp_vm); vm = tmp_vm;// 元に戻る assert(vm->heap_num==4); Object* B = pool(vm_get_record(VM1));// コピーとる assert(vm->heap_num==5); printf("id change check.........\n"); gc_collect(); assert(vm->heap_num==5); LEAVE_FRAME(frame); }
void scene(t_data *d, t_dmlx *m) { if (m->scene == VM) vm(&d->vm, d->vm.cperloop); else if (m->scene == VM_INIT) vm_init(d, &d->vm); else if (m->scene == INTRO_LOAD) intro_load(m, &m->scene_img[0][0], &m->scene_img[0][1]); else if (m->scene == INTRO_MENU) intro_menu(&m->scene_img[0][2], &m->scene_img[0][1]); else if (m->scene == INTRO_OUT) intro_out(d, &m->scene_img[0][0], &m->scene_img[0][1] , &m->scene_img[0][3]); else if (m->scene == END) vm_end(m, &data()->vm, &m->scene_img[0][0]); }