quakeforge/ruamoko/scheme/Primitive.r

33 lines
590 B
R
Raw Permalink Normal View History

#include "Primitive.h"
#include "Machine.h"
#include "Continuation.h"
@implementation Primitive
+ (id) newFromFunc: (primfunc_t) f
{
return [[self alloc] initWithFunc: f];
}
- (id) initWithFunc: (primfunc_t) f
{
self = [super init];
func = f;
return self;
}
2011-02-14 13:39:43 +00:00
- (SchemeObject*) invokeOnMachine: (Machine*) m
{
2011-02-14 13:39:43 +00:00
local SchemeObject *value = func ([m stack], m);
[super invokeOnMachine: m];
if (value) {
[m value: value];
[[m continuation] restoreOnMachine: m];
}
2011-02-14 13:39:43 +00:00
return value;
}
- (string) printForm
{
return "<primitive>";
}
@end