mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-21 02:31:01 +00:00
Follow Smalltalk convention to return the receiver from a method
without an explicit return statement. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@36421 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fd46046983
commit
1fc2e5fb63
2 changed files with 21 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-03-24 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* STCompiler.m (-compileMethod:): Follow Smalltalk convention to
|
||||
return the receiver from a method without an explicit return
|
||||
statement.
|
||||
|
||||
2013-03-24 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* STExecutionContext.h: Change type of instruction pointer attribute
|
||||
|
|
|
@ -327,11 +327,20 @@ extern int STCparse(void *context);
|
|||
/* FIXME: unite STCMessage and STMessage */
|
||||
messagePattern = (STMessage *)[method messagePattern];
|
||||
|
||||
if(!messagePattern)
|
||||
if (!messagePattern)
|
||||
{
|
||||
messagePattern = [STMessage messageWithSelector:@"_unnamed_method"
|
||||
arguments:nil];
|
||||
}
|
||||
else if (![[method statements] returnExpression])
|
||||
{
|
||||
/* A Smalltalk method (but not plain code) without a return expression
|
||||
returns the receiver itself. */
|
||||
STCPrimary *selfPrimary = [STCPrimary primaryWithVariable:@"self"];
|
||||
STCExpression *returnExpression =
|
||||
[STCExpression primaryExpressionWithObject:selfPrimary];
|
||||
[[method statements] setReturnExpression:returnExpression];
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STCompiler", @"Compile method %@", [messagePattern selector]);
|
||||
|
||||
|
@ -342,16 +351,16 @@ extern int STCparse(void *context);
|
|||
compiledMethod = [STCompiledMethod methodWithCode:code
|
||||
messagePattern:messagePattern];
|
||||
|
||||
if(!isSingleMethod)
|
||||
if (!isSingleMethod)
|
||||
{
|
||||
|
||||
if(resultMethod)
|
||||
if (resultMethod)
|
||||
{
|
||||
[NSException raise:@"STCompilerException"
|
||||
format:@"Method is present when compiling a script"];
|
||||
return;
|
||||
}
|
||||
if(!resultScript)
|
||||
if (!resultScript)
|
||||
{
|
||||
NSDebugLLog(@"STCompiler",
|
||||
@"Creating script with %i variables",[receiverVars count]);
|
||||
|
@ -363,13 +372,13 @@ extern int STCparse(void *context);
|
|||
}
|
||||
else
|
||||
{
|
||||
if(resultMethod)
|
||||
if (resultMethod)
|
||||
{
|
||||
[NSException raise:@"STCompilerException"
|
||||
format:@"More than one method compiled for single method request"];
|
||||
return;
|
||||
}
|
||||
if(resultScript)
|
||||
if (resultScript)
|
||||
{
|
||||
[NSException raise:@"STCompilerException"
|
||||
format:@"Compiled script is present when compiling single method"];
|
||||
|
|
Loading…
Reference in a new issue