Changeset 11110 for lang/c

Show
Ignore:
Timestamp:
05/04/08 21:45:54 (7 months ago)
Author:
mokehehe
Message:
 
Location:
lang/c/misc/mlisp
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/c/misc/mlisp/compiler/compiler.cpp

    r11061 r11110  
    1010 
    1111 
     12void compile_error(int errcode) { 
     13        error(errcode); 
     14} 
     15 
     16 
     17 
    1218static SExp extend(SExp e, SExp r) { 
    1319        return cons(r, e); 
     
    1824} 
    1925 
    20  
    21 void compile_error(int errcode) { 
    22         error(errcode); 
    23 } 
    24  
    25 // ���݂̊‹��ɕϐ���^ 
    26 //  �߂��̓C���f�N�X 
    27 SExp compile_define_var(SExp env, SExp var) { 
     26/// �‹��ɕϐ���^ 
     27/** 
     28        @return         �C���f�N�X 
     29*/ 
     30static SExp compile_define_var(SExp env, SExp var) { 
    2831        SExp e = car(env); 
    2932        int l; 
     
    3841} 
    3942 
    40 // ���[�J���‹��ɕϐ���^ 
    41 SExp compile_define_local(SExp env, SExp var) { 
     43/// ���[�J���‹��ɕϐ���^ 
     44static SExp compile_define_local(SExp env, SExp var) { 
    4245        return cons(int2s(0), compile_define_var(env, var)); 
    4346} 
    4447 
    45 // ���[�J���‹��ɕϐ���^ 
    46 SExp compile_define_global(SExp env, SExp var) { 
     48/// ���[�J���‹��ɕϐ���^ 
     49static SExp compile_define_global(SExp env, SExp var) { 
    4750        return cons(int2s(length(env) - 1), compile_define_var(last_pair(env), var)); 
    4851} 
    4952 
    5053 
    51  
    52  
     54/// �ϐ��Q�� 
    5355static SExp compile_lookup(SExp var, SExp e) { 
    54 #if 0 
    55         int rib = 0; 
    56 nxtrib:; 
    57                 if (nilp(e))    return nil; 
    58                 SExp vars = car(e); 
    59                 int elt = 0; 
    60 nxtelt:; 
    61                         if (nilp(vars))                 { e = cdr(e); ++rib; goto nxtrib; } 
    62                         if (eq(car(vars), var)) return cons(int2s(rib), int2s(elt)); 
    63                         else                                    { vars = cdr(vars); ++elt; goto nxtelt; } 
    64 #else 
    6556        int rib = 0; 
    6657        for (;; e = cdr(e), ++rib) { 
     
    7364                } 
    7465        } 
    75 #endif 
    7666} 
    7767 
    78  
     68/// �y�A����p�C�� 
    7969static SExp compile_pair_loop(SExp args, SExp c, SExp e, SExp next) { 
    8070        if (nilp(args)) { 
     
    8979} 
    9080 
    91 SExp compile_set(SExp op, SExp sym, SExp val, SExp e, SExp next, bool b_define) { 
     81/// set! ����p�C�� 
     82static SExp compile_set(SExp op, SExp sym, SExp val, SExp e, SExp next, bool b_define) { 
    9283        SExp access = compile_lookup(sym, e); 
    9384        if (nilp(access)) { 
     
    10192} 
    10293 
    103 SExp compile_define(SExp var, SExp xs, SExp e, SExp next) { 
     94/// define ����p�C�� 
     95static SExp compile_define(SExp var, SExp xs, SExp e, SExp next) { 
    10496        while (consp(var)) { 
    10597                SExp fname = car(var); 
     
    112104} 
    113105 
    114 SExp get_next(SExp sexps, SExp next) { 
     106/// �u���b�N�R���p�C�����́A���̖��� 
     107static SExp get_next(SExp sexps, SExp next) { 
    115108        if (singlep(sexps)) 
    116109                return cons(car(next), cdr(next)); 
     
    119112} 
    120113 
    121 SExp compile_block_loop(SExp sexps, SExp e, SExp prev, SExp next) { 
    122         while (!nilp(sexps)) { 
     114/// �����̎�����p�C�� 
     115SExp compile_block(SExp sexps, SExp e, SExp next) { 
     116        SExp start = get_next(sexps, next); 
     117        for (SExp prev = start; !nilp(sexps); sexps = cdr(sexps)) { 
    123118                SExp se = car(sexps); 
    124119                SExp nx = get_next(sexps, next); 
     
    127122                rplacd(prev, cdr(r)); 
    128123 
    129                 sexps = cdr(sexps); 
    130124                prev = nx; 
    131125        } 
    132         return prev; 
    133 } 
    134  
    135  
    136 SExp compile_block(SExp sexps, SExp e, SExp next) { 
    137         SExp start = get_next(sexps, next); 
    138         compile_block_loop(sexps, e, start, next); 
    139126        return start; 
    140127} 
    141128 
    142  
     129/// �P�‚̎�����p�C�� 
    143130SExp compile(SExp x, SExp e, SExp next) { 
    144131        if (symbolp(x)) { 
  • lang/c/misc/mlisp/readme.txt

    r11059 r11110  
    77 
    88* �m�[�g 
    9 -repl ����quit�v�Ƒł����ނƔ�����-�V���{���̑啶���Ə�������ʂ��� 
     9- repl ����quit�v�Ƒł����ނƔ�����- �V���{���̑啶���Ə�������ʂ��� 
     10- ������ 
     11-- ���� 
     12-- �V���{�� 
     13-- ������- �Z�� 
    1014 
    1115 
    1216* ��� 
    13 -BoehmGC ��p 
    14 -�r������p�C�����āA�o�C�g�R�[�h��s 
    15 -�q�[�v�x�[�X�̎�� 
     17- �r������p�C�����āA�o�C�g�R�[�h��s 
     18- �q�[�v�x�[�X�̎�� 
     19- BoehmGC ��p 
    1620 
     21 
     22 
     23* �\�[�X�\�� 
     24 
     25        sexp 
     26                �r������        compiler 
     27                �R���p�C�� 
     28        vm 
     29                �o�[�`�����}�V�� 
     30        test 
     31                �e�X�g�p�G���g�� 
     32 
     33        mlisp.vcproj 
     34                VC(2003) �p�v���W�F�N�g�t�@�C�� 
    1735 
    1836 
    1937* ToDo 
    2038- �X�^�b�N�x�[�X�ɒu��������- �R���p�C�����̊֐��Ăяo���`�F�b�N 
    21 -- �֐����H 
     39-- �֐����ǂ����H 
    2240-- ����������Ă邩�H 
    2341- �C�ӌ‚̈��󂯎� 
    2442- �}�N����� 
    25 - C �������[�o���̊֐���яo�������ɂ���-�unil�v�ut�v���V���{���Ȃ̂ŁA�R���p�C�������V���{���Q�ƂɂȂ�Ă��܂� 
     43-- macroexpand ��- C �������[�o���̊֐���яo�������ɂ���- �unil�v�ut�v���V���{���Ȃ̂ŁA�R���p�C�������V���{���Q�ƂɂȂ�Ă��܂� 
     44- ��s���ɕϐ�������������Ƃ��̎����� 
     45- �������� 
    2646 
    2747- SDL �Ɨ��߂ĂȂ񂩍��i�e�g���X�j 
    2848 
     49 
     50 
     51* changelog 
     52 
     53** 080504 
     54- �쐬 
  • lang/c/misc/mlisp/vm/op.h

    r11061 r11110  
     1//============================================================================= 
     2/// �o�C�g�R�[�h�̖��ߒ� 
     3//============================================================================= 
     4 
    15#pragma once 
    26