Changeset 2949
- Timestamp:
- 12/09/07 21:23:52 (13 months ago)
- Location:
- lang/c/misc/mlisp/src
- Files:
-
- 2 modified
-
ml_builtin.c (modified) (1 diff)
-
mlisp.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/misc/mlisp/src/ml_builtin.c
r2378 r2949 264 264 r = ml_read(ml, fp); 265 265 if (r == cEOF) break; 266 ml_print(ml, stdout, r, FALSE);266 // ml_print(ml, stdout, r, FALSE); 267 267 268 268 e = ml_eval(ml, r); 269 ml_print(ml, stdout, e, FALSE);269 // ml_print(ml, stdout, e, FALSE); 270 270 } 271 271 -
lang/c/misc/mlisp/src/mlisp.cpp
r2945 r2949 75 75 SExp car; 76 76 SExp cdr; 77 bool unreach; // �K�x�R���p�F�����B�t���O 77 78 } Cell; 78 79 … … 142 143 143 144 private: 144 void collect_garbage(); 145 void clear_all_mark(); ///< ���ׂẴZ���𖢓��B�ɐݒ� void mark_cell(SExp sexp); ///< �Z���Ƀ}�[�N������ċA�j 146 void collect_garbage(); ///< �K�x�[�W�R���N�V���� 145 147 146 148 SExp read_string(FILE* fp); … … 251 253 g_builtin_p = 0; 252 254 255 clear_all_mark(); 253 256 // �Z������Ȃ��āA�t���[�Z���Ƃ��� for (int i=0; i<MAX_CELL-1; ++i) { 254 257 Cell* p = &g_cell_buf[i]; … … 298 301 } 299 302 303 void MLContext::clear_all_mark() 304 { 305 for (int i=0; i<MAX_CELL; ++i) { 306 Cell* p = &g_cell_buf[i]; 307 p->unreach = true; 308 } 309 } 310 311 void MLContext::mark_cell(SExp sexp) 312 { 313 int type = SEXP_TYPE(sexp); 314 if (type == tCell || type == tFunc) { 315 Cell* p = get_cell_ptr(sexp); 316 if (p->unreach) { 317 p->unreach = false; 318 mark_cell(p->car); 319 mark_cell(p->cdr); 320 } 321 } 322 } 323 300 324 void MLContext::collect_garbage() 301 325 { 302 assert(!"not implemented"); 326 assert(!"���r���I"); 327 328 clear_all_mark(); 329 330 // �����炽�ǂ��Z���Ƀ}�[�N����� // �O���[�o�� 331 for (int i=0; i<g_symbol_free_p; ++i) { 332 Symbol* p = &g_symbol_buf[i]; 333 mark_cell(p->sexp); 334 } 335 // �X�^�b�N 336 for (int i=0; i<g_stack_p; ++i) { 337 SExp sexp = g_stack[i]; 338 mark_cell(sexp); 339 } 340 341 // �}�[�N�̂��ĂȂ��Z�����Exp free = cNil; 342 for (int i=0; i<MAX_CELL; ++i) { 343 Cell* p = &g_cell_buf[i]; 344 if (p->unreach) { 345 SExp t = MAKE_SEXP(tCell, i); 346 Cell* p = get_cell_ptr(t); 347 p->cdr = free; 348 free = t; 349 ++free_cell_num; 350 } 351 } 352 g_free_cell = free; 303 353 } 304 354 … … 317 367 318 368 Cell* p = &g_cell_buf[idx]; 369 assert(p->unreach); 319 370 p->car = a; 320 371 p->cdr = d; 372 p->unreach = false; 321 373 322 374 return MAKE_SEXP(tCell, idx);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)