Cons now allocates String objects when outputting string form. Added

support for begin expressions and tweaked the GC to be more aggressive.
This commit is contained in:
Brian Koropoff 2005-05-08 11:17:44 +00:00
parent 111df712fa
commit ed0b29a0a0
3 changed files with 9 additions and 5 deletions

View file

@ -11,6 +11,7 @@ Symbol quoteSym;
Symbol defineSym;
Symbol ifSym;
Symbol letrecSym;
Symbol beginSym;
@implementation Compiler
+ (void) initialize
@ -25,6 +26,8 @@ Symbol letrecSym;
[ifSym retain];
letrecSym = symbol("letrec");
[letrecSym retain];
beginSym = symbol("begin");
[beginSym retain];
}
+ (id) newWithLambda: (SchemeObject) xp scope: (Scope) sc
@ -236,6 +239,8 @@ Symbol letrecSym;
[self emitIf: [expression cdr] flags: fl];
} else if ([expression car] == letrecSym) {
[self emitLetrec: [expression cdr] flags: fl];
} else if ([expression car] == beginSym) {
[self emitSequence: [expression cdr] flags: fl];
} else {
[self emitApply: expression flags: fl];
}

View file

@ -2,6 +2,7 @@
#include "Cons.h"
#include "Nil.h"
#include "defs.h"
#include "SchemeString.h"
Cons cons (SchemeObject car, SchemeObject cdr)
{
@ -75,7 +76,7 @@ BOOL isList (SchemeObject ls)
- (string) printForm
{
local string acc = "", res;
local string acc = "";
local id cur, next = NIL;
for (cur = self; cur; cur = next) {
@ -91,9 +92,7 @@ BOOL isList (SchemeObject ls)
}
}
res = str_new();
str_copy(res, sprintf("(%s)", acc));
return res;
return [[String newFromString: sprintf("(%s)", acc)] stringValue];
}
@end

View file

@ -14,7 +14,7 @@ typedef enum {
gc_state_e gc_state;
integer checkpoint;
#define GC_AMOUNT 200
#define GC_AMOUNT 100
@implementation SchemeObject