Om
evaluate_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_EvaluateOperation_
16 
18 
19  #ifdef Om_Macro_Test_
20 
21  #ifndef Om_Macro_Precompilation_
22 
23  #include "boost/test/unit_test.hpp"
24 
25  #endif
26 
27 namespace Om {
28 
29  namespace Language {
30 
31  namespace Operation {
32 
33  BOOST_AUTO_TEST_SUITE(EvaluateOperationTest)
34 
35  BOOST_AUTO_TEST_CASE(DefinitionTest) {
36  BOOST_CHECK_EQUAL(
37  "{evaluate}",
38  System::Get().Evaluate("drop find {evaluate} system")
39  );
40  }
41 
42  BOOST_AUTO_TEST_CASE(BasicTest) {
43  BOOST_CHECK_EQUAL(
44  "{{A}{A}}",
45  System::Get().Evaluate("evaluate {copy {A}}")
46  );
47  }
48 
49  BOOST_AUTO_TEST_SUITE_END()
50 
51  }
52 
53  }
54 
55 }
56 
57  #endif
58 
59 #else
60 
62 
63 // MARK: - Om::Language::Operation::EvaluateOperation
64 
65  #define Type_ \
66  Om::Language::Operation::EvaluateOperation
67 
68 // MARK: public (static)
69 
70 inline char const * Type_::GetName() {
72 }
73 
74 template <typename TheEvaluateOperation>
75 inline void Type_::GiveElements(
76  TheEvaluateOperation &,
77  Consumer & theConsumer
78 ) {
79  theConsumer.TakeElement(
80  GetOperator()
81  );
82 }
83 
84 // MARK: public (non-static)
85 
86 inline Type_::EvaluateOperation() {}
87 
88 template <typename TheOperand>
89 inline bool Type_::TakeOperand(
90  Evaluation & theEvaluation,
91  TheOperand & theOperand
92 ) {
93  assert(
94  !theOperand.IsEmpty()
95  );
96  return this->TakeQuotedProducer(
97  theEvaluation,
98  *theOperand.GetProgram()
99  );
100 }
101 
102 template <typename TheProducer>
103 inline bool Type_::TakeQuotedProducer(
104  Evaluation & theEvaluation,
105  TheProducer & theProducer
106 ) {
107  Expression theExpression;
108  {
109  Evaluator theScope(
110  theExpression,
111  theEvaluation.GetTranslator()
112  );
113  theProducer.GiveElements(theScope);
114  }
115  theEvaluation.TakeQuotedProducer(theExpression);
116  return true;
117 }
118 
119  #undef Type_
120 
121 #endif
static System & Get()
Om header file.
Om header file.
#define Om_Language_Operation_EvaluateOperation_GetName_()
The Om library.
Definition: code_point.hpp:26