summaryrefslogtreecommitdiff
path: root/MLKSymbol.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 20:35:48 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 20:35:48 +0200
commitc1e2a414b56ffd61d03cdfb0eedb7752083ea0c8 (patch)
treeb8ff5f5858b1904eea30ba43a719ca88e0bd6655 /MLKSymbol.m
parent85c76a3866597bfed2280aba4834edbce0765800 (diff)
When printing a symbol, omit the package prefix as appropriate.
Diffstat (limited to 'MLKSymbol.m')
-rw-r--r--MLKSymbol.m33
1 files changed, 32 insertions, 1 deletions
diff --git a/MLKSymbol.m b/MLKSymbol.m
index 02cd728..36b6359 100644
--- a/MLKSymbol.m
+++ b/MLKSymbol.m
@@ -16,9 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#import "MLKDynamicContext.h"
+#import "MLKPackage.h"
#import "MLKSymbol.h"
#import "runtime-compatibility.h"
+#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
@@ -69,7 +72,35 @@
// NOTE: Need to take *PRINT-GENSYM* into account.
//
// FIXME: This is wrong in more than one way.
- return [NSString stringWithFormat:@"|%@|::|%@|", [homePackage name], name];
+ MLKPackage *currentPackage =
+ [[MLKDynamicContext currentContext]
+ valueForSymbol:[[MLKPackage findPackage:@"COMMON-LISP"]
+ intern:@"*PACKAGE*"]];
+ BOOL accessible;
+ NSString *packagePrefix;
+
+ NS_DURING
+ {
+ if ([currentPackage findSymbol:name] == self)
+ accessible = YES;
+ else
+ accessible = NO;
+ }
+ NS_HANDLER
+ {
+ if ([[localException name] isEqualToString:@"MLKNoSuchSymbolError"])
+ accessible = NO;
+ else
+ [localException raise];
+ }
+ NS_ENDHANDLER;
+
+ if (accessible)
+ packagePrefix = [NSString string];
+ else
+ packagePrefix = [NSString stringWithFormat:@"|%@|::", [homePackage name]];
+
+ return [NSString stringWithFormat:@"%@|%@|", packagePrefix, name];
}
-(NSString *) description