From 720c5a33b6a49cf328fdd7611f49153cf8f60247 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 8 Apr 2020 14:51:57 +0300 Subject: Separate tests and examples into individual packages Also make cli module to be explicitly enabled via the config.cli configuration variable. --- cli/cli/traversal/class.cxx | 49 ++++++++++++++ cli/cli/traversal/class.hxx | 41 +++++++++++ cli/cli/traversal/doc.hxx | 16 +++++ cli/cli/traversal/elements.cxx | 14 ++++ cli/cli/traversal/elements.hxx | 142 +++++++++++++++++++++++++++++++++++++++ cli/cli/traversal/expression.hxx | 16 +++++ cli/cli/traversal/namespace.cxx | 26 +++++++ cli/cli/traversal/namespace.hxx | 26 +++++++ cli/cli/traversal/option.cxx | 59 ++++++++++++++++ cli/cli/traversal/option.hxx | 74 ++++++++++++++++++++ cli/cli/traversal/unit.cxx | 46 +++++++++++++ cli/cli/traversal/unit.hxx | 58 ++++++++++++++++ 12 files changed, 567 insertions(+) create mode 100644 cli/cli/traversal/class.cxx create mode 100644 cli/cli/traversal/class.hxx create mode 100644 cli/cli/traversal/doc.hxx create mode 100644 cli/cli/traversal/elements.cxx create mode 100644 cli/cli/traversal/elements.hxx create mode 100644 cli/cli/traversal/expression.hxx create mode 100644 cli/cli/traversal/namespace.cxx create mode 100644 cli/cli/traversal/namespace.hxx create mode 100644 cli/cli/traversal/option.cxx create mode 100644 cli/cli/traversal/option.hxx create mode 100644 cli/cli/traversal/unit.cxx create mode 100644 cli/cli/traversal/unit.hxx (limited to 'cli/cli/traversal') diff --git a/cli/cli/traversal/class.cxx b/cli/cli/traversal/class.cxx new file mode 100644 index 0000000..b920f1f --- /dev/null +++ b/cli/cli/traversal/class.cxx @@ -0,0 +1,49 @@ +// file : cli/traversal/class.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#include + +namespace traversal +{ + // inherits + // + void inherits:: + traverse (type& i) + { + dispatch (i.base ()); + } + + // class_ + // + void class_:: + traverse (type& c) + { + pre (c); + inherits (c); + names (c); + post (c); + } + + void class_:: + inherits (type& c) + { + inherits (c, *this); + } + + void class_:: + inherits (type& c, edge_dispatcher& d) + { + iterate_and_dispatch (c.inherits_begin (), c.inherits_end (), d); + } + + void class_:: + pre (type&) + { + } + + void class_:: + post (type&) + { + } +} diff --git a/cli/cli/traversal/class.hxx b/cli/cli/traversal/class.hxx new file mode 100644 index 0000000..38cbefc --- /dev/null +++ b/cli/cli/traversal/class.hxx @@ -0,0 +1,41 @@ +// file : cli/traversal/class.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_CLASS_HXX +#define CLI_TRAVERSAL_CLASS_HXX + +#include +#include + +namespace traversal +{ + struct inherits: edge + { + inherits () {} + inherits (node_dispatcher& n) {node_traverser (n);} + + virtual void + traverse (type&); + }; + + struct class_: scope_template + { + virtual void + traverse (type&); + + virtual void + pre (type&); + + virtual void + inherits (type&); + + virtual void + inherits (type&, edge_dispatcher&); + + virtual void + post (type&); + }; +} + +#endif // CLI_TRAVERSAL_CLASS_HXX diff --git a/cli/cli/traversal/doc.hxx b/cli/cli/traversal/doc.hxx new file mode 100644 index 0000000..70a6dfd --- /dev/null +++ b/cli/cli/traversal/doc.hxx @@ -0,0 +1,16 @@ +// file : cli/traversal/doc.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_DOC_HXX +#define CLI_TRAVERSAL_DOC_HXX + +#include +#include + +namespace traversal +{ + struct doc: node {}; +} + +#endif // CLI_TRAVERSAL_DOC_HXX diff --git a/cli/cli/traversal/elements.cxx b/cli/cli/traversal/elements.cxx new file mode 100644 index 0000000..f3353f2 --- /dev/null +++ b/cli/cli/traversal/elements.cxx @@ -0,0 +1,14 @@ +// file : cli/traversal/elements.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#include + +namespace traversal +{ + void names:: + traverse (type& e) + { + dispatch (e.named ()); + } +} diff --git a/cli/cli/traversal/elements.hxx b/cli/cli/traversal/elements.hxx new file mode 100644 index 0000000..a2ada23 --- /dev/null +++ b/cli/cli/traversal/elements.hxx @@ -0,0 +1,142 @@ +// file : cli/traversal/elements.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_ELEMENTS_HXX +#define CLI_TRAVERSAL_ELEMENTS_HXX + +#include + +#include + +namespace traversal +{ + using namespace cutl; + + // + // + typedef compiler::dispatcher node_dispatcher; + typedef compiler::dispatcher edge_dispatcher; + + // + // + struct node_base: node_dispatcher, edge_dispatcher + { + void + edge_traverser (edge_dispatcher& d) + { + edge_dispatcher::traverser (d); + } + + edge_dispatcher& + edge_traverser () + { + return *this; + } + + using node_dispatcher::dispatch; + using edge_dispatcher::dispatch; + + using edge_dispatcher::iterate_and_dispatch; + }; + + struct edge_base: edge_dispatcher, node_dispatcher + { + void + node_traverser (node_dispatcher& d) + { + node_dispatcher::traverser (d); + } + + node_dispatcher& + node_traverser () + { + return *this; + } + + using edge_dispatcher::dispatch; + using node_dispatcher::dispatch; + + using node_dispatcher::iterate_and_dispatch; + }; + + inline edge_base& + operator>> (node_base& n, edge_base& e) + { + n.edge_traverser (e); + return e; + } + + inline node_base& + operator>> (edge_base& e, node_base& n) + { + e.node_traverser (n); + return n; + } + + // + // + template + struct node: compiler::traverser_impl, + virtual node_base + { + }; + + template + struct edge: compiler::traverser_impl, + virtual edge_base + { + }; + + // Edges + // + + struct names: edge + { + names () + { + } + + names (node_dispatcher& n) + { + node_traverser (n); + } + + virtual void + traverse (type&); + }; + + // Nodes + // + + struct nameable: node {}; + + template + struct scope_template: node + { + public: + virtual void + traverse (T& s) + { + names (s); + } + + virtual void + names (T& s) + { + names (s, *this); + } + + virtual void + names (T& s, edge_dispatcher& d) + { + this->iterate_and_dispatch (s.names_begin (), s.names_end (), d); + } + }; + + typedef scope_template scope; + + struct type: node {}; +} + +#endif // CLI_TRAVERSAL_ELEMENTS_HXX diff --git a/cli/cli/traversal/expression.hxx b/cli/cli/traversal/expression.hxx new file mode 100644 index 0000000..0888455 --- /dev/null +++ b/cli/cli/traversal/expression.hxx @@ -0,0 +1,16 @@ +// file : cli/traversal/expression.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_EXPRESSION_HXX +#define CLI_TRAVERSAL_EXPRESSION_HXX + +#include +#include + +namespace traversal +{ + struct expression: node {}; +} + +#endif // CLI_TRAVERSAL_EXPRESSION_HXX diff --git a/cli/cli/traversal/namespace.cxx b/cli/cli/traversal/namespace.cxx new file mode 100644 index 0000000..c938f77 --- /dev/null +++ b/cli/cli/traversal/namespace.cxx @@ -0,0 +1,26 @@ +// file : cli/traversal/namespace.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#include + +namespace traversal +{ + void namespace_:: + traverse (type& n) + { + pre (n); + names (n); + post (n); + } + + void namespace_:: + pre (type&) + { + } + + void namespace_:: + post (type&) + { + } +} diff --git a/cli/cli/traversal/namespace.hxx b/cli/cli/traversal/namespace.hxx new file mode 100644 index 0000000..5709f2a --- /dev/null +++ b/cli/cli/traversal/namespace.hxx @@ -0,0 +1,26 @@ +// file : cli/traversal/namespace.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_NAMESPACE_HXX +#define CLI_TRAVERSAL_NAMESPACE_HXX + +#include +#include + +namespace traversal +{ + struct namespace_: scope_template + { + virtual void + traverse (type&); + + virtual void + pre (type&); + + virtual void + post (type&); + }; +} + +#endif // CLI_TRAVERSAL_NAMESPACE_HXX diff --git a/cli/cli/traversal/option.cxx b/cli/cli/traversal/option.cxx new file mode 100644 index 0000000..ff5dcce --- /dev/null +++ b/cli/cli/traversal/option.cxx @@ -0,0 +1,59 @@ +// file : cli/traversal/option.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#include +#include + +namespace traversal +{ + // belongs + // + void belongs:: + traverse (type& e) + { + dispatch (e.type ()); + } + + // initialized + // + void initialized:: + traverse (type& e) + { + dispatch (e.expression ()); + } + + // option + // + void option:: + traverse (type& o) + { + pre (o); + belongs (o); + if (o.initialized_p ()) + initialized (o); + post (o); + } + + void option:: + pre (type&) + { + } + + void option:: + belongs (type& o) + { + belongs (o, edge_traverser ()); + } + + void option:: + initialized (type& o) + { + initialized (o, edge_traverser ()); + } + + void option:: + post (type&) + { + } +} diff --git a/cli/cli/traversal/option.hxx b/cli/cli/traversal/option.hxx new file mode 100644 index 0000000..e11fa21 --- /dev/null +++ b/cli/cli/traversal/option.hxx @@ -0,0 +1,74 @@ +// file : cli/traversal/option.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_OPTION_HXX +#define CLI_TRAVERSAL_OPTION_HXX + +#include +#include + +namespace traversal +{ + struct belongs: edge + { + belongs () + { + } + + belongs (node_dispatcher& n) + { + node_traverser (n); + } + + virtual void + traverse (type&); + }; + + struct initialized: edge + { + initialized () + { + } + + initialized (node_dispatcher& n) + { + node_traverser (n); + } + + virtual void + traverse (type&); + }; + + struct option: node + { + virtual void + traverse (type&); + + virtual void + pre (type&); + + virtual void + belongs (type&); + + virtual void + initialized (type&); + + virtual void + post (type&); + + void + belongs (type& o, edge_dispatcher& d) + { + d.dispatch (o.belongs ()); + } + + void + initialized (type& o, edge_dispatcher& d) + { + d.dispatch (o.initialized ()); + } + }; +} + +#endif // CLI_TRAVERSAL_OPTION_HXX diff --git a/cli/cli/traversal/unit.cxx b/cli/cli/traversal/unit.cxx new file mode 100644 index 0000000..cf10d1d --- /dev/null +++ b/cli/cli/traversal/unit.cxx @@ -0,0 +1,46 @@ +// file : cli/traversal/unit.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#include + +namespace traversal +{ + // cxx_includes + // + void cxx_includes:: + traverse (type& e) + { + dispatch (e.includee ()); + } + + // cli_includes + // + void cli_includes:: + traverse (type& e) + { + dispatch (e.includee ()); + } + + // cli_unit + // + void cli_unit:: + traverse (type& u) + { + pre (u); + iterate_and_dispatch ( + u.includes_begin (), u.includes_end (), edge_traverser ()); + names (u); + post (u); + } + + void cli_unit:: + pre (type&) + { + } + + void cli_unit:: + post (type&) + { + } +} diff --git a/cli/cli/traversal/unit.hxx b/cli/cli/traversal/unit.hxx new file mode 100644 index 0000000..eab42aa --- /dev/null +++ b/cli/cli/traversal/unit.hxx @@ -0,0 +1,58 @@ +// file : cli/traversal/unit.hxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_TRAVERSAL_UNIT_HXX +#define CLI_TRAVERSAL_UNIT_HXX + +#include +#include + +namespace traversal +{ + struct cxx_includes: edge + { + cxx_includes () + { + } + + cxx_includes (node_dispatcher& n) + { + node_traverser (n); + } + + virtual void + traverse (type&); + }; + + struct cli_includes: edge + { + cli_includes () + { + } + + cli_includes (node_dispatcher& n) + { + node_traverser (n); + } + + virtual void + traverse (type&); + }; + + struct cxx_unit: node {}; + + struct cli_unit: scope_template + { + virtual void + traverse (type&); + + virtual void + pre (type&); + + virtual void + post (type&); + }; +} + +#endif // CLI_TRAVERSAL_UNIT_HXX -- cgit v1.1