summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 20:07:03 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 20:07:03 +0200
commitd41a82c4e21ba8e65432a1c0364b524e2b1896a1 (patch)
tree8a91902425bfa19270f61047d8a544e38d87e08e
parentaab0da6f05ab8f962b8b7c096c7a5c132dbdbff6 (diff)
Interpreter: Add special operator IN-PACKAGE.
-rw-r--r--MLKInterpreter.m14
-rw-r--r--MLKPackage.m1
2 files changed, 15 insertions, 0 deletions
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index 778985f..37d4523 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -42,6 +42,7 @@
static MLKPackage *cl;
static MLKPackage *sys;
static MLKSymbol *IF;
+static MLKSymbol *IN_PACKAGE;
static MLKSymbol *DECLARE;
static MLKSymbol *PROGN;
static MLKSymbol *TAGBODY;
@@ -72,6 +73,7 @@ static MLKSymbol *_LAMBDA;
sys = [MLKPackage findPackage:@"TOILET-SYSTEM"];
IF = [cl intern:@"IF"];
+ IN_PACKAGE = [cl intern:@"IN-PACKAGE"];
DECLARE = [cl intern:@"DECLARE"];
PROGN = [cl intern:@"PROGN"];
TAGBODY = [cl intern:@"TAGBODY"];
@@ -208,6 +210,18 @@ static MLKSymbol *_LAMBDA;
inLexicalContext:context
withEnvironment:lexenv];
}
+ else if (car == IN_PACKAGE)
+ {
+ id cadr = [[program cdr] car];
+ id package = [MLKPackage findPackage:stringify(cadr)];
+
+ [[MLKDynamicContext currentContext]
+ setValue:package
+ forSymbol:[[MLKPackage findPackage:@"COMMON-LISP"]
+ intern:@"*PACKAGE*"]];
+
+ return [NSArray arrayWithObject:nullify(package)];
+ }
else if (car == _LAMBDA)
{
// A bare-bones LAMBDA without a real lambda list. What
diff --git a/MLKPackage.m b/MLKPackage.m
index fb5ab20..568dfd3 100644
--- a/MLKPackage.m
+++ b/MLKPackage.m
@@ -63,6 +63,7 @@ static NSMutableDictionary *packages = nil;
[cl export:nil];
[cl export:[cl intern:@"T"]];
[cl export:[cl intern:@"IF"]];
+ [cl export:[cl intern:@"IN-PACKAGE"]];
[cl export:[cl intern:@"LET"]];
[cl export:[cl intern:@"LAMBDA"]];
[cl export:[cl intern:@"FUNCALL"]];