2005-05-01 11:48:36 +00:00
|
|
|
#include "Continuation.h"
|
2010-12-16 11:01:49 +00:00
|
|
|
#include "Machine.h"
|
|
|
|
#include "Cons.h"
|
2005-05-01 11:48:36 +00:00
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
@implementation Continuation
|
2011-03-25 07:46:32 +00:00
|
|
|
+ (id) newWithState: (state_t *) st pc: (int) p
|
2005-05-01 11:48:36 +00:00
|
|
|
{
|
2005-05-06 23:25:06 +00:00
|
|
|
return [[self alloc] initWithState: st pc: p];
|
2005-05-01 11:48:36 +00:00
|
|
|
}
|
2011-03-25 07:46:32 +00:00
|
|
|
- (id) initWithState: (state_t *) st pc: (int) p
|
2005-05-01 11:48:36 +00:00
|
|
|
{
|
|
|
|
self = [self init];
|
|
|
|
state.program = st.program;
|
|
|
|
state.pc = p;
|
|
|
|
state.literals = st.literals;
|
|
|
|
state.stack = st.stack;
|
2005-05-06 23:25:06 +00:00
|
|
|
state.cont = st.cont;
|
|
|
|
state.env = st.env;
|
2005-05-08 06:38:01 +00:00
|
|
|
state.proc = st.proc;
|
|
|
|
state.lineinfo = st.lineinfo;
|
2005-05-01 11:48:36 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-02-14 13:39:43 +00:00
|
|
|
- (void) restoreOnMachine: (Machine *) m
|
2005-05-08 03:44:18 +00:00
|
|
|
{
|
|
|
|
[m state: &state];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-14 13:39:43 +00:00
|
|
|
- (void) invokeOnMachine: (Machine *) m
|
2005-05-01 11:48:36 +00:00
|
|
|
{
|
2011-02-14 13:39:43 +00:00
|
|
|
[m value: [(Cons *) [m stack] car]];
|
2005-05-01 11:48:36 +00:00
|
|
|
[m state: &state];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-05-02 02:33:44 +00:00
|
|
|
- (void) markReachable
|
|
|
|
{
|
|
|
|
[state.literals mark];
|
|
|
|
[state.stack mark];
|
2005-05-06 23:25:06 +00:00
|
|
|
[state.cont mark];
|
|
|
|
[state.env mark];
|
|
|
|
[state.proc mark];
|
2005-05-02 02:33:44 +00:00
|
|
|
}
|
|
|
|
|
2005-05-01 11:48:36 +00:00
|
|
|
- (string) printForm
|
|
|
|
{
|
|
|
|
return "<continuation>";
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|