Om
pull_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_PullOperation_
16 
18 
19 #else
20 
21 // MARK: - Om::Language::Operation::PullOperation
22 
23  #define Template_ \
24  template < \
25  typename ThisProgram, \
26  typename ThisImplementation \
27  >
28 
29  #define Type_ \
30  Om::Language::Operation::PullOperation< \
31  ThisProgram, \
32  ThisImplementation \
33  >
34 
35 // MARK: public (static)
36 
37 Template_
38 template <typename ThePullOperation>
39 inline void Type_::GiveElements(
40  ThePullOperation &,
41  Consumer & theConsumer
42 ) {
43  theConsumer.TakeElement(
44  GetOperator()
45  );
46 }
47 
48 // MARK: public (non-static)
49 
50 Template_
51 inline bool Type_::ParseQuotedElements(
52  Evaluation & theEvaluation,
53  Reader & theReader
54 ) {
55  ThisProgram theProgram;
56  theProgram.ParseElements(theReader);
57  return this->TakeQuotedElements(
58  theEvaluation,
59  theProgram
60  );
61 }
62 
63 Template_
64 template <typename TheOperand>
65 inline bool Type_::TakeOperand(
66  Evaluation & theEvaluation,
67  TheOperand & theOperand
68 ) {
69  assert(
70  !theOperand.IsEmpty()
71  );
72  return this->TakeQuotedProducer(
73  theEvaluation,
74  *theOperand.GetProgram()
75  );
76 }
77 
78 Template_
79 template <typename TheProducer>
80 inline bool Type_::TakeQuotedProducer(
81  Evaluation & theEvaluation,
82  TheProducer & theProducer
83 ) {
84  ThisProgram theProgramToPullFrom;
85  theProgramToPullFrom.TakeElements(theProducer);
86 
87  ThisProgram thePulledProgram;
88  ThisImplementation::Pull(
89  theProgramToPullFrom,
90  thePulledProgram
91  );
92 
93  theEvaluation.TakeQuotedProducer(theProgramToPullFrom);
94  theEvaluation.TakeQuotedProducer(thePulledProgram);
95  return true;
96 }
97 
98 // MARK: private (static)
99 
100 Template_
101 inline Om::Language::Operator const & Type_::GetOperator() {
102  static Operator const theOperator(
103  ThisImplementation::GetName()
104  );
105  return theOperator;
106 }
107 
108  #undef Type_
109  #undef Template_
110 
111 #endif
The Operator implementation.
Definition: operator.hpp:60
Om header file.