#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

#import <math.h>

#import "SchemeTypes.h"
#import "EnvWindow.h"

#define PRIM_CLASS_PREF @"PRM"

BOOL isBoolean(id item);
BOOL isChar(id item);
BOOL isInt(id item);
BOOL isDouble(id item);
BOOL isSymbol(id item);
BOOL isString(id item);
BOOL isPair(id item);
BOOL isVector(id item);
BOOL isTriple(id item);
BOOL isPrimitive(id item);
BOOL isEval(id item);
BOOL isClosure(id item);
BOOL isThunk(id item);
BOOL isFalse(id item);

BOOL isEqual(id itema, id itemb);

typedef enum {
    NT_INTEGERS,
    NT_DOUBLE,
    NT_OTHER
} NUMTYPE;

@interface Primitive : SCMType
{
    id value;
    NSString *errmsg;
}

- init;

- (NUMTYPE)checkArgsNumeric:(NSMutableArray *)args offset:(int)offs;

- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;

- (NSString *)primName;
- value;
- errmsg;

@end

@interface PRMVectorPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMPairPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNullPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMZeroPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNumberPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMEqPred : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNot : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNumEqual : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNumLT : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNumGT : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMPlus : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMTimes : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMMinus : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDivide : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMRandom : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMQuotient : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMRemainder : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMList : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMCons : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMCar : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMCdr : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMSetCar : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMSetCdr : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDisplay : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNewline : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawMove : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawLine : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawColor : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawCircle : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMFillCircle : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawRect : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMFillRect : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawFont : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawString : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMDrawShow : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMSin : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMCos : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMTan : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMExp : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMLog : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMATan : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMASin : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMACos : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMSqrt : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMMakeVector : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMListToVector : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMVectorToList : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMVectorLength : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMVectorRef : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMVectorSet : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMVectorFill : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMSymToStr : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStrToSym : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStringSize : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStringLength : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMCharToInt : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMIntToChar : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStringRef : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMListToStr : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStrToList : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMStringAppend : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMMakeString : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMNumberToStr : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMFormat : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMBrowseEnvironment : Primitive
- (NSString *)primName;
- (BOOL)evalVM:(id)vm Args:(NSMutableArray *)args offset:(int)offs;
@end

@interface PRMEval : Primitive
- (NSString *)primName;
@end
