2005-05-01 11:48:36 +00:00
|
|
|
#include "Primitive.h"
|
|
|
|
#include "Machine.h"
|
2010-12-16 11:01:49 +00:00
|
|
|
#include "Continuation.h"
|
2005-05-01 11:48:36 +00:00
|
|
|
|
|
|
|
@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
|
2005-05-01 11:48:36 +00:00
|
|
|
{
|
2011-02-14 13:39:43 +00:00
|
|
|
local SchemeObject *value = func ([m stack], m);
|
2005-05-06 23:25:06 +00:00
|
|
|
[super invokeOnMachine: m];
|
|
|
|
if (value) {
|
|
|
|
[m value: value];
|
2005-05-08 03:44:18 +00:00
|
|
|
[[m continuation] restoreOnMachine: m];
|
2005-05-06 23:25:06 +00:00
|
|
|
}
|
2011-02-14 13:39:43 +00:00
|
|
|
return value;
|
2005-05-01 11:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (string) printForm
|
|
|
|
{
|
|
|
|
return "<primitive>";
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|