Changeset 12263 for lang/c

Show
Ignore:
Timestamp:
05/24/08 11:08:18 (6 months ago)
Author:
mokehehe
Message:

change vector to module.

Location:
lang/c/misc/mlisp
Files:
1 added
12 modified
2 moved

Legend:

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

    r12180 r12263  
    77 
    88#include "c_compiler.h" 
    9 #include "sexp.h" 
     9#include "mlisp_dev.h" 
    1010#include "s_util.h" 
    1111#include "op.h" 
  • lang/c/misc/mlisp/core/inner.h

    r12180 r12263  
    8282 
    8383 
    84 /// �x�N�^ 
    85 struct SVector : public SExpExt { 
    86         unsigned int size; 
    87         SExp buf[1];                    // �o�b�t�@�̃T�C�Y���L�т�}; 
    88  
    89  
    9084/// �f�o�b�O���Â炢�̂ŁA�S�̂�񂾌^��� 
    9185union SExpExtU { 
     
    9589        String string; 
    9690        Procedure procedure; 
    97         SVector vector; 
    9891}; 
    9992 
    10093 
     94__inline SExp gen_sexpext(struct SExpExt* p) { 
     95        SExp s; 
     96        s.ptr = (SExpExtU*)p; 
     97        return s; 
     98} 
    10199 
    102100 
    103 /// �������m�� 
    104 void* salloc(size_t size, int b_atomic); 
     101 
    105102 
    106103void print_rec(SExp s); 
     
    108105 
    109106 
    110 /// ��s���F�X�^�b�N�Q�� 
    111 sint get_arg_num(void); 
    112 SExp get_arg(int idx); 
    113  
    114107SExp macroexpand_1(SExp x); 
  • lang/c/misc/mlisp/core/m_basic.cpp

    r12180 r12263  
    55#include "m_basic.h" 
    66#include "v_vm.h" 
    7 #include "mlisp.h" 
     7#include "mlisp_dev.h" 
    88#include "s_util.h" 
    99#include "inner.h" 
  • lang/c/misc/mlisp/core/m_vect.cpp

    r11617 r12263  
    33//============================================================================= 
    44 
    5 #include "s_vect.h" 
     5#include "m_vect.h" 
     6#include "mlisp_dev.h" 
    67#include "inner.h" 
     8 
     9 
     10int tVect; 
     11 
     12 
     13struct SVector : public SExpExt { 
     14        unsigned int size; 
     15        SExp buf[1];                    // �o�b�t�@�̃T�C�Y���L�т�}; 
     16 
     17 
     18void add_vector_module(void) { 
     19        tVect = mlisp_alloc_new_type(); 
     20} 
    721 
    822 
     
    1125                return nil; 
    1226 
    13         unsigned int n = size; 
    14         SVector* p = (SVector*)salloc(sizeof(SVector) + sizeof(SExp) * (n - 1), FALSE); 
    15         p->type = tVect; 
    16         p->size = n; 
    17         for (unsigned int i=0; i<n; ++i) { 
     27        SVector* p = (SVector*)salloc(sizeof(SVector) + sizeof(SExp) * (size - 1), FALSE); 
     28        p->type = (SType)tVect; 
     29        p->size = size; 
     30        for (int i=0; i<size; ++i) { 
    1831                p->buf[i] = nil; 
    1932        } 
    2033 
    21         SExp s; 
    22         s.ptr = (SExpExtU*)p; 
    23         return s; 
     34        return gen_sexpext(p); 
    2435} 
    2536 
  • lang/c/misc/mlisp/core/m_vect.h

    r11550 r12263  
    1313#endif 
    1414 
     15extern int tVect; 
     16 
     17void add_vector_module(void); 
    1518 
    1619SExp make_vector(int size); 
  • lang/c/misc/mlisp/core/mlisp.cpp

    r12180 r12263  
    44 
    55#include "mlisp.h" 
     6#include "mlisp_dev.h" 
    67#include "s_util.h" 
    78#include "c_compiler.h" 
     
    910#include "op.h" 
    1011#include "m_basic.h" 
     12#include "m_vect.h" 
    1113#include "inner.h" 
    1214 
     
    4244 
    4345 
     46int mlisp_alloc_new_type() { 
     47        static int type = tUserDef; 
     48        return type++; 
     49} 
     50 
     51 
    4452void mlisp_new(const SVTable* vtbl) { 
    4553        sexp_new(vtbl); 
     
    4755        init_compile(); 
    4856        define_basic_lib(); 
     57        add_vector_module(); 
    4958} 
    5059 
     
    5261        sexp_delete(); 
    5362} 
     63 
  • lang/c/misc/mlisp/core/s_print.cpp

    r11617 r12263  
    7171                } 
    7272                break; 
    73         case tVect: 
    74                 print_vector(s); 
    75                 break; 
     73//      case tVect: 
     74//              print_vector(s); 
     75//              break; 
    7676        } 
    7777} 
  • lang/c/misc/mlisp/core/sexp.cpp

    r11750 r12263  
    167167} 
    168168 
    169 int type_check(SExp s, SType type) { 
     169int type_check(SExp s, int type) { 
    170170        if (type_of(s) != type) { 
    171171                error(ERR_TYPE_REQUIRED, TypeStrTbl[type]); 
     
    183183        p->cdr = d; 
    184184 
    185         SExp s; 
    186         s.ptr = (SExpExtU*)p; 
    187         return s; 
     185        return gen_sexpext(p); 
    188186} 
    189187 
     
    227225                p->str[l] = '\0'; 
    228226 
    229                 SExp s; 
    230                 s.ptr = (SExpExtU*)p; 
     227                SExp s = gen_sexpext(p); 
    231228                symbol_table.add(s); 
    232229                return s; 
     
    242239        p->str[l] = '\0'; 
    243240 
    244         SExp s; 
    245         s.ptr = (SExpExtU*)p; 
    246         return s; 
     241        return gen_sexpext(p); 
    247242} 
    248243 
     
    257252        p->maxnarg = maxnarg; 
    258253 
    259         SExp s; 
    260         s.ptr = (SExpExtU*)p; 
    261  
    262         return s; 
     254        return gen_sexpext(p); 
    263255} 
    264256 
     
    272264        p->maxnarg = maxnarg; 
    273265 
    274         SExp s; 
    275         s.ptr = (SExpExtU*)p; 
    276  
    277         return s; 
     266        return gen_sexpext(p); 
    278267} 
    279268 
     
    289278        p->maxnarg = maxnarg; 
    290279 
    291         SExp s; 
    292         s.ptr = (SExpExtU*)p; 
    293  
    294         return s; 
     280        return gen_sexpext(p); 
    295281} 
    296282 
     
    306292        p->maxnarg = maxnarg; 
    307293 
    308         SExp s; 
    309         s.ptr = (SExpExtU*)p; 
    310  
    311         return s; 
     294        return gen_sexpext(p); 
    312295} 
    313296 
  • lang/c/misc/mlisp/core/v_vm.cpp

    r12093 r12263  
    77 
    88#include "v_vm.h" 
    9 #include "sexp.h" 
     9#include "mlisp_dev.h" 
    1010#include "s_util.h" 
    11 #include "s_vect.h" 
     11#include "m_vect.h" 
    1212#include "op.h" 
    1313#include "inner.h" 
  • lang/c/misc/mlisp/inc/mlisp.h

    r12093 r12263  
    1717 
    1818 
    19 /// �g�b�v���x���ŃR���p�C�� 
    20 SExp compile_ontop(SExp code); 
    21  
    2219/// �]�� 
    2320SExp evaluate(SExp code); 
    2421 
    25 /// �\�[�X�̓ǂݍ��݁A�]�� 
     22/// �t�@�C�������ǂݍ��݁A�]�� 
    2623SExp load_eval(const char* fn); 
    27  
    28  
    29 /// �O���[�o���Ȓl�̒� 
    30 void define_global(SExp sym, SExp val); 
    31  
    32 /// �O���[�o���̎Q�� 
    33 SExp refer_global(SExp sym); 
    34  
    35 /// �O���[�o���ɒl�����݂��邩�H 
    36 int exist_global(SExp sym); 
    37  
    38 /// �Ăяo�� 
    39 SExp vm_apply(SExp fn, int narg, ...); 
    4024 
    4125 
  • lang/c/misc/mlisp/inc/sexp.h

    r12093 r12263  
    2222/// �^�̎� 
    2323typedef enum { 
     24        tUnknown = -1,                  ///< �s�� 
    2425        tInt,                                   ///< ���� 
    2526        tCell,                                  ///< �Z�� 
    2627        tSymb,                                  ///< �V���{�� 
    2728        tStr,                                   ///< ������tProc,                                       ///< �v���V�W�� 
    28         tVect,                                  ///< �x�N�^ 
    2929 
    30         tUnknown,                               ///< �G���[ 
    31 } SType; 
     30        tUserDef,                               ///< ���R�g�p�̈�} SType; 
    3231 
    3332 
     
    3534typedef union SExp { 
    3635        sint i;                                 ///< ���� 
    37 //      struct SExpExt* ptr;    ///< ���̑� 
    3836        union SExpExtU* ptr;    ///< ���̑� 
    3937 
     
    119117const char* s2str(SExp s); 
    120118 
     119/// �������m�� 
     120void* salloc(size_t size, int b_atomic); 
     121 
    121122 
    122123 
     
    125126        �Ⴄ�ꍇ�G���[������ 
    126127 */ 
    127 int type_check(SExp s, SType type); 
     128int type_check(SExp s, int type); 
    128129 
    129130 
  • lang/c/misc/mlisp/mlisp.vcproj

    r11715 r12263  
    135135                        </File> 
    136136                        <File 
    137                                 RelativePath=".\core\s_vect.cpp"> 
    138                         </File> 
    139                         <File 
    140                                 RelativePath=".\core\s_vect.h"> 
    141                         </File> 
    142                         <File 
    143137                                RelativePath=".\core\sexp.cpp"> 
    144138                        </File> 
     
    174168                                <File 
    175169                                        RelativePath=".\core\m_basic.h"> 
     170                                </File> 
     171                                <File 
     172                                        RelativePath=".\core\m_vect.cpp"> 
     173                                </File> 
     174                                <File 
     175                                        RelativePath=".\core\m_vect.h"> 
    176176                                </File> 
    177177                                <File 
  • lang/c/misc/mlisp/readme.txt

    r12180 r12263  
    4747 
    4848* ToDo 
    49 -[v] �X�^�b�N�x�[�X�ɒu��������-[v] �C�ӌ‚̈��󂯎� 
     49-if ��else ���̕����ɑΉ�����-[v] �x�N�^��W���[���Ƃ��Ď������-[v] �X�^�b�N�x�[�X�ɒu��������-[v] �C�ӌ‚̈��󂯎� 
    5050-[v] �}�N����� 
    5151--[v] macroexpand ��-[v] C �������[�o���̊֐���яo�������ɂ���- �unil�v�ut�v���V���{���Ȃ̂ŁA�R���p�C�������V���{���Q�ƂɂȂ�Ă��܂� 
  • lang/c/misc/mlisp/test/main.cpp

    r12093 r12263  
    4747 
    4848 
     49#if 0 
    4950void test_call() { 
    5051        SExp src = read_from_string( 
     
    6263        print(r); 
    6364} 
     65#endif 
    6466 
    6567