From d8d28d9eee279d0440408abb63f666bc7a63c79d Mon Sep 17 00:00:00 2001 From: Stefan Urbanek Date: Tue, 5 Aug 2003 20:23:47 +0000 Subject: [PATCH] Added empty implementation of script objects git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@17433 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 + Documentation/Reference/STObjCRuntime.html | 4 +- Languages/Smalltalk/ChangeLog | 7 +- Languages/Smalltalk/GNUmakefile | 2 +- Languages/Smalltalk/STBytecodeInterpreter.m | 6 +- Languages/Smalltalk/STCompiledScript.m | 6 +- ...riptObject.h => STSmalltalkScriptObject.h} | 4 +- Languages/Smalltalk/STSmalltalkScriptObject.m | 170 ++++++++++++++++++ Source/GNUmakefile | 4 + Source/Headers/StepTalk/STMethod.h | 11 ++ Source/Headers/StepTalk/STScriptObject.h | 28 +++ Source/STMethod.m | 18 ++ Source/STScriptObject.m | 59 ++++++ 13 files changed, 310 insertions(+), 13 deletions(-) rename Languages/Smalltalk/{STScriptObject.h => STSmalltalkScriptObject.h} (95%) create mode 100644 Languages/Smalltalk/STSmalltalkScriptObject.m create mode 100644 Source/Headers/StepTalk/STMethod.h create mode 100644 Source/Headers/StepTalk/STScriptObject.h create mode 100644 Source/STMethod.m create mode 100644 Source/STScriptObject.m diff --git a/ChangeLog b/ChangeLog index 50f1016..1df3297 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003 Aug 5 Stefan Urbanek + + * Added STScriptObject and STMethod. + 2003 Jun 15 * NSInvocation+additions: added unknown selector creation; created a diff --git a/Documentation/Reference/STObjCRuntime.html b/Documentation/Reference/STObjCRuntime.html index e7bab75..9c5280e 100644 --- a/Documentation/Reference/STObjCRuntime.html +++ b/Documentation/Reference/STObjCRuntime.html @@ -9,9 +9,7 @@

STObjCRuntime autogsdoc generated documentation

Authors

-
Stefan Urbanek( - urbanek@host.sk - )
+
Stefan Urbanek (urbanek@host.sk)
diff --git a/Languages/Smalltalk/ChangeLog b/Languages/Smalltalk/ChangeLog index 86b6ab7..f3a24f3 100644 --- a/Languages/Smalltalk/ChangeLog +++ b/Languages/Smalltalk/ChangeLog @@ -1,4 +1,9 @@ -2003 May 17 Stefan Urbanek +2003 Aug 5 Stefan Urbanek + + * STScriptObject renamed to STSmalltalkScriptObject, because of steptalk + core change. + +2003 May 17 Stefan Urbanek * STSourceReader: treat decimal point followed by whitespace as '.' dot - end of statement. diff --git a/Languages/Smalltalk/GNUmakefile b/Languages/Smalltalk/GNUmakefile index 3db502b..522fed7 100644 --- a/Languages/Smalltalk/GNUmakefile +++ b/Languages/Smalltalk/GNUmakefile @@ -45,7 +45,7 @@ Smalltalk_OBJC_FILES = \ STLiterals.m \ STMessage.m \ STMethodContext.m \ - STScriptObject.m \ + STSmalltalkScriptObject.m \ STStack.m \ STUndefinedObject+additions.m \ STSelector+additions.m \ diff --git a/Languages/Smalltalk/STBytecodeInterpreter.m b/Languages/Smalltalk/STBytecodeInterpreter.m index 52bd5f3..c681202 100644 --- a/Languages/Smalltalk/STBytecodeInterpreter.m +++ b/Languages/Smalltalk/STBytecodeInterpreter.m @@ -32,7 +32,7 @@ #import "STLiterals.h" #import "STMessage.h" #import "STMethodContext.h" -#import "STScriptObject.h" +#import "STSmalltalkScriptObject.h" #import "STStack.h" #import @@ -453,7 +453,7 @@ static Class NSInvocation_class = nil; break; case STPushRecVarBytecode: - object = [(STScriptObject *)receiver instanceVariableAtIndex: + object = [(STSmalltalkScriptObject *)receiver instanceVariableAtIndex: bytecode.arg1]; STDebugBytecodeWith(bytecode,object); STPush(stack,object); @@ -479,7 +479,7 @@ static Class NSInvocation_class = nil; case STPopAndStoreRecVarBytecode: STDebugBytecode(bytecode); - [(STScriptObject *)receiver setInstanceVariable:STPop(stack) + [(STSmalltalkScriptObject *)receiver setInstanceVariable:STPop(stack) atIndex:bytecode.arg1]; break; diff --git a/Languages/Smalltalk/STCompiledScript.m b/Languages/Smalltalk/STCompiledScript.m index 4ee446f..577d598 100644 --- a/Languages/Smalltalk/STCompiledScript.m +++ b/Languages/Smalltalk/STCompiledScript.m @@ -23,7 +23,7 @@ #import "STCompiledScript.h" -#import "STScriptObject.h" +#import "STSmalltalkScriptObject.h" #import "STCompiledMethod.h" #import @@ -92,12 +92,12 @@ static SEL finalizeSelector; - (id)executeInEnvironment:(STEnvironment *)env { - STScriptObject *object; + STSmalltalkScriptObject *object; int methodCount; id retval = nil; - object = [[STScriptObject alloc] initWithEnvironment:env + object = [[STSmalltalkScriptObject alloc] initWithEnvironment:env compiledScript:self]; methodCount = [methodDictionary count]; diff --git a/Languages/Smalltalk/STScriptObject.h b/Languages/Smalltalk/STSmalltalkScriptObject.h similarity index 95% rename from Languages/Smalltalk/STScriptObject.h rename to Languages/Smalltalk/STSmalltalkScriptObject.h index 2374b17..98e202e 100644 --- a/Languages/Smalltalk/STScriptObject.h +++ b/Languages/Smalltalk/STSmalltalkScriptObject.h @@ -1,5 +1,5 @@ /** - STScriptObject.h + STSmalltalkScriptObject.h Object that represents script Copyright (c) 2002 Free Software Foundation @@ -30,7 +30,7 @@ @class STCompiledScript; @class STEnvironment; -@interface STScriptObject:NSObject +@interface STSmalltalkScriptObject:NSObject { NSString *name; STBytecodeInterpreter *interpreter; diff --git a/Languages/Smalltalk/STSmalltalkScriptObject.m b/Languages/Smalltalk/STSmalltalkScriptObject.m new file mode 100644 index 0000000..f5594e5 --- /dev/null +++ b/Languages/Smalltalk/STSmalltalkScriptObject.m @@ -0,0 +1,170 @@ +/** + STSmalltalkScriptObject.m + Object that represents script + + Copyright (c) 2002 Free Software Foundation + + This file is part of the StepTalk project. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA. + + */ + +#import "STSmalltalkScriptObject.h" + +#import "STBytecodeInterpreter.h" +#import "STCompiledScript.h" + +#import +#import +#import +#import + +#import +#import +#import +#import + +@implementation STSmalltalkScriptObject +- initWithEnvironment:(STEnvironment *)env + compiledScript:(STCompiledScript *)compiledScript +{ + int count = [compiledScript variableCount]; + int i; + + [super init]; + + NSDebugLLog(@"STEngine", + @"creating script object %p with %i ivars",compiledScript, + count); + + environment = RETAIN(env); + script = RETAIN(compiledScript); + variables = [[NSMutableArray alloc] initWithCapacity:count]; + + for(i=0;i> forwarding to self ..."); + + retval = [interpreter interpretMethod:method + forReceiver:self + arguments:args]; + + NSDebugLLog(@"STSending", + @"<< returned from forwarding"); + + [invocation setReturnValue:&retval]; +} +@end diff --git a/Source/GNUmakefile b/Source/GNUmakefile index a7a9a16..f78f3d5 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -41,6 +41,8 @@ libStepTalk_OBJC_FILES = \ STScript.m \ STScriptsManager.m \ STScripting.m \ + STMethod.m \ + STScriptObject.m \ STSelector.m \ STStructure.m \ STUndefinedObject.m \ @@ -56,6 +58,8 @@ STEPTALK_HEADER_FILES = \ STLanguage.h \ STObjCRuntime.h \ STObjectReference.h \ + STMethod.h \ + STScriptObject.h \ STScript.h \ STScriptsManager.h \ STScripting.h \ diff --git a/Source/Headers/StepTalk/STMethod.h b/Source/Headers/StepTalk/STMethod.h new file mode 100644 index 0000000..fa13356 --- /dev/null +++ b/Source/Headers/StepTalk/STMethod.h @@ -0,0 +1,11 @@ +/* 2003 Aug 5 */ + +#import + +@class STEngine; + +@interface STMethod:NSObject +- (NSString *)source; +- (NSString *)methodName; +- (NSString *)languageName; +@end diff --git a/Source/Headers/StepTalk/STScriptObject.h b/Source/Headers/StepTalk/STScriptObject.h new file mode 100644 index 0000000..25a2edf --- /dev/null +++ b/Source/Headers/StepTalk/STScriptObject.h @@ -0,0 +1,28 @@ +/* 2003 Aug 5 */ + +#import + +@class NSMutableDictionary; +@class NSDictionary; +@class NSArray; +@class STMethod; + +@interface STScriptObject:NSObject +{ + NSMutableDictionary *ivars; + NSMutableDictionary *methods; +} +- initWithInstanceVariableNames:(NSString *)names; + +- (void)setObject:(id)anObject forVariable:(NSString *)aName; +- (id)objectForVariable:(NSString *)aName; + +- (NSArray *)instanceVariableNames; + +- (void)addMethod:(STMethod *)aMethod; +- (STMethod *)methodWithName:(NSString *)aName; +- (void)removeMethod:(STMethod *)aMethod; +- (void)removeMethodWithName:(NSString *)aName; +- (NSArray *)methodNames; +- (NSDictionary *)methodDictionary; +@end diff --git a/Source/STMethod.m b/Source/STMethod.m new file mode 100644 index 0000000..dd1c3cb --- /dev/null +++ b/Source/STMethod.m @@ -0,0 +1,18 @@ +/* 2003 Aug 5 */ + +#import + +@implementation STMethod +- (NSString *)source +{ + [self _notImplemented:_cmd]; +} +- (NSString *)methodName +{ + [self _notImplemented:_cmd]; +} +- (NSString *)languageName +{ + [self _notImplemented:_cmd]; +} +@end diff --git a/Source/STScriptObject.m b/Source/STScriptObject.m new file mode 100644 index 0000000..dfddbe2 --- /dev/null +++ b/Source/STScriptObject.m @@ -0,0 +1,59 @@ +/* 2003 Aug 5 */ + +#import "StepTalk/STScriptObject.h" + +@implementation STScriptObject +- initWithInstanceVariableNames:(NSString *)names +{ + self = [super init]; + + methods = [[NSMutableDictionary alloc] init]; + + return self; +} +- (void)dealloc +{ + RELEASE(methods); + RELEASE(ivars); + [super dealloc]; +} + +- (void)setObject:(id)anObject forVariable:(NSString *)aName +{ + [self _notImplemented:_cmd]; +} +- (id)objectForVariable:(NSString *)aName +{ + [self _notImplemented:_cmd]; +} + +- (NSArray *)instanceVariableNames +{ + [self _notImplemented:_cmd]; +} + +- (void)addMethod:(STMethod *)aMethod +{ + [methods setObject:aMethod forKey:[aMethod methodName]]; +} +- (STMethod *)methodWithName:(NSString *)aName +{ + return [methods objectForKey:aName]; +} +- (void)removeMethod:(STMethod *)aMethod +{ + [self _notImplemented:_cmd]; +} +- (void)removeMethodWithName:(NSString *)aName +{ + [methods removeObjectForKey:aName]; +} +- (NSArray *)methodNames +{ + return [methods allKeys]; +} +- (NSDictionary *)methodDictionary +{ + return [NSDictionary dictionaryWithDictionary:methods]; +} +@end