Changeset 12366 for lang/c

Show
Ignore:
Timestamp:
05/25/08 23:37:08 (6 months ago)
Author:
mokehehe
Message:

Fix a bug about 'find-free'.

Location:
lang/c/misc/mlisp
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/c/misc/mlisp/core/c_compiler.cpp

    r12358 r12366  
    193193static SExp find_free(SExp x, SExp b); 
    194194 
    195 static SExp find_free_compound(SExp body, SExp free) { 
    196         for (SExp p = body; !nilp(p); p = cdr(p)) { 
     195static SExp find_free_compound(SExp xs, SExp b) { 
     196        SExp r = nil; 
     197        for (SExp p = xs; !nilp(p); p = cdr(p)) { 
    197198                SExp x = car(p); 
    198                 free = find_free(x, free); 
    199         } 
    200         return free; 
     199                r = set_union(find_free(x, b), r); 
     200        } 
     201        return r; 
    201202} 
    202203 
     
    241242                        return find_free_compound(body, b); 
    242243                } else { 
    243                         SExp r = nil; 
    244                         for (;; x = cdr(x)) { 
    245                                 if (nilp(x))    break; 
    246                                 r = set_union(find_free(car(x), b), r); 
    247                         } 
    248                         return r; 
     244                        return find_free_compound(x, b); 
    249245                } 
    250246        } else { 
  • lang/c/misc/mlisp/core/v_vm.h

    r11756 r12366  
    1 //============================================================================= 
    21/// �o�[�`�����}�V�� 
    32//============================================================================= 
  • lang/c/misc/mlisp/proto/stackbased.scm

    r12358 r12366  
    295295  (lambda (x b) 
    296296    (define (find-free-compound xs b) 
    297       (fold (lambda (x r) (find-free x r)) 
    298             b 
     297      (fold (lambda (x r) (set-union (find-free x b) r)) 
     298            '() 
    299299            xs)) 
    300300    (cond 
     
    319319                       (find-free-compound body b))) 
    320320                   (else 
    321                     (recur next ((x x)) 
    322                            (if (null? x) 
    323                                '() 
    324                              (set-union (find-free (car x) b) 
    325                                         (next (cdr x)))))))) 
     321                    (find-free-compound x b)))) 
    326322     (else '())))) 
    327323