7 #ifndef __evaluator_Evaluator_h__ 8 #define __evaluator_Evaluator_h__ 15 class Debug :
public Counted
23 virtual ~Debug(
void) {}
24 void push(
void) { m_pushed =
true; m_depth++; }
25 void pop(
void) { m_depth--; }
26 void log(
const char *a_group,
const char *fmt, ...)
29 std::string group = a_group;
33 for(
unsigned int i = 1; i < m_depth; i++)
62 feLogGroup(a_group,
"%s%s\n", prefix.c_str(), str.c_str());
69 class FE_DL_EXPORT AsVariable :
71 public Initialize<AsVariable>
76 add(value, FE_SPEC(
"eval:value",
"evaluate real"));
78 Accessor<t_eval_real> value;
81 class FE_DL_EXPORT AsString :
83 public Initialize<AsString>
88 add(value, FE_SPEC(
"eval:string",
"evaluate string"));
90 Accessor<String> value;
94 class FE_DL_EXPORT RealFunction :
95 virtual public FunctionI,
96 public Initialize<RealFunction>
102 ~RealFunction(
void) {}
104 void initialize(
void);
106 virtual bool compile(sp<RecordGroup> a_rg, Record &a_return, t_stdvector<WeakRecord> &a_argv, t_stdstring &a_msg);
107 virtual sp<Aggregate> &returnType(
void) {
return m_aggregate; }
109 sp<AsVariable> m_asVariable;
110 sp<Aggregate> m_aggregate;
115 typedef Registry::FactoryLocation *t_factory_location;
123 Token(
const t_stdstring &a_str,
unsigned int a_line)
128 operator t_stdstring &()
132 const char *c_str(
void)
134 return m_str.c_str();
140 typedef Token t_token;
142 class Node :
public Counted
148 void compile(t_stdlist<t_token> &a_tokens,
149 Evaluator *a_evaluator,
153 void preEvaluate(Evaluator *a_evaluator, sp<Debug> a_debug);
154 void evaluate(sp<t_variables> &a_variables);
155 Record &value(
void) {
return m_value; }
157 virtual sp<Aggregate> &returnType(
void) {
return m_aggregate; }
159 t_stdvector< sp<Node> > m_children;
165 sp<FunctionI> m_function;
166 t_stdvector< WeakRecord > m_argv;
168 sp< Aggregate > m_aggregate;
173 sp<Node> m_jump_node;
179 e_eval_assign_matched,
180 e_eval_assign_mismatch,
190 void leafMake(Evaluator *a_evaluator, sp<Node> a_node);
200 typedef JumpLocation t_jump_location;
202 class FE_DL_EXPORT Evaluator :
203 virtual public EvaluatorI,
204 public Initialize<Evaluator>
208 virtual ~Evaluator(
void);
210 void initialize(
void);
212 virtual void bind(sp<RecordGroup> a_rg);
215 virtual void compile(
const t_stdstring &a_buffer);
216 virtual void evaluate(
void);
218 virtual void addFunction(
const t_stdstring &a_function,
219 const t_stdstring &a_component);
220 virtual sp<FunctionI> createFunction(
const t_stdstring &a_function);
223 virtual unsigned int index(
const t_stdstring &a_name);
224 virtual const Record &variable(
unsigned int a_index)
225 {
return m_variables->m_varray[a_index]; }
226 virtual const sp< Aggregate > &aggregate(
unsigned int a_index)
227 {
return m_aggregates[a_index]; }
228 virtual void assignVariable(
unsigned int a_index,
230 sp< Aggregate > a_aggregate)
232 m_variables->m_varray[a_index] = a_record;
233 m_aggregates[a_index] = a_aggregate;
235 virtual void makeVariable(Node *a_node);
236 virtual t_variables &variables(
void) {
return *m_variables; }
238 virtual Record create(
const t_stdstring &a_name,
239 sp< AccessorSet > a_spSA);
243 Record createRecord(sp<Layout> a_layout);
246 void tokenize(t_stdlist<t_token> &a_tokens,
const t_stdstring &a_buffer);
249 sp<t_variables> m_variables;
250 t_stdvector< sp< Aggregate > > m_aggregates;
251 t_stdvector< sp<Node> > m_nodes;
252 t_stdmap<t_stdstring, t_factory_location> m_factory_locations;
253 t_stdmap<t_stdstring, unsigned int> m_var_names;
254 unsigned int m_output_index;
259 sp< Aggregate > m_stringAggregate;
260 sp< Aggregate > m_literalAggregate;
262 t_stdmap<t_stdstring, t_jump_location > m_jump_locations;
267 sp< Aggregate > &literalAggregate(
void) {
return m_literalAggregate; }
268 sp< Aggregate > &stringAggregate(
void) {
return m_stringAggregate; }
271 class FE_DL_EXPORT EvaluatorLog :
public AnnotatedLog
274 EvaluatorLog(
void) {}
275 virtual ~EvaluatorLog(
void) {}
277 using AnnotatedLog::log;
279 virtual void log(
const std::string &a_message,
280 std::map<std::string,std::string> &a_attributes);
kernel
Definition: namespace.dox:3
void vsPrintf(std::string &target, const char *fmt, va_list ap, int &size)
Format text into a fe::String.
Definition: debug.cc:252