Kiwi Script
KiwiScript Interpreter
 All Data Structures Files Functions Variables Typedefs Enumerations Macros
KSExpression.h
Go to the documentation of this file.
1 
8 #ifndef KSEXPRESSION_H
9 #define KSEXPRESSION_H
10 
11 #include <KiwiEngine/KiwiEngine.h>
12 #include "KSForwarders.h"
13 
15 struct KSExpression {
17  struct KEObject superClass ;
19  struct KEFrame * resultType ;
21  struct KELineInfo * lineInfo ;
22 } ;
23 
25 typedef void (*KSAcceptExpressionVisitorFuncRef)(const struct KSExpressionVisitor * visitor, struct KSExpression * exp, void * userinfo) ;
26 
30  struct KEObjectMethods superClass ;
33 } ;
34 
43 struct KSExpression *
44 KSAllocateExpression(size_t size, const struct KSExpressionMethods * methods, struct KELineInfo * linfo, struct CNResource * resource) ;
45 
52 static inline void
53 KSDeallocateExpression(struct KSExpression * dst)
54 {
55  if(dst->resultType){
56  KEReleaseFrame(dst->resultType) ;
57  }
58 }
59 
64 static inline void
65 KSRetainExpression(struct KSExpression * dst)
66 {
67  KERetainObject(&(dst->superClass)) ;
68 }
69 
74 static inline void
75 KSReleaseExpression(struct KSExpression * dst)
76 {
77  KEReleaseObject(&(dst->superClass)) ;
78 }
79 
85 static inline void
86 KSSetResultTypeToExpression(struct KSExpression * dst, struct KEFrame * type)
87 {
88  KERetainFrame(type) ;
89  if(dst->resultType){
90  KEReleaseFrame(dst->resultType) ;
91  }
92  dst->resultType = type ;
93 }
94 
100 static inline const struct KSExpressionMethods *
101 KSMethodsOfExpression(const struct KSExpression * src)
102 {
103  return (const struct KSExpressionMethods *) KEMethodsOfObject(&(src->superClass)) ;
104 }
105 
110 static inline struct KEFrame *
111 KSResultTypeOfExpression(struct KSExpression * src)
112 {
113  return src->resultType ;
114 }
115 
116 static inline void
117 KSAcceptExpressionVisitor(struct KSExpression * exp, const struct KSExpressionVisitor * visitor, void * userinfo)
118 {
119  const struct KSExpressionMethods * methods = KSMethodsOfExpression(exp) ;
121  (*accfunc)(visitor, exp, userinfo) ;
122 }
123 
124 #endif /* KSEXPRESSION_H */
struct KEObjectMethods superClass
Definition: KSExpression.h:30
Definition: KSExpression.h:15
Definition: KSExpressionVisitor.h:14
struct KEFrame * resultType
Definition: KSExpression.h:19
struct KELineInfo * lineInfo
Definition: KSExpression.h:21
void(* KSAcceptExpressionVisitorFuncRef)(const struct KSExpressionVisitor *visitor, struct KSExpression *exp, void *userinfo)
Definition: KSExpression.h:25
struct KEObject superClass
Definition: KSExpression.h:17
KSAcceptExpressionVisitorFuncRef acceptVisitorFunc
Definition: KSExpression.h:32
Definition: KSExpression.h:28
struct KSExpression * KSAllocateExpression(size_t size, const struct KSExpressionMethods *methods, struct KELineInfo *linfo, struct CNResource *resource)
Allocate expression.
Forward declarations for the KiwiScript.