ChaiScript / ChaiScript
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-2018, 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>
17 1
        constexpr void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *) noexcept
18
        {
19
        }
20
    };
21

22
    template<typename ... T>
23
      struct Tracer : T...
24
    {
25 1
      Tracer() = default;
26
      constexpr explicit Tracer(T ... t)
27
        : T(std::move(t))...
28
      {
29
      }
30

31 1
      void do_trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
32 1
        (static_cast<T&>(*this).trace(ds, node), ... );
33
      }
34

35 1
      static void trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
36 1
        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

Read our documentation on viewing source code .

Loading