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