summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKInterpreter.m18
-rw-r--r--MLKReader.m7
-rw-r--r--MLKRoot.m18
-rw-r--r--util.h23
4 files changed, 28 insertions, 38 deletions
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index 730aaa9..e03df1d 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -29,6 +29,7 @@
#import "MLKRoot.h"
#import "MLKSymbol.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSArray.h>
#import <Foundation/NSException.h>
@@ -36,23 +37,6 @@
#import <Foundation/NSString.h>
-static id nullify (id value)
-{
- if (value)
- return value;
- else
- return [NSNull null];
-}
-
-static id denullify (id value)
-{
- if (value == [NSNull null])
- return nil;
- else
- return value;
-}
-
-
static MLKPackage *cl;
static MLKPackage *sys;
static MLKSymbol *IF;
diff --git a/MLKReader.m b/MLKReader.m
index f957c4d..4acf24e 100644
--- a/MLKReader.m
+++ b/MLKReader.m
@@ -31,6 +31,7 @@
#import "MLKRatio.h"
#import "MLKStringInputStream.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSArray.h>
#import <Foundation/NSRange.h>
@@ -69,7 +70,7 @@
ch = [stream readChar];
if ([readtable isWhitespaceCharacter:ch] || ch == '\0')
goto start;
-
+
if ([readtable isMacroCharacter:ch])
{
NSArray *returnValues;
@@ -87,9 +88,7 @@
}
returnValues = [macrofun applyToArray:args];
if ([returnValues count])
- return ([returnValues objectAtIndex:0] == [NSNull null]
- ? nil
- : [returnValues objectAtIndex:0]);
+ return denullify ([returnValues objectAtIndex:0]);
else
goto start;
}
diff --git a/MLKRoot.m b/MLKRoot.m
index c30a043..cafafe1 100644
--- a/MLKRoot.m
+++ b/MLKRoot.m
@@ -26,6 +26,7 @@
#import "MLKSingleFloat.h"
#import "MLKDoubleFloat.h"
#import "runtime-compatibility.h"
+#import "util.h"
#import <Foundation/NSArray.h>
#import <Foundation/NSException.h>
@@ -36,23 +37,6 @@
#import <Foundation/NSString.h>
-static id nullify (id value)
-{
- if (value)
- return value;
- else
- return [NSNull null];
-}
-
-static id denullify (id value)
-{
- if (value == [NSNull null])
- return nil;
- else
- return value;
-}
-
-
static NSMethodSignature *signature;
static MLKPackage *sys;
static MLKPackage *cl;
diff --git a/util.h b/util.h
index 7a73d22..71dc3d6 100644
--- a/util.h
+++ b/util.h
@@ -1,3 +1,6 @@
+#include "runtime-compatibility.h"
+#include <Foundation/NSNull.h>
+
#define DEFINE_GMP_OPERATION(SIGNATURE, TYPE, GMPOP, OBJTYPE, CONSTRUCTOR) \
-(OBJTYPE *) SIGNATURE \
{ \
@@ -11,3 +14,23 @@
\
return result; \
}
+
+
+static id nullify (id value) __attribute__ ((pure, unused));
+static id denullify (id value) __attribute__ ((pure, unused));
+
+static id nullify (id value)
+{
+ if (value)
+ return value;
+ else
+ return [NSNull null];
+}
+
+static id denullify (id value)
+{
+ if (value == [NSNull null])
+ return nil;
+ else
+ return value;
+}