Kiwi Engine
VM for interpreter
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
KEError.h
Go to the documentation of this file.
1 
8 #ifndef KEERROR_H
9 #define KEERROR_H
10 
11 #include <Coconut/Coconut.h>
12 #include "KEForwarders.h"
13 #include "KEException.h"
14 #include "KEValue.h"
15 
17 typedef enum {
18  KEParserError,
19  KETooMaryRegisterError,
20  KEInvalidPathDescriptionError,
21  KENonexistentPathError,
22  KEInvalidValueTypeError,
23  KEIdentifierRequiredError,
24  KEMergeFailedError,
25  KEExceptionError
26 } KEErrorKind ;
27 
31 struct KEError {
33  struct CNObject superClass ;
37  struct KELineInfo * lineInfo ;
39  union {
40  struct {
41  struct CNString * errorMessage ;
42  } parseError ;
43  struct {
44  unsigned long numberOfRequiredRegisters ;
45  } tooMaryRegisterError ;
46  struct {
47  struct CNString * invalidPath ;
48  } invalidPathDescription ;
49  struct {
50  struct KEPath * path ;
51  } nonexistentPathError ;
52  struct {
53  const char * requiredType ;
54  const char * givenType ;
55  } invalidValueType ;
56  struct {
57  struct KEPath * invalidPath ;
58  } identifierRequired ;
59  struct {
60  const struct CNFixedString * conflictedIdentifier ;
61  } mergeFailed ;
62  struct {
63  struct KEException exception ;
64  } exceptionError ;
65  } ;
66 } ;
67 
75 struct KEError *
76 KEAllocateParserError(const char * msg, struct KELineInfo * linfo, struct CNResource * resource) ;
77 
85 struct KEError *
86 KEAllocateTooManyRegisterError(unsigned long regnum, struct KELineInfo * linfo, struct CNResource * resource) ;
87 
95 struct KEError *
96 KEAllocateInvalidPathDescriptionError(struct CNString * pathstr, struct KELineInfo * linfo, struct CNResource * resource) ;
97 
105 struct KEError *
106 KEAllocateNonexistentPathError(struct KEPath * path, struct KELineInfo * linfo, struct CNResource * resource) ;
107 
116 struct KEError *
117 KEAllocateInvalidValueTypeError(const char * reqtype,
118  const char * giventype,
119  struct KELineInfo * linfo,
120  struct CNResource * resource) ;
121 
129 struct KEError *
130 KEAllocateIdentifierRequiredError(struct KEPath * path, struct KELineInfo * linfo, struct CNResource * resource) ;
131 
139 struct KEError *
140 KEAllocateMergeFailedError(const struct CNFixedString * ident, struct KELineInfo * linfo, struct CNResource * resource) ;
141 
148 struct KEError *
149 KEAllocateExceptionError(const struct KEException * except, struct CNResource * resource) ;
150 
155 static inline void
156 KEReleaseError(struct KEError * dst)
157 {
158  CNReleaseObject(&(dst->superClass)) ;
159 }
160 
166 static inline struct CNObject *
167 KEObjectOfError(struct KEError * src)
168 {
169  return &(src->superClass) ;
170 }
171 
178 static inline struct KELineInfo *
179 KELineInfoInError(struct KEError * src)
180 {
181  return src->lineInfo ;
182 }
183 
189 void
190 KEPrintError(FILE * outfp, const struct KEError * src) ;
191 
192 #endif /* KEERROR_H */
KEProgram class.
Definition: KELineInfo.h:19
struct KEError * KEAllocateParserError(const char *msg, struct KELineInfo *linfo, struct CNResource *resource)
Allocate parse error object.
struct KEError * KEAllocateTooManyRegisterError(unsigned long regnum, struct KELineInfo *linfo, struct CNResource *resource)
Allocate Too many register error.
struct KEError * KEAllocateExceptionError(const struct KEException *except, struct CNResource *resource)
Allocate exception error.
Define KEValue data structure.
Exception information.
Definition: KEException.h:31
struct KEError * KEAllocateNonexistentPathError(struct KEPath *path, struct KELineInfo *linfo, struct CNResource *resource)
Allocate nonexistent path error.
void KEPrintError(FILE *outfp, const struct KEError *src)
Print parse error message to file stream.
struct KEError * KEAllocateMergeFailedError(const struct CNFixedString *ident, struct KELineInfo *linfo, struct CNResource *resource)
Allocate merge failed error.
KEErrorKind errorKind
Definition: KEError.h:35
Instruction class.
Definition: KEError.h:31
Define KEException data structure.
KEErrorKind
Definition: KEError.h:17
Forward declarations of the data type in KiwiEngine.
struct KELineInfo * lineInfo
Definition: KEError.h:37
Definition: KEPath.h:16
struct KEError * KEAllocateIdentifierRequiredError(struct KEPath *path, struct KELineInfo *linfo, struct CNResource *resource)
Allocate identifier required error.
struct CNObject superClass
Definition: KEError.h:33
struct KEError * KEAllocateInvalidPathDescriptionError(struct CNString *pathstr, struct KELineInfo *linfo, struct CNResource *resource)
Allocate invalid path description error.
struct KEError * KEAllocateInvalidValueTypeError(const char *reqtype, const char *giventype, struct KELineInfo *linfo, struct CNResource *resource)
Allocate invalid value type error.