Kiwi Engine
VM for interpreter
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
KEValueTable.h
Go to the documentation of this file.
1 
8 #ifndef KEVALUETABLE_H
9 #define KEVALUETABLE_H
10 
11 #include <Coconut/Coconut.h>
12 #include "KEValue.h"
13 
17 struct KEValueTable {
19  struct CNObject superClass ;
21  uint64_t valueNum ;
23  struct KEValue valueArray[1] ;
24 } ;
25 
32 struct KEValueTable *
33 KEAllocateValueTable(uint64_t varnum, struct CNResource * resource) ;
34 
40 static inline uint64_t
41 KECapacityOfValueTable(uint64_t valnum)
42 {
43  uint64_t rnum = (valnum + 64 - 1) / 64 ;
44  return rnum * 64 ;
45 }
46 
51 static inline void
52 KERetainValueTable(struct KEValueTable * dst)
53 {
54  CNRetainObject(&(dst->superClass)) ;
55 }
56 
61 static inline void
62 KEReleaseValueTable(struct KEValueTable * dst)
63 {
64  CNReleaseObject(&(dst->superClass)) ;
65 }
66 
72 static inline struct CNObject *
73 KEObjectOfValueTable(struct KEValueTable * src)
74 {
75  return &(src->superClass) ;
76 }
77 
82 void
83 KECleanValueTable(struct KEValueTable * dst) ;
84 
90 static inline uint64_t
91 KENumberOfValuesInTable(const struct KEValueTable * src)
92 {
93  return src->valueNum ;
94 }
95 
102 static inline void
103 KESetValueToTable(struct KEValueTable * dst, uint64_t index, const struct KEValue * src)
104 {
105  struct KEValue * dstval = &(dst->valueArray[index]) ;
106  KEUpdateValue(dstval, src) ;
107 }
108 
115 static inline struct KEValue *
116 KEValueInTable(struct KEValueTable * table, uint64_t index)
117 {
118  return &(table->valueArray[index]) ;
119 }
120 
126 void
127 KEDumpValueTable(struct CNText * outbuf, const struct KEValueTable * src) ;
128 
129 #endif /* KEVALUETABLE_H */
Define KEValue data structure.
uint64_t valueNum
Definition: KEValueTable.h:21
KEProgram class.
Definition: KEValueTable.h:17
struct KEValueTable * KEAllocateValueTable(uint64_t varnum, struct CNResource *resource)
Allocate value table.
void KECleanValueTable(struct KEValueTable *dst)
Release resources for each values in the table.
Definition: KEValue.h:40
void KEDumpValueTable(struct CNText *outbuf, const struct KEValueTable *src)
Dump value table into buffer.
struct KEValue valueArray[1]
Definition: KEValueTable.h:23
struct CNObject superClass
Definition: KEValueTable.h:19