1 // This file is distributed under the BSD License.
2 // See "license.txt" for details.
3 // Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
4 // Copyright 2009-2017, Jason Turner (jason@emptycrate.com)
5 // http://www.chaiscript.com
6 
7 #ifndef CHAISCRIPT_TRACER_HPP_
8 #define CHAISCRIPT_TRACER_HPP_
9 
10 namespace chaiscript {
11   namespace eval {
12 
13 
14     struct Noop_Tracer_Detail
15     {
16       template<typename T>
tracechaiscript::eval::Noop_Tracer_Detail17         void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *)
18         {
19         }
20     };
21 
22     template<typename ... T>
23       struct Tracer : T...
24     {
25       Tracer() = default;
Tracerchaiscript::eval::Tracer26       explicit Tracer(T ... t)
27         : T(std::move(t))...
28       {
29       }
30 
do_tracechaiscript::eval::Tracer31       void do_trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
32         (void)std::initializer_list<int>{ (static_cast<T&>(*this).trace(ds, node), 0)... };
33       }
34 
tracechaiscript::eval::Tracer35       static void trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
36         ds->get_parser().get_tracer<Tracer<T...>>().do_trace(ds, node);
37       }
38     };
39 
40     typedef Tracer<Noop_Tracer_Detail> Noop_Tracer;
41 
42   }
43 }
44 
45 #endif
46 
47