mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 21:02:50 +00:00
75ec6bf244
This is a nasty commit, sorry, but 99% of the commit is interdependent.
45 lines
1,022 B
R
45 lines
1,022 B
R
#include "Lambda.h"
|
|
#include "Nil.h"
|
|
#include "Symbol.h"
|
|
#include "string.h"
|
|
#include "Cons.h"
|
|
#include "defs.h"
|
|
#include "Error.h"
|
|
#include "Machine.h"
|
|
|
|
@implementation Lambda
|
|
+ (id) newWithCode: (CompiledCode []) c environment: (Frame []) e
|
|
{
|
|
return [[self alloc] initWithCode: c environment: e];
|
|
}
|
|
|
|
- (id) initWithCode: (CompiledCode []) c environment: (Frame []) e
|
|
{
|
|
self = [super init];
|
|
code = c;
|
|
env = e;
|
|
return self;
|
|
}
|
|
|
|
- (void) invokeOnMachine: (Machine []) m
|
|
{
|
|
[super invokeOnMachine: m];
|
|
if (length([m stack]) < [code minimumArguments]) {
|
|
[m value: [Error type: "call"
|
|
message: sprintf("expected at least %i arguments, received %i",
|
|
[code minimumArguments], length([m stack]))
|
|
by: m]];
|
|
return;
|
|
}
|
|
[m loadCode: code];
|
|
[m environment: env];
|
|
[m procedure: self];
|
|
}
|
|
|
|
- (void) markReachable
|
|
{
|
|
[env mark];
|
|
[code mark];
|
|
}
|
|
|
|
@end
|