85 #include "structure_member.h"
91 StructureMember::StructureMember() {
94 StructureMember::StructureMember(_Read r,
97 Iteration i) : read_(r),
102 if (read_ == &Compiler::read_any) type_ = ANY;
103 else if (read_ == &Compiler::read_number) type_ = NUMBER;
104 else if (read_ == &Compiler::read_timestamp) type_ = TIMESTAMP;
105 else if (read_ == &Compiler::read_duration) type_ = DURATION;
106 else if (read_ == &Compiler::read_boolean) type_ = BOOLEAN;
107 else if (read_ == &Compiler::read_string) type_ = STRING;
108 else if (read_ == &Compiler::read_node) type_ = NODE_ID;
109 else if (read_ == &Compiler::read_device) type_ = DEVICE_ID;
110 else if (read_ == &Compiler::read_function) type_ = FUNCTION_ID;
111 else if (read_ == &Compiler::read_expression) type_ = ANY;
112 else if (read_ == &Compiler::read_set) type_ = ReturnType::SET;
113 else if (read_ == &Compiler::read_class) type_ = ReturnType::CLASS;
116 Class *StructureMember::get_class(Metadata *metadata)
const {
118 return class_ ==
"" ? NULL : &metadata->classes_.find(class_)->second;
121 ReturnType StructureMember::get_return_type()
const {
126 bool StructureMember::used_as_expression()
const {
128 return iteration_ == I_EXPRESSION;
131 StructureMember::Iteration StructureMember::getIteration()
const {
136 _Read StructureMember::read()
const {
141 void StructureMember::write(word32 *storage)
const {
143 if (read_ == &Compiler::read_any)
145 else if (read_ == &Compiler::read_number)
146 storage[0] = R_NUMBER;
147 else if (read_ == &Compiler::read_timestamp)
148 storage[0] = R_TIMESTAMP;
149 else if (read_ == &Compiler::read_duration)
150 storage[0] = R_DURATION;
151 else if (read_ == &Compiler::read_boolean)
152 storage[0] = R_BOOLEAN;
153 else if (read_ == &Compiler::read_string)
154 storage[0] = R_STRING;
155 else if (read_ == &Compiler::read_node)
157 else if (read_ == &Compiler::read_device)
158 storage[0] = R_DEVICE;
159 else if (read_ == &Compiler::read_function)
160 storage[0] = R_FUNCTION;
161 else if (read_ == &Compiler::read_expression)
162 storage[0] = R_EXPRESSION;
163 else if (read_ == &Compiler::read_set)
165 else if (read_ == &Compiler::read_class)
166 storage[0] = R_CLASS;
168 storage[offset++] = type_;
169 r_code::Write(storage + offset, class_);
170 offset += r_code::GetSize(class_);
171 storage[offset++] = iteration_;
172 r_code::Write(storage + offset, name_);
175 void StructureMember::read(word32 *storage) {
177 switch (storage[0]) {
178 case R_ANY: read_ = &Compiler::read_any;
break;
179 case R_NUMBER: read_ = &Compiler::read_number;
break;
180 case R_TIMESTAMP: read_ = &Compiler::read_timestamp;
break;
181 case R_DURATION: read_ = &Compiler::read_duration;
break;
182 case R_BOOLEAN: read_ = &Compiler::read_boolean;
break;
183 case R_STRING: read_ = &Compiler::read_string;
break;
184 case R_NODE: read_ = &Compiler::read_node;
break;
185 case R_DEVICE: read_ = &Compiler::read_device;
break;
186 case R_FUNCTION: read_ = &Compiler::read_function;
break;
187 case R_EXPRESSION: read_ = &Compiler::read_expression;
break;
188 case R_SET: read_ = &Compiler::read_set;
break;
189 case R_CLASS: read_ = &Compiler::read_class;
break;
192 type_ = (ReturnType)storage[offset++];
193 r_code::Read(storage + offset, class_);
194 offset += r_code::GetSize(class_);
195 iteration_ = (Iteration)storage[offset++];
196 r_code::Read(storage + offset, name_);
199 uint32 StructureMember::get_size() {
202 size += r_code::GetSize(class_);
203 size += r_code::GetSize(name_);