Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 219 lines (167 sloc) 8.294 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218

//metadoc Message copyright Steve Dekorte 2002
//metadoc Message license BSD revised

#ifndef IOMESSAGE_DEFINED
#define IOMESSAGE_DEFINED 1

#include "IoVMApi.h"
#include "Common.h"
#include "List.h"
#include "UArray.h"
#include "IoTag.h"
#include "IoObject_struct.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MESSAGE_STOP_STATUS_NORMAL 0
#define MESSAGE_STOP_STATUS_BREAK 1
#define MESSAGE_STOP_STATUS_CONTINUE 2
#define MESSAGE_STOP_STATUS_RETURN 4
#define MESSAGE_STOP_STATUS_EOL 8

#define ISMESSAGE(self) IoObject_hasCloneFunc_(self, (IoTagCloneFunc *)IoMessage_rawClone)

#if !defined(IoSymbol_DEFINED)
#define IoSymbol_DEFINED
typedef IoObject IoSymbol;
#endif

typedef IoObject IoMessage;

#define IOMESSAGE_HASPREV

typedef struct
{
IoSymbol *name;
List *args;
#ifdef IOMESSAGE_HASPREV
IoMessage *previous; // unused for now
#endif
IoMessage *next;
IoObject *cachedResult;

// debugging info
//int charNumber;
int lineNumber;
IoSymbol *label;
} IoMessageData;

#define IOMESSAGEDATA(self) ((IoMessageData *)IoObject_dataPointer(self))

// basics

IOVM_API IoMessage *IoMessage_proto(void *state);
IOVM_API IoMessage *IoMessage_rawClone(IoMessage *m);
IOVM_API IoMessage *IoMessage_new(void *state);
IOVM_API void IoMessage_copy_(IoMessage *self, IoMessage *other);
IOVM_API IoMessage *IoMessage_deepCopyOf_(IoMessage *m);
IOVM_API IoMessage *IoMessage_newWithName_(void *state, IoSymbol *symbol);
IOVM_API IoMessage *IoMessage_newWithName_label_(void *state, IoSymbol *symbol, IoSymbol *label);
IOVM_API IoMessage *IoMessage_newWithName_returnsValue_(void *state, IoSymbol *symbol, IoObject *v);
IOVM_API IoMessage *IoMessage_newWithName_andCachedArg_(void *state, IoSymbol *symbol, IoObject *v);

IOVM_API void IoMessage_mark(IoMessage *self);
IOVM_API void IoMessage_free(IoMessage *self);

IOVM_API IoSymbol *IoMessage_rawLabel(IoMessage *self);
IOVM_API int IoMessage_rawLineNumber(IoMessage *self);
IOVM_API int IoMessage_rawCharNumber(IoMessage *self);
IOVM_API void IoMessage_label_(IoMessage *self, IoSymbol *ioSymbol); // sets label for children too
IOVM_API void IoMessage_rawSetLineNumber_(IoMessage *self, int n);
IOVM_API void IoMessage_rawSetCharNumber_(IoMessage *self, int n);
IOVM_API void IoMessage_rawCopySourceLocation(IoMessage *self, IoMessage *other);
IOVM_API List *IoMessage_rawArgList(IoMessage *self);
IOVM_API unsigned char IoMessage_needsEvaluation(IoMessage *self);

IOVM_API void IoMessage_addCachedArg_(IoMessage *self, IoObject *v);
IOVM_API void IoMessage_setCachedArg_to_(IoMessage *self, int n, IoObject *v);
IOVM_API void IoMessage_setCachedArg_toInt_(IoMessage *self, int n, int anInt);
IOVM_API void IoMessage_rawSetCachedResult_(IoMessage *self, IoObject *v);
IOVM_API void IoMessage_rawSetName_(IoMessage *self, IoObject *v);
IOVM_API void IoMessage_rawSetLabel_(IoMessage *self, IoObject *v);


IOVM_API IO_METHOD(IoMessage, lineNumber);
IOVM_API IO_METHOD(IoMessage, characterNumber);
IOVM_API IO_METHOD(IoMessage, label);

// perform

IOVM_API IO_METHOD(IoMessage, doInContext);
IOVM_API IoObject *IoMessage_locals_performOn_(IoMessage *self, IoObject *locals, IoObject *target);

// args

//IOVM_API IoObject *IoMessage_locals_valueArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_valueOrEvalArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API void IoMessage_assertArgCount_receiver_(IoMessage *self, int n, IoObject *receiver);
IOVM_API int IoMessage_argCount(IoMessage *self);

IOVM_API void IoMessage_locals_numberArgAt_errorForType_(
  IoMessage *self,
  IoObject *locals,
  int n,
  const char *typeName);

IOVM_API IoObject *IoMessage_locals_numberArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API int IoMessage_locals_intArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API int IoMessage_locals_boolArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API long IoMessage_locals_longArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API size_t IoMessage_locals_sizetArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API double IoMessage_locals_doubleArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API float IoMessage_locals_floatArgAt_(IoMessage *self, IoObject *locals, int n);

IOVM_API IoObject *IoMessage_locals_symbolArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_seqArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_mutableSeqArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API char *IoMessage_locals_cStringArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_valueAsStringArgAt_(IoMessage *self, IoObject *locals, int n);

IOVM_API IoObject *IoMessage_locals_blockArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_dateArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_mapArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_messageArgAt_(IoMessage *self, IoObject *locals, int n);
IOVM_API IoObject *IoMessage_locals_listArgAt_(IoMessage *self, IoObject *locals, int n);

// printing

IOVM_API void IoMessage_print(IoMessage *self);
IOVM_API void IoMessage_printWithReturn(IoMessage *self);
IOVM_API UArray *IoMessage_description(IoMessage *self);
IOVM_API UArray *IoMessage_descriptionJustSelfAndArgs(IoMessage *self); /* caller must io_free returned */
IOVM_API void IoMessage_appendDescriptionTo_follow_(IoMessage *self, UArray *ba, int follow);
IOVM_API IO_METHOD(IoMessage, asString);

// primitive methods

IOVM_API IO_METHOD(IoMessage, clone);
IOVM_API IO_METHOD(IoMessage, protoName);
IOVM_API IO_METHOD(IoMessage, protoSetName);
IOVM_API IO_METHOD(IoMessage, descriptionString);

// next

IOVM_API IO_METHOD(IoMessage, next);
IOVM_API IoMessage *IoMessage_rawNext(IoMessage *self);

IOVM_API IO_METHOD(IoMessage, setNext);
IOVM_API void IoMessage_rawSetNext_(IoMessage *self, IoMessage *m);

IOVM_API IO_METHOD(IoMessage, isEOL);
IOVM_API int IoMessage_rawIsEOL(IoMessage *self);

IOVM_API IO_METHOD(IoMessage, nextIgnoreEOLs);
IOVM_API IoMessage *IoMessage_rawNextIgnoreEOLs(IoMessage *self);
IOVM_API IO_METHOD(IoMessage, last);
IOVM_API IoMessage *IoMessage_rawLast(IoMessage *self);
IOVM_API IO_METHOD(IoMessage, lastBeforeEOL);
IOVM_API IoMessage *IoMessage_rawLastBeforeEOL(IoMessage *self);

// previous

IOVM_API IO_METHOD(IoMessage, previous);
IOVM_API IoMessage *IoMessage_rawPrevious(IoMessage *self);

IOVM_API IO_METHOD(IoMessage, setPrevious);
IOVM_API void IoMessage_rawSetPrevious(IoMessage *self, IoMessage *m);

IOVM_API IO_METHOD(IoMessage, argAt);
IOVM_API IO_METHOD(IoMessage, arguments);
IOVM_API IO_METHOD(IoMessage, setArguments);
IOVM_API IO_METHOD(IoMessage, appendArg);
IOVM_API IO_METHOD(IoMessage, appendCachedArg);
IOVM_API IO_METHOD(IoMessage, argCount_);
IOVM_API IO_METHOD(IoMessage, cachedResult);
IOVM_API IO_METHOD(IoMessage, setCachedResult);
IOVM_API IO_METHOD(IoMessage, removeCachedResult);
IOVM_API IO_METHOD(IoMessage, hasCachedResult);

IOVM_API IO_METHOD(IoMessage, setLineNumber);
IOVM_API IO_METHOD(IoMessage, setCharacterNumber);
IOVM_API IO_METHOD(IoMessage, setLabel);

IOVM_API IO_METHOD(IoMessage, fromString);
IOVM_API IO_METHOD(IoMessage, argsEvaluatedIn);
IOVM_API IO_METHOD(IoMessage, evaluatedArgs);
IOVM_API IO_METHOD(IoMessage, profilerTime);

IOVM_API void IoMessage_foreachArgs(IoMessage *self,
IoObject *object,
IoSymbol **indexSlotName,
IoSymbol **valueSlotName,
IoMessage **doMessage);

IOVM_API IoMessage *IoMessage_asMessageWithEvaluatedArgs(IoMessage *self, IoObject *locals, IoMessage *m);

// ------------------------------

#include "IoMessage_inline.h"
#include "IoMessage_parser.h"

//IoSymbol *IoMessage_name(IoMessage *self);

#define IoMessage_name(self) (((IoMessageData *)IoObject_dataPointer(self))->name)
#define IoMessage_rawCachedResult(self) (((IoMessageData *)IoObject_dataPointer(self))->cachedResult)

IOVM_API void IoMessage_addArg_(IoMessage *self, IoMessage *m);
IOVM_API IoMessage *IoMessage_rawArgAt_(IoMessage *self, int n);
IOVM_API List *IoMessage_rawArgs(IoMessage *self);

IOVM_API UArray *IoMessage_asMinimalStackEntryDescription(IoMessage *self);

#ifdef __cplusplus
}
#endif
#endif
Something went wrong with that request. Please try again.