Om
quote_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_QuoteOperation_
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(QuoteOperationTest)
34 
35  BOOST_AUTO_TEST_CASE(DefinitionTest) {
36  BOOST_CHECK_EQUAL(
37  "{quote}",
38  System::Get().Evaluate("drop find {quote} system")
39  );
40  }
41 
42  BOOST_AUTO_TEST_CASE(SimpleTest) {
43  BOOST_CHECK_EQUAL(
44  "{{1{2}3}}",
45  System::Get().Evaluate("quote {1{2}3}")
46  );
47  }
48 
49  BOOST_AUTO_TEST_SUITE_END()
50 
51  }
52 
53  }
54 
55 }
56 
57  #endif
58 
59 #else
60 
61  #include "om/language/literal.hpp"
62 
63 // MARK: - Om::Language::Operation::QuoteOperation
64 
65  #define Type_ \
66  Om::Language::Operation::QuoteOperation
67 
68 // MARK: public (static)
69 
70 inline char const * Type_::GetName() {
72 }
73 
74 template <typename TheQuoteOperation>
75 inline void Type_::GiveElements(
76  TheQuoteOperation &,
77  Consumer & theConsumer
78 ) {
79  theConsumer.TakeElement(
80  GetOperator()
81  );
82 }
83 
84 // MARK: public (non-static)
85 
86 template <typename TheOperand>
87 inline bool Type_::TakeOperand(
88  Evaluation & theEvaluation,
89  TheOperand & theOperand
90 ) {
91  assert(
92  !theOperand.IsEmpty()
93  );
94  theEvaluation.TakeQuotedProducer(theOperand);
95  return true;
96 }
97 
98 template <typename TheProducer>
99 inline bool Type_::TakeQuotedProducer(
100  Evaluation & theEvaluation,
101  TheProducer & theProducer
102 ) {
103  Operand theOperand(
104  theProducer.GiveProgram()
105  );
106  theEvaluation.TakeQuotedProducer(theOperand);
107  return true;
108 }
109 
110  #undef Type_
111 
112 #endif
static System & Get()
Om header file.
The Om library.
Definition: code_point.hpp:26
Om header file.
#define Om_Language_Operation_QuoteOperation_GetName_()