Om
encode_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_EncodeOperation_
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(EncodeOperationTest)
36 
37  BOOST_AUTO_TEST_CASE(DefinitionTest) {
38  BOOST_CHECK_EQUAL(
39  "{encode}",
40  System::Get().Evaluate("drop find {encode} system")
41  );
42  }
43 
44  BOOST_AUTO_TEST_CASE(SimpleTest) {
45  BOOST_CHECK_EQUAL(
46  "{```{```}``` `{`{`}`}` }",
47  System::Get().Evaluate("encode {`{`}` {{}} }")
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::EncodeOperation
66 
67  #define Type_ \
68  Om::Language::Operation::EncodeOperation
69 
70 // MARK: public (static)
71 
72 inline char const * Type_::GetName() {
74 }
75 
76 template <typename TheEncodeOperation>
77 inline void Type_::GiveElements(
78  TheEncodeOperation &,
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  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  Operator theOperator;
108  theOperator.Encode(theProducer);
109  theEvaluation.TakeQuotedProducer(theOperator);
110  return true;
111 }
112 
113  #undef Type_
114 
115 #endif
static System & Get()
Om header file.
#define Om_Language_Operation_EncodeOperation_GetName_()
Om header file.
The Om library.
Definition: code_point.hpp:26
Om header file.