91 #include "out_stream.h"
93 #include "../r_code/image.h"
100 std::istream *in_stream_;
105 Class current_class_;
107 uint32 current_object_index_;
108 int32 current_view_index_;
115 State() : indents(0),
116 right_indents_ahead(0),
117 left_indents_ahead(0),
119 no_arity_check(
false) {}
120 State(
Compiler *c) : indents(c->state_.indents),
121 right_indents_ahead(c->state_.right_indents_ahead),
122 left_indents_ahead(c->state_.left_indents_ahead),
123 pattern_lvl(c->state_.pattern_lvl),
124 no_arity_check(c->state_.no_arity_check),
125 stream_ptr(c->in_stream_->tellg()) {}
127 uint16 right_indents_ahead;
128 uint16 left_indents_ahead;
131 std::streampos stream_ptr;
136 void restore_state(State s);
138 void set_error(
const std::string &s);
139 void set_arity_error(uint16 expected, uint16 got);
141 std::unordered_map<std::string, Reference> local_references_;
142 std::unordered_map<std::string, Reference> global_references_;
143 void addLocalReference(
const std::string reference_name,
const uint16 index,
const Class &p);
144 bool getGlobalReferenceIndex(
const std::string reference_name,
const ReturnType t,
r_code::ImageObject *
object, uint16 &index,
Class *&_class);
147 bool allow_variables_and_wildcards_outside_pattern_skeleton_;
148 std::vector<std::string> hlp_references_;
149 uint8 add_hlp_reference(std::string reference_name);
150 uint8 get_hlp_reference(std::string reference_name);
153 bool read_nil(uint16 write_index, uint16 &extent_index,
bool write);
154 bool read_nil_set(uint16 write_index, uint16 &extent_index,
bool write);
155 bool read_nil_nb(uint16 write_index, uint16 &extent_index,
bool write);
156 bool read_nil_ts(uint16 write_index, uint16 &extent_index,
bool write);
157 bool read_forever_nb(uint16 write_index, uint16 &extent_index,
bool write);
158 bool read_nil_nid(uint16 write_index, uint16 &extent_index,
bool write);
159 bool read_nil_did(uint16 write_index, uint16 &extent_index,
bool write);
160 bool read_nil_fid(uint16 write_index, uint16 &extent_index,
bool write);
161 bool read_nil_bl(uint16 write_index, uint16 &extent_index,
bool write);
162 bool read_nil_st(uint16 write_index, uint16 &extent_index,
bool write);
163 bool read_variable(uint16 write_index, uint16 &extent_index,
bool write,
const Class p);
164 bool read_reference(uint16 write_index, uint16 &extent_index,
bool write,
const ReturnType t);
165 bool read_wildcard(uint16 write_index, uint16 &extent_index,
bool write);
166 bool read_tail_wildcard(uint16 write_index, uint16 &extent_index,
bool write);
173 bool separator(
bool pushback);
174 bool right_indent(
bool pushback);
175 bool left_indent(
bool pushback);
176 bool indent(
bool pushback);
177 bool expression_begin(
bool &indented);
178 bool expression_end(
bool indented);
179 bool set_begin(
bool &indented);
180 bool set_end(
bool indented);
181 bool symbol_expr(std::string &s);
182 bool symbol_expr_set(std::string &s);
183 bool match_symbol_separator(
const char *symbol,
bool pushback);
184 bool match_symbol(
const char *symbol,
bool pushback);
185 bool member(std::string &s);
201 bool label(std::string &l);
202 bool variable(std::string &v);
204 bool local_reference(uint16 &index,
const ReturnType t);
205 bool global_reference(uint16 &index,
const ReturnType t);
206 bool hlp_reference(uint16 &index);
207 bool this_indirection(std::vector<int16> &v,
const ReturnType t);
208 bool local_indirection(std::vector<int16> &v,
const ReturnType t, uint16 &cast_opcode);
209 bool global_indirection(std::vector<int16> &v,
const ReturnType t);
211 bool tail_wildcard();
217 bool duration(int64 &result);
225 bool timestamp_s_ms_us(int64 &ts);
226 bool str(std::string &s);
227 bool number(float32 &n);
229 bool boolean(
bool &b);
230 bool object(
Class &p);
231 bool object(
const Class &p);
232 bool sys_object(
Class &p);
233 bool sys_object(
const Class &p);
234 bool marker(
Class &p);
235 bool op(
Class &p,
const ReturnType t);
236 bool op(
const Class &p);
237 bool function(
Class &p);
238 bool expression_head(
Class &p,
const ReturnType t);
239 bool expression_head(
const Class &p);
240 bool expression_tail(
bool indented,
const Class &p, uint16 write_index, uint16 &extent_index,
bool write);
243 bool expression(
bool &indented,
const ReturnType t, uint16 write_index, uint16 &extent_index,
bool write);
244 bool expression(
bool &indented,
const Class &p, uint16 write_index, uint16 &extent_index,
bool write);
245 bool set(
bool &indented, uint16 write_index, uint16 &extent_index,
bool write);
246 bool set(
bool &indented,
const Class &p, uint16 write_index, uint16 &extent_index,
bool write);
248 uint8 set_element_count(
bool indented);
249 bool read(
const StructureMember &m,
bool &indented,
bool enforce, uint16 write_index, uint16 &extent_index,
bool write);
253 bool read_sys_object();
264 Compiler(
bool allow_variables_and_wildcards_outside_pattern_skeleton =
false);
267 bool compile(std::istream *stream,
281 bool read_any(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
282 bool read_number(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
283 bool read_timestamp(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
284 bool read_duration(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
285 bool read_boolean(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
286 bool read_string(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
287 bool read_node(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
288 bool read_device(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
289 bool read_function(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
290 bool read_expression(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
291 bool read_set(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
292 bool read_class(
bool &indented,
bool enforce,
const Class *p, uint16 write_index, uint16 &extent_index,
bool write);
295 std::string getObjectName(
const uint16 index)
const;