Changeset 635


Ignore:
Timestamp:
May 11, 2011, 1:26:11 AM (7 years ago)
Author:
Sam Hocevar
Message:

lisp: refactor Lisp spaces so that they are real objects, and get rid
of the unused USER_SPACE.

Location:
abuse/trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/cache.cpp

    r555 r635  
    382382      if (cache_fun)
    383383      {
    384     int sp=current_space;
    385     current_space=PERM_SPACE;
     384    LSpace *sp = LSpace::Current;
     385    LSpace::Current = &LSpace::Perm;
    386386
    387387    void *call_with=NULL;
     
    419419      }
    420420    }
    421     current_space=sp;
     421    LSpace::Current=sp;
    422422
    423423      }
  • abuse/trunk/src/chars.cpp

    r555 r635  
    113113    num=ts;
    114114    if (num<MAX_STATE) num=MAX_STATE;
    115     int sp=current_space;
    116     current_space=PERM_SPACE;
     115    LSpace *sp = LSpace::Current;
     116    LSpace::Current = &LSpace::Perm;
    117117    ((LSymbol *)symbol)->SetNumber(num);
    118     current_space=sp;
     118    LSpace::Current=sp;
    119119  }
    120120
     
    268268
    269269    /* create the var and add to var list */
    270     int sp=current_space;
    271     current_space=PERM_SPACE;
     270    LSpace *sp = LSpace::Current;
     271    LSpace::Current = &LSpace::Perm;
    272272
    273273    add_c_object(symbol,free_index);
     
    276276    var_index[free_index]=tv;
    277277    tv++;
    278     current_space=sp;
     278    LSpace::Current=sp;
    279279  }
    280280}
  • abuse/trunk/src/clisp.cpp

    r579 r635  
    724724      for (int x=0; x<trials; x++)
    725725      {
    726     clear_tmp();
     726    LSpace::Tmp.Clear();
    727727    CAR(args)->Eval();
    728728      }
     
    770770        exit(0);
    771771      }
    772       int sp=current_space;
    773       current_space=PERM_SPACE;
     772      LSpace *sp = LSpace::Current;
     773      LSpace::Current = &LSpace::Perm;
    774774      sym->SetNumber(total_objects);   // set the symbol value to the object number
    775       current_space=sp;
     775      LSpace::Current=sp;
    776776      if (!total_objects)
    777777      {
     
    13821382      }
    13831383
    1384       int sp=current_space;
    1385       current_space=PERM_SPACE;
     1384      LSpace *sp = LSpace::Current;
     1385      LSpace::Current = &LSpace::Perm;
    13861386      int id=cache.reg(lstring_value(lcar(args)),NULL,SPEC_EXTERN_SFX,1);
    13871387      if (sym)
    13881388        sym->SetNumber(id);    // set the symbol value to sfx id
    1389       current_space=sp;
     1389      LSpace::Current=sp;
    13901390      return id;
    13911391    } break;
  • abuse/trunk/src/dev.cpp

    r579 r635  
    5353
    5454  // maybe english.lsp was not loaded yet, let's try to do that
    55   int sp=current_space;
    56   current_space=PERM_SPACE;
    57 
     55  LSpace *sp = LSpace::Current;
     56  LSpace::Current = &LSpace::Perm;
    5857
    5958  char prog[50];
     
    6867    exit(0);
    6968  }
    70   current_space=sp;
     69  LSpace::Current=sp;
    7170
    7271
  • abuse/trunk/src/game.cpp

    r632 r635  
    699699  {
    700700    screen->dirt_off();
    701     clear_tmp();
     701    LSpace::Tmp.Clear();
    702702    l_post_render->EvalFunction(NULL);
    703     clear_tmp();
     703    LSpace::Tmp.Clear();
    704704    screen->dirt_on();
    705705  }
     
    19851985void Game::step()
    19861986{
    1987   clear_tmp();
     1987  LSpace::Tmp.Clear();
    19881988  if(current_level)
    19891989  {
     
    22822282        if(!strcmp(argv[i], "-lisp"))
    22832283        {
    2284             lisp_init();
     2284            Lisp::Init();
    22852285            char const *eof_char = "Ctrl-D";
    22862286            fprintf(stderr,
     
    23282328/*      if(DEFINEDP(symbol_function(l_next_song)))  // if user function installed, call it to load up next song
    23292329      {
    2330     int sp = current_space;
    2331     current_space = PERM_SPACE;
     2330    int sp = LSpace::Current;
     2331    LSpace::Current = SPACE_PERM;
    23322332    ((LSymbol *)l_next_song)->EvalFunction(NULL);
    2333     current_space = sp;
     2333    LSpace::Current = sp;
    23342334      } */
    23352335    }
     
    24592459
    24602460        game_net_init(argc, argv);
    2461         lisp_init();
     2461        Lisp::Init();
    24622462
    24632463        dev_init(argc, argv);
     
    25882588        }
    25892589
    2590         lisp_uninit();
     2590        Lisp::Uninit();
    25912591
    25922592#if !defined __CELLOS_LV2__
  • abuse/trunk/src/gamma.cpp

    r632 r635  
    189189                fprintf(fp, "(setq darkest_gray %ld)\n", dg);
    190190                fclose(fp);
    191                 int sp = current_space;
    192                 current_space = PERM_SPACE;
     191                LSpace *sp = LSpace::Current;
     192                LSpace::Current = &LSpace::Perm;
    193193                LSymbol::FindOrCreate("darkest_gray")->SetNumber(dg);
    194194
    195                 current_space = sp;
     195                LSpace::Current = sp;
    196196            }
    197197            else
  • abuse/trunk/src/level.cpp

    r555 r635  
    743743    }
    744744
    745     clear_tmp();
     745    LSpace::Tmp.Clear();
    746746
    747747    if (cur)
     
    822822  }
    823823
    824   clear_tmp();
     824  LSpace::Tmp.Clear();
    825825}
    826826
     
    941941      uint16_t t=fp->read_uint16();
    942942      game_object *p=new game_object(o_remap[t],1);
    943       clear_tmp();
     943      LSpace::Tmp.Clear();
    944944      if (!first) first=p; else last->next=p;
    945945      last=p; p->next=NULL;
     
    11511151        uint16_t t=fp->read_uint16();
    11521152        game_object *p=new game_object(o_remap[t],1);
    1153         clear_tmp();
     1153        LSpace::Tmp.Clear();
    11541154        if (!first) first=p; else last->next=p;
    11551155        last=p; p->next=NULL;
     
    15101510/*  if (DEFINEDP(symbol_function(l_level_loaded)))
    15111511  {
    1512     int sp=current_space;
    1513     current_space=PERM_SPACE;
     1512    LSpace *sp = LSpace::Current;
     1513    LSpace::Current = &LSpace::Perm;
    15141514
    15151515    void *arg_list=NULL;
     
    15181518    ((LSymbol *)l_level_loaded)->EvalFunction(arg_list);
    15191519
    1520     current_space=sp;
     1520    LSpace::Current = sp;
    15211521  } */
    15221522}
     
    18411841    if (f->focus)
    18421842    {
    1843       current_object=f->focus;
    1844       void *m=mark_heap(TMP_SPACE);
     1843      current_object = f->focus;
     1844      void *m = LSpace::Tmp.Mark();
    18451845      fun->EvalFunction(NULL);
    1846       restore_heap(m,TMP_SPACE);
     1846      LSpace::Tmp.Restore(m);
    18471847    }
    18481848      }
  • abuse/trunk/src/lisp/lisp.cpp

    r563 r635  
    4242 * tmp space which gets thrown away after completion of eval.  system
    4343 * functions reside in permant space. */
    44 
    45 bFILE *current_print_file=NULL;
     44LSpace LSpace::Tmp, LSpace::Perm, LSpace::Gc;
     45
     46/* Normally set to Tmp, unless compiling or other needs. */
     47LSpace *LSpace::Current;
     48
     49bFILE *current_print_file = NULL;
    4650
    4751LSymbol *LSymbol::root = NULL;
    4852size_t LSymbol::count = 0;
    4953
    50 
    51 uint8_t *space[4], *free_space[4];
    52 size_t space_size[4];
    5354int print_level = 0, trace_level = 0, trace_print_level = 1000;
    5455int total_user_functions;
    55 
    56 int current_space;  // normally set to TMP_SPACE, unless compiling or other needs
    5756
    5857int break_level=0;
     
    160159void need_perm_space(char const *why)
    161160{
    162   if (current_space!=PERM_SPACE && current_space!=GC_SPACE)
     161  if (LSpace::Current != &LSpace::Perm && LSpace::Current != &LSpace::Gc)
    163162  {
    164163    lbreak("%s : action requires permanant space\n", why);
     
    167166}
    168167
    169 void *mark_heap(int heap)
    170 {
    171   return free_space[heap];
    172 }
    173 
    174 void restore_heap(void *val, int heap)
    175 {
    176   free_space[heap] = (uint8_t *)val;
    177 }
    178 
    179 static size_t get_free_size(int which_space)
    180 {
    181     size_t used = free_space[which_space] - space[which_space];
    182     return space_size[which_space] > used ? space_size[which_space] - used : 0;
    183 }
    184 
    185 static void *lmalloc(size_t size, int which_space)
     168void *LSpace::Mark()
     169{
     170    return m_free;
     171}
     172
     173void LSpace::Restore(void *val)
     174{
     175    m_free = (uint8_t *)val;
     176}
     177
     178size_t LSpace::GetFree()
     179{
     180    size_t used = m_free - m_data;
     181    return m_size > used ? m_size - used : 0;
     182}
     183
     184void *LSpace::Alloc(size_t size)
    186185{
    187186    // Align allocation
     
    189188
    190189    // Collect garbage if necessary
    191     if (size > get_free_size(which_space))
    192     {
    193         if (which_space == PERM_SPACE || which_space == TMP_SPACE)
    194             LispGC::CollectSpace(which_space, 0);
    195 
    196         if (size > get_free_size(which_space))
    197             LispGC::CollectSpace(which_space, 1);
    198 
    199         if (size > get_free_size(which_space))
    200         {
    201             lbreak("lisp: cannot find %d bytes in space #%d\n",
    202                    size, which_space);
     190    if (size > GetFree())
     191    {
     192        if (this == &LSpace::Perm || this == &LSpace::Tmp)
     193            LispGC::CollectSpace(this, 0);
     194
     195        if (size > GetFree())
     196            LispGC::CollectSpace(this, 1);
     197
     198        if (size > GetFree())
     199        {
     200            lbreak("lisp: cannot find %d bytes in %s\n", size, m_name);
    203201            exit(0);
    204202        }
    205203    }
    206204
    207     void *ret = (void *)free_space[which_space];
    208     free_space[which_space] += size;
     205    void *ret = m_free;
     206    m_free += size;
    209207    return ret;
    210208}
     
    229227        size = sizeof(LRedirect);
    230228
    231     LArray *p = (LArray *)lmalloc(size, current_space);
     229    LArray *p = (LArray *)LSpace::Current->Alloc(size);
    232230    p->type = L_1D_ARRAY;
    233231    p->len = len;
     
    282280    size_t size = Max(sizeof(LFixedPoint), sizeof(LRedirect));
    283281
    284     LFixedPoint *p = (LFixedPoint *)lmalloc(size, current_space);
     282    LFixedPoint *p = (LFixedPoint *)LSpace::Current->Alloc(size);
    285283    p->type = L_FIXED_POINT;
    286284    p->x = x;
     
    292290    size_t size = Max(sizeof(LObjectVar), sizeof(LRedirect));
    293291
    294     LObjectVar *p = (LObjectVar *)lmalloc(size, current_space);
     292    LObjectVar *p = (LObjectVar *)LSpace::Current->Alloc(size);
    295293    p->type = L_OBJECT_VAR;
    296294    p->index = index;
     
    304302    size_t size = Max(sizeof(LPointer), sizeof(LRedirect));
    305303
    306     LPointer *p = (LPointer *)lmalloc(size, current_space);
     304    LPointer *p = (LPointer *)LSpace::Current->Alloc(size);
    307305    p->type = L_POINTER;
    308306    p->addr = addr;
     
    314312    size_t size = Max(sizeof(LChar), sizeof(LRedirect));
    315313
    316     LChar *c = (LChar *)lmalloc(size, current_space);
     314    LChar *c = (LChar *)LSpace::Current->Alloc(size);
    317315    c->type = L_CHARACTER;
    318316    c->ch = ch;
     
    339337    size_t size = Max(sizeof(LString) + length - 1, sizeof(LRedirect));
    340338
    341     LString *s = (LString *)lmalloc(size, current_space);
     339    LString *s = (LString *)LSpace::Current->Alloc(size);
    342340    s->type = L_STRING;
    343341    s->str[0] = '\0';
     
    351349    size_t size = Max(sizeof(LUserFunction), sizeof(LRedirect));
    352350
    353     LUserFunction *lu = (LUserFunction *)lmalloc(size, current_space);
     351    LUserFunction *lu = (LUserFunction *)LSpace::Current->Alloc(size);
    354352    lu->type = L_USER_FUNCTION;
    355353    lu->arg_list = arg_list;
     
    363361
    364362    // System functions should reside in permanant space
    365     int space = (current_space == GC_SPACE) ? GC_SPACE : PERM_SPACE;
    366     LSysFunction *ls = (LSysFunction *)lmalloc(size, space);
     363    LSysFunction *ls = LSpace::Current == &LSpace::Gc
     364                     ? (LSysFunction *)LSpace::Gc.Alloc(size)
     365                     : (LSysFunction *)LSpace::Perm.Alloc(size);
    367366    ls->type = L_SYS_FUNCTION;
    368367    ls->min_args = min_args;
     
    397396    size_t size = Max(sizeof(LSymbol), sizeof(LRedirect));
    398397
    399     LSymbol *s = (LSymbol *)lmalloc(size, current_space);
     398    LSymbol *s = (LSymbol *)LSpace::Current->Alloc(size);
    400399    PtrRef ref(s);
    401400
     
    414413    size_t size = Max(sizeof(LNumber), sizeof(LRedirect));
    415414
    416     LNumber *n = (LNumber *)lmalloc(size, current_space);
     415    LNumber *n = (LNumber *)LSpace::Current->Alloc(size);
    417416    n->type = L_NUMBER;
    418417    n->num = num;
     
    424423    size_t size = Max(sizeof(LList), sizeof(LRedirect));
    425424
    426     LList *c = (LList *)lmalloc(size, current_space);
     425    LList *c = (LList *)LSpace::Current->Alloc(size);
    427426    c->type = L_CONS_CELL;
    428427    c->car = NULL;
     
    772771  else
    773772  {
    774     int sp=current_space;
    775     if (current_space!=GC_SPACE)
    776       current_space=PERM_SPACE;       // make sure all symbols get defined in permanant space
     773    LSpace *sp = LSpace::Current;
     774    if (LSpace::Current != &LSpace::Gc)
     775      LSpace::Current = &LSpace::Perm;       // make sure all symbols get defined in permanant space
    777776    LList *cs;
    778777    cs=LList::Create();
     
    781780    cs->cdr=symbol_list;
    782781    symbol_list=cs;
    783     current_space=sp;
     782    LSpace::Current = sp;
    784783  }
    785784  return s;
     
    815814
    816815    // Make sure all symbols get defined in permanant space
    817     int sp = current_space;
    818     if (current_space != GC_SPACE)
    819        current_space = PERM_SPACE;
     816    LSpace *sp = LSpace::Current;
     817    if (LSpace::Current != &LSpace::Gc)
     818        LSpace::Current = &LSpace::Perm;
    820819
    821820    p = (LSymbol *)malloc(sizeof(LSymbol));
     
    833832    count++;
    834833
    835     current_space = sp;
     834    LSpace::Current = sp;
    836835    return p;
    837836}
     
    24012400                    stat_man->update((cs - s) * 100 / l);
    24022401#endif
    2403                 void *m = mark_heap(TMP_SPACE);
     2402                void *m = LSpace::Tmp.Mark();
    24042403                compiled_form = LObject::Compile(cs);
    24052404                compiled_form->Eval();
    24062405                compiled_form = NULL;
    2407                 restore_heap(m, TMP_SPACE);
     2406                LSpace::Tmp.Restore(m);
    24082407            }
    24092408#ifndef NO_LIBS
     
    24712470    case SYS_FUNC_ENUM:
    24722471    {
    2473         int sp = current_space;
    2474         current_space = PERM_SPACE;
     2472        LSpace *sp = LSpace::Current;
     2473        LSpace::Current = &LSpace::Perm;
    24752474        int32_t x = 0;
    24762475        while (arg_list)
     
    25112510            x++;
    25122511        }
    2513         current_space = sp;
     2512        LSpace::Current = sp;
    25142513        break;
    25152514    }
     
    28072806    }
    28082807    case SYS_FUNC_GC:
    2809         LispGC::CollectSpace(current_space, 0);
     2808        LispGC::CollectSpace(LSpace::Current, 0);
    28102809        break;
    28112810    case SYS_FUNC_SCHAR:
     
    29462945void tmp_space()
    29472946{
    2948     current_space = TMP_SPACE;
     2947    LSpace::Current = &LSpace::Tmp;
    29492948}
    29502949
    29512950void perm_space()
    29522951{
    2953     current_space = PERM_SPACE;
    2954 }
    2955 
    2956 void use_user_space(void *addr, long size)
    2957 {
    2958     current_space = USER_SPACE;
    2959     free_space[USER_SPACE] = space[USER_SPACE] = (uint8_t *)addr;
    2960     space_size[USER_SPACE] = size;
     2952    LSpace::Current = &LSpace::Perm;
    29612953}
    29622954
     
    30713063        {
    30723064            dprintf("%d (%d, %d, %d) TRACE : ", trace_level,
    3073                     get_free_size(PERM_SPACE), get_free_size(TMP_SPACE),
     3065                    LSpace::Perm.GetFree(), LSpace::Tmp.GetFree(),
    30743066                    PtrRef::stack.m_size);
    30753067            Print();
     
    31203112        if (trace_level <= trace_print_level)
    31213113            dprintf("%d (%d, %d, %d) TRACE ==> ", trace_level,
    3122                     get_free_size(PERM_SPACE), get_free_size(TMP_SPACE),
     3114                    LSpace::Perm.GetFree(), LSpace::Tmp.GetFree(),
    31233115                    PtrRef::stack.m_size);
    31243116        ret->Print();
     
    31273119
    31283120/*  l_user_stack.push(ret);
    3129   LispGC::CollectSpace(PERM_SPACE);
     3121  LispGC::CollectSpace(&LSpace::Perm);
    31303122  ret=l_user_stack.pop(1);  */
    31313123
     
    31353127void l_comp_init();
    31363128
    3137 void lisp_init()
     3129void Lisp::Init()
    31383130{
    31393131    LSymbol::root = NULL;
    31403132    total_user_functions = 0;
    31413133
    3142     free_space[0] = space[0] = (uint8_t *)malloc(0x1000);
    3143     space_size[0] = 0x1000;
    3144 
    3145     free_space[1] = space[1] = (uint8_t *)malloc(0x1000);
    3146     space_size[1] = 0x1000;
    3147 
    3148     current_space = PERM_SPACE;
     3134    LSpace::Tmp.m_free = LSpace::Tmp.m_data = (uint8_t *)malloc(0x1000);
     3135    LSpace::Tmp.m_size = 0x1000;
     3136    LSpace::Tmp.m_name = "temporary space";
     3137
     3138    LSpace::Perm.m_free = LSpace::Perm.m_data = (uint8_t *)malloc(0x1000);
     3139    LSpace::Perm.m_size = 0x1000;
     3140    LSpace::Perm.m_name = "permanent space";
     3141
     3142    LSpace::Gc.m_name = "garbage space";
     3143
     3144    LSpace::Current = &LSpace::Perm;
    31493145
    31503146    l_comp_init();
     
    31533149                         sys_funcs[i].min_args, sys_funcs[i].max_args, i);
    31543150    clisp_init();
    3155     current_space = TMP_SPACE;
     3151    LSpace::Current = &LSpace::Tmp;
    31563152    dprintf("Lisp: %d symbols defined, %d system functions, "
    31573153            "%d pre-compiled functions\n", LSymbol::count,
     
    31593155}
    31603156
    3161 void lisp_uninit()
    3162 {
    3163     free(space[0]);
    3164     free(space[1]);
     3157void Lisp::Uninit()
     3158{
     3159    free(LSpace::Tmp.m_data);
     3160    free(LSpace::Perm.m_data);
    31653161    DeleteAllSymbols(LSymbol::root);
    31663162    LSymbol::root = NULL;
     
    31683164}
    31693165
    3170 void clear_tmp()
    3171 {
    3172     free_space[TMP_SPACE] = space[TMP_SPACE];
     3166void LSpace::Clear()
     3167{
     3168    m_free = m_data;
    31733169}
    31743170
  • abuse/trunk/src/lisp/lisp.h

    r560 r635  
    2121#define Cell void
    2222#define MAX_LISP_TOKEN_LEN 200
    23 enum { PERM_SPACE,
    24        TMP_SPACE,
    25        USER_SPACE,
    26        GC_SPACE };
    2723
    2824#define FIXED_TRIG_SIZE 360               // 360 degrees stored in table
     
    3329#define DEFINEDP(x) (x!=l_undefined)
    3430class bFILE;
    35 extern int current_space;
    3631extern bFILE *current_print_file;
    3732
     
    4540typedef uint32_t ltype;    // make sure structures aren't packed differently on various compiler
    4641                       // and sure that word, etc are word aligned
     42
     43class Lisp
     44{
     45public:
     46    static void Init();
     47    static void Uninit();
     48};
     49
     50struct LSpace
     51{
     52    size_t GetFree();
     53    void *Alloc(size_t size);
     54
     55    void *Mark();
     56    void Restore(void *val);
     57    void Clear();
     58
     59    static LSpace Tmp, Perm, Gc;
     60    static LSpace *Current;
     61
     62    uint8_t *m_data;
     63    uint8_t *m_free;
     64    char const *m_name;
     65    size_t m_size;
     66};
    4767
    4868struct LObject
     
    206226void perm_space();
    207227void tmp_space();
    208 void use_user_space(void *addr, long size);
    209228void *lpointer_value(void *lpointer);
    210229int32_t lnumber_value(void *lnumber);
     
    239258
    240259int end_of_program(char *s);
    241 void clear_tmp();
    242260void lisp_init();
    243261void lisp_uninit();
    244262
    245 extern uint8_t *space[4], *free_space[4];
    246 extern size_t space_size[4];
    247263void *nth(int num, void *list);
    248264int32_t lisp_atan2(int32_t dy, int32_t dx);
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r630 r635  
    205205}
    206206
    207 void LispGC::CollectSpace(int which_space, int grow)
    208 {
    209     int old_space = current_space;
    210     cstart = space[which_space];
    211     cend = free_space[which_space];
    212 
    213     space_size[GC_SPACE] = space_size[which_space];
     207void LispGC::CollectSpace(LSpace *which_space, int grow)
     208{
     209    LSpace *old_space = LSpace::Current;
     210    cstart = which_space->m_data;
     211    cend = which_space->m_free;
     212
     213    LSpace::Gc.m_size = which_space->m_size;
    214214    if (grow)
    215215    {
    216         space_size[GC_SPACE] += space_size[which_space] >> 1;
    217         space_size[GC_SPACE] -= (space_size[GC_SPACE] & 7);
    218     }
    219     uint8_t *new_space = (uint8_t *)malloc(space_size[GC_SPACE]);
    220     current_space = GC_SPACE;
    221     free_space[GC_SPACE] = space[GC_SPACE] = new_space;
    222 
    223     collected_start = new_space;
    224     collected_end = new_space + space_size[GC_SPACE];
     216        LSpace::Gc.m_size += which_space->m_size >> 1;
     217        LSpace::Gc.m_size -= (LSpace::Gc.m_size & 7);
     218    }
     219    uint8_t *new_data = (uint8_t *)malloc(LSpace::Gc.m_size);
     220    LSpace::Current = &LSpace::Gc;
     221    LSpace::Gc.m_free = LSpace::Gc.m_data = new_data;
     222
     223    collected_start = new_data;
     224    collected_end = new_data + LSpace::Gc.m_size;
    225225
    226226    CollectSymbols(LSymbol::root);
     
    228228
    229229    // for debuging clear it out
    230     memset(space[which_space], 0, space_size[which_space]);
    231     free(space[which_space]);
    232 
    233     space[which_space] = new_space;
    234     space_size[which_space] = space_size[GC_SPACE];
    235     free_space[which_space] = new_space
    236                             + (free_space[GC_SPACE] - space[GC_SPACE]);
    237     current_space = old_space;
    238 }
    239 
     230    memset(which_space->m_data, 0, which_space->m_size);
     231    free(which_space->m_data);
     232
     233    which_space->m_data = new_data;
     234    which_space->m_size = LSpace::Gc.m_size;
     235    which_space->m_free = new_data + (LSpace::Gc.m_free - LSpace::Gc.m_data);
     236    LSpace::Current = old_space;
     237}
     238
  • abuse/trunk/src/lisp/lisp_gc.h

    r561 r635  
    2020public:
    2121    // Collect temporary or permanent spaces
    22     static void CollectSpace(int which_space, int grow);
     22    static void CollectSpace(LSpace *which_space, int grow);
    2323
    2424private:
  • abuse/trunk/src/loader2.cpp

    r579 r635  
    361361  }
    362362  compiled_init();
    363   clear_tmp();
     363  LSpace::Tmp.Clear();
    364364
    365365  dprintf("Engine : Registering base graphics\n");
  • abuse/trunk/src/menu.cpp

    r590 r635  
    389389  if (!DEFINEDP(ss->GetValue()))
    390390  {
    391     int sp=current_space;
    392     current_space=PERM_SPACE;
     391    LSpace *sp = LSpace::Current;
     392    LSpace::Current = &LSpace::Perm;
    393393//    char *prog="((\"art/help.spe\" . \"sell2\")(\"art/help.spe\" . \"sell4\")(\"art/help.spe\" . \"sell3\")(\"art/fore/endgame.spe\" . \"credit\"))";
    394394//    char *prog="((\"art/fore/endgame.spe\" . \"credit\") (\"art/help.spe\" . \"sell6\"))";
    395395    char const *prog = "((\"art/fore/endgame.spe\" . \"credit\"))";
    396396    ss->SetValue(LObject::Compile(prog));
    397     current_space=sp;
     397    LSpace::Current = sp;
    398398  }
    399399
  • abuse/trunk/src/objects.cpp

    r555 r635  
    261261    current_object=this;
    262262
    263     void *m=mark_heap(TMP_SPACE);
     263    void *m = LSpace::Tmp.Mark();
    264264    ((LSymbol *)ns)->EvalFunction(NULL);
    265     restore_heap(m,TMP_SPACE);
     265    LSpace::Tmp.Restore(m);
    266266
    267267    current_object=o;
     
    275275    {
    276276        current_object = this;
    277         void *m = mark_heap( TMP_SPACE );
     277        void *m = LSpace::Tmp.Mark();
    278278        ((LSymbol *)ns)->EvalFunction(NULL);
    279         restore_heap( m, TMP_SPACE );
     279        LSpace::Tmp.Restore(m);
    280280    }
    281281    else
     
    410410
    411411    current_object=this;
    412     void *m=mark_heap(TMP_SPACE);
     412    void *m = LSpace::Tmp.Mark();
    413413
    414414    time_marker *prof1=NULL;
     
    424424    }
    425425
    426     restore_heap(m,TMP_SPACE);
     426    LSpace::Tmp.Restore(m);
    427427
    428428    if (keep_ai_info())
     
    484484    current_object = this;
    485485
    486     void *m = mark_heap(TMP_SPACE);
     486    void *m = LSpace::Tmp.Mark();
    487487
    488488    am = LList::Create();
     
    528528    }
    529529
    530     restore_heap(m, TMP_SPACE);
     530    LSpace::Tmp.Restore(m);
    531531
    532532    current_object = o;
     
    624624    current_object=this;
    625625
    626     void *m=mark_heap(TMP_SPACE);
     626    void *m = LSpace::Tmp.Mark();
    627627    time_marker *prof1=NULL;
    628628    if (profiling())
     
    637637    }
    638638
    639 
    640 
    641     restore_heap(m,TMP_SPACE);
     639    LSpace::Tmp.Restore(m);
    642640
    643641  } else drawer();
     
    651649    current_object=this;
    652650
    653     void *m=mark_heap(TMP_SPACE);
     651    void *m = LSpace::Tmp.Mark();
    654652    time_marker *prof1=NULL;
    655653    if (profiling())
     
    664662    }
    665663
    666     restore_heap(m,TMP_SPACE);
    667 
     664    LSpace::Tmp.Restore(m);
    668665  }
    669666}
     
    11571154    current_object=g;
    11581155
    1159     void *m=mark_heap(TMP_SPACE);
     1156    void *m = LSpace::Tmp.Mark();
    11601157
    11611158    time_marker *prof1=NULL;
     
    11711168    }
    11721169
    1173 
    1174 
    1175     restore_heap(m,TMP_SPACE);
    1176 
    1177     current_object=o;
     1170    LSpace::Tmp.Restore(m);
     1171    current_object = o;
    11781172  }
    11791173  return g;
     
    12221216    lcy->cdr = lb;
    12231217
    1224     void *m = mark_heap(TMP_SPACE);
     1218    void *m = LSpace::Tmp.Mark();
    12251219
    12261220    time_marker *prof1 = NULL;
     
    12361230    }
    12371231
    1238     restore_heap(m,TMP_SPACE);
     1232    LSpace::Tmp.Restore(m);
    12391233
    12401234    if (item_type(r)!=L_NUMBER)
     
    16261620    current_object=this;
    16271621
    1628     void *m=mark_heap(TMP_SPACE);
     1622    void *m = LSpace::Tmp.Mark();
    16291623
    16301624    time_marker *prof1=NULL;
     
    16401634    }
    16411635
    1642 
    1643     restore_heap(m,TMP_SPACE);
    1644 
    1645     current_object=o;
    1646   }
    1647 }
     1636    LSpace::Tmp.Restore(m);
     1637    current_object = o;
     1638  }
     1639}
  • abuse/trunk/src/particle.cpp

    r555 r635  
    7272    exit(0);
    7373  }
    74   int sp=current_space;
    75   current_space=PERM_SPACE;
     74  LSpace *sp = LSpace::Current;
     75  LSpace::Current = &LSpace::Perm;
    7676  sym->SetNumber(total_pseqs); // set the symbol value to the object number
    77   current_space=sp;
     77  LSpace::Current = sp;
    7878  pseqs=(part_sequence **)realloc(pseqs,sizeof(part_sequence *)*(total_pseqs+1));
    7979
  • abuse/trunk/src/view.cpp

    r555 r635  
    473473      current_object=focus;
    474474
    475       void *m=mark_heap(TMP_SPACE);
     475      void *m = LSpace::Tmp.Mark();
    476476      void *list=NULL;
    477477      push_onto_list(LString::Create(chat_buf),list);
    478478      ((LSymbol *)l_chat_input)->EvalFunction(list);
    479       restore_heap(m,TMP_SPACE);
     479      LSpace::Tmp.Restore(m);
    480480
    481481      current_object=o;
Note: See TracChangeset for help on using the changeset viewer.