2002-05-13 22:13:06 +00:00
|
|
|
/**
|
|
|
|
STBlockContext.m
|
|
|
|
|
|
|
|
Copyright (c) 2002 Free Software Foundation
|
|
|
|
|
|
|
|
This file is part of the StepTalk project.
|
|
|
|
|
2004-04-25 18:18:17 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
2002-05-13 22:13:06 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2004-04-25 18:18:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-05-13 22:13:06 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "STBlockContext.h"
|
|
|
|
|
|
|
|
#import "STStack.h"
|
|
|
|
#import "STBytecodeInterpreter.h"
|
|
|
|
#import "STBytecodes.h"
|
|
|
|
#import "STMethodContext.h"
|
|
|
|
|
|
|
|
#import <StepTalk/STExterns.h>
|
|
|
|
|
|
|
|
#import <Foundation/NSDebug.h>
|
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
@implementation STBlockContext
|
2014-10-14 20:13:09 +00:00
|
|
|
- initWithInitialIP:(NSUInteger)pointer
|
2013-05-26 15:51:26 +00:00
|
|
|
stackSize:(NSUInteger)size
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
2013-03-23 18:09:25 +00:00
|
|
|
if ((self = [super initWithStackSize:size]) != nil)
|
|
|
|
{
|
|
|
|
initialIP = pointer;
|
2002-05-13 22:13:06 +00:00
|
|
|
|
2013-03-23 18:09:25 +00:00
|
|
|
instructionPointer = initialIP;
|
|
|
|
}
|
2003-04-06 12:59:13 +00:00
|
|
|
return self;
|
2002-05-13 22:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isBlockContext
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
- (void)setHomeContext:(STMethodContext *)context
|
|
|
|
{
|
|
|
|
ASSIGN(homeContext,context);
|
|
|
|
}
|
|
|
|
- (STMethodContext *)homeContext
|
|
|
|
{
|
|
|
|
return homeContext;
|
|
|
|
}
|
|
|
|
|
2013-05-26 15:51:26 +00:00
|
|
|
- (NSUInteger)initialIP
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
|
|
|
return initialIP;
|
|
|
|
}
|
|
|
|
|
2013-05-26 15:51:26 +00:00
|
|
|
- temporaryAtIndex:(NSUInteger)index;
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
|
|
|
return [homeContext temporaryAtIndex:index];
|
|
|
|
}
|
2013-05-26 15:51:26 +00:00
|
|
|
- (void)setTemporary:anObject atIndex:(NSUInteger)index;
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
|
|
|
[homeContext setTemporary:anObject atIndex:index];
|
|
|
|
}
|
|
|
|
|
2013-05-26 15:51:26 +00:00
|
|
|
- (NSString *)referenceNameAtIndex:(NSUInteger)index
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
2005-06-20 20:40:47 +00:00
|
|
|
return [homeContext referenceNameAtIndex:index];
|
2002-05-13 22:13:06 +00:00
|
|
|
}
|
|
|
|
- (STBytecodes *)bytecodes
|
|
|
|
{
|
|
|
|
return [homeContext bytecodes];
|
|
|
|
}
|
2013-05-26 15:51:26 +00:00
|
|
|
- (id)literalObjectAtIndex:(NSUInteger)index
|
2002-05-13 22:13:06 +00:00
|
|
|
{
|
2002-09-17 12:40:41 +00:00
|
|
|
return [homeContext literalObjectAtIndex:index];
|
2002-06-14 08:35:11 +00:00
|
|
|
}
|
|
|
|
- (id)receiver
|
|
|
|
{
|
|
|
|
return [homeContext receiver];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resetInstructionPointer
|
|
|
|
{
|
2003-04-06 12:59:13 +00:00
|
|
|
instructionPointer = initialIP;
|
2002-05-13 22:13:06 +00:00
|
|
|
}
|
|
|
|
@end
|