- Timestamp:
- 05/24/08 14:18:59 (6 months ago)
- Location:
- lang/c/misc/mlisp
- Files:
-
- 1 added
- 6 modified
-
core/c_compiler.cpp (modified) (2 diffs)
-
core/inner.h (modified) (3 diffs)
-
core/v_vm.cpp (modified) (3 diffs)
-
inc/sexp_dev.h (added)
-
mlisp.vcproj (modified) (1 diff)
-
proto/stackbased.scm (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/misc/mlisp/core/c_compiler.cpp
r12263 r12268 435 435 // �K�p����p�C�� 436 436 static SExp compile_apply(SExp x, SExp e, SExp s, SExp next) { 437 SExp expanded = macroexpand_1(x);438 if (!eq(expanded, x)) {439 return compile(expanded, e, s, next);440 } else {437 // SExp expanded = macroexpand_1(x); 438 // if (!eq(expanded, x)) { 439 // return compile(expanded, e, s, next); 440 // } else { 441 441 SExp args = cdr(x); 442 442 int argnum = length(args); … … 445 445 SExp c = compile(car(x), e, s, nx); 446 446 return compile_pair_loop(args, c, e, s, next); 447 }447 // } 448 448 } 449 449 -
lang/c/misc/mlisp/core/inner.h
r12263 r12268 6 6 7 7 #include "sexp.h" 8 #include " mlisp.h"8 #include "sexp_dev.h" 9 9 10 10 #ifndef FALSE … … 28 28 ERR_UNDEFINED_SYMBOL, 29 29 ERR_UNEXPECTED, 30 };31 32 33 /// S���̒lj���x�[�X�N���X�i�Z���Ȃǁj34 struct SExpExt {35 SType type; ///< �^36 30 }; 37 31 … … 92 86 93 87 94 __inline SExp gen_sexpext(struct SExpExt* p) {95 SExp s;96 s.ptr = (SExpExtU*)p;97 return s;98 }99 100 101 88 102 89 -
lang/c/misc/mlisp/core/v_vm.cpp
r12263 r12268 173 173 } 174 174 175 static void modify_args(Procedure* proc, int n, int s) { 175 static void modify_args(Procedure* proc, int n) { 176 int s = g_sp - 1; 176 177 if (proc->minnarg != proc->maxnarg) { 177 SExp rest = nil; 178 for (int i=n; --i >= proc->minnarg; ) { 179 rest = cons(index(s, i), rest); 178 if (proc->maxnarg == -1) { // REST �p�����[�^ 179 SExp rest = nil; 180 for (int i=n; --i >= proc->minnarg; ) { 181 rest = cons(index(s, i), rest); 182 } 183 if (n == proc->minnarg) { // REST �p�����[�^�ɉ��������Ȃ�����ꍇ�A�X�^�b�N�t���[�����������̂Ŋg������ const int m = n - proc->minnarg + 1; 184 for (int i=0; i<n; ++i) { 185 index_set(s, i, index(s, i + m)); 186 } 187 push(int2s(n + m)); 188 s += m; 189 } 190 index_set(s, proc->minnarg, rest); 191 } else { 192 assert(!"not implemented"); 180 193 } 181 index_set(s, proc->minnarg, rest);182 194 } 183 195 } … … 245 257 if (check_arg_num(proc, n)) { 246 258 push(argnum); 247 int ss = g_sp;248 259 switch (proc->get_func_type()) { 249 260 case Procedure::Builtin: … … 257 268 case Procedure::Cell: 258 269 { 259 modify_args(proc, n , ss - 1);260 *px = closure_body(fn); *pf = ss; *pc = fn;270 modify_args(proc, n); 271 *px = closure_body(fn); *pf = g_sp; *pc = fn; 261 272 } 262 273 r = 1; -
lang/c/misc/mlisp/mlisp.vcproj
r12263 r12268 197 197 </File> 198 198 <File 199 RelativePath=".\inc\mlisp_dev.h"> 200 </File> 201 <File 199 202 RelativePath=".\inc\sexp.h"> 203 </File> 204 <File 205 RelativePath=".\inc\sexp_dev.h"> 200 206 </File> 201 207 </Filter> -
lang/c/misc/mlisp/proto/stackbased.scm
r12180 r12268 452 452 (if (is-a? a <functional>) 453 453 (if (check-arg-num a n) 454 (let (( ss (push n))455 (body (closure-body a)))454 (let ((body (closure-body a))) 455 (push n) 456 456 (if (procedure? body) 457 457 (let* ((res (body)) … … 459 459 (VM res ret f c)) 460 460 (begin 461 (modify-args a n (- ss 1))462 (VM a body ssa))))461 (modify-args a n) 462 (VM a body *sp* a)))) 463 463 (error "wrong number of argument")) 464 464 (error "can't apply"))) … … 567 567 568 568 ;; 可変引数の受け取り 569 (define (modify-args c n s) 570 (let* ((min (closure-min-arg-num c)) 571 (max (closure-max-arg-num c))) 572 (if (!= min max) 573 (let ((rest (do ((i (-1+ n) (-1+ i)) 574 (ls '() (cons (index s i) ls))) 575 ((< i min) ls)))) 576 (index-set! s min rest))))) 569 (define (modify-args c n) 570 (let ((s (-1+ *sp*))) 571 (define (expand-frame n m) 572 (dotimes (i n '()) 573 (index-set! s i (index s (+ i m)))) 574 (push (+ n m))) 575 (let* ((min (closure-min-arg-num c)) 576 (max (closure-max-arg-num c))) 577 (if (!= min max) 578 (if (= max -1) ; REST パラメータ 579 (let ((rest (do ((i (-1+ n) (-1+ i)) 580 (ls '() (cons (index s i) ls))) 581 ((< i min) ls)))) 582 (if (= n min) ; REST パラメータに何も与えられなかった場合、スタックフレームが足りないので拡張する 583 (let ((m (1+ (- n min)))) 584 (expand-frame n m) 585 (inc! s (+ n m)))) 586 (index-set! s min rest)) 587 (error "not implemented")))))) 577 588 578 589 -
lang/c/misc/mlisp/readme.txt
r12263 r12268 47 47 48 48 * ToDo 49 -if ��else ���̕����ɑΉ�����-[v] �x�N�^��W���[���Ƃ��Ď������-[v] �X�^�b�N�x�[�X�ɒu��������-[v] �C�ӌ̈��� 49 -[v] �C�ӌ̈��O����Ɨ�����-�G���[���b�Z�[�W���Ƃ킩������ 50 -begin 51 -[v] �x�N�^��W���[���Ƃ��Ď������-[v] �X�^�b�N�x�[�X�ɒu��������-[v] �C�ӌ̈��� 50 52 -[v] �}�N����� 51 53 --[v] macroexpand ��-[v] C �������[�o���̊���яo�������ɂ���- �unil�v�ut�v���V���{���Ȃ̂ŁA�R���p�C�������V���{���Q�ƂɂȂ�Ă��܂�
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)