Update procedures
[shapes.git] / source / coreconstruct_impl.h
blob3f62fa0eaf26d0c15a5a2f87404749444728f661
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2013, 2014 Henrik Tidefelt
19 #pragma once
21 #include "ast.h"
22 #include "graphtypes.h"
23 #include "globals.h"
26 namespace Shapes
28 namespace Kernel
31 class Core_graph_cont_partitions : public Kernel::Continuation
33 RefCountPtr< const Lang::Value > nodes_;
34 const Ast::SourceLocation & nodesLoc_;
35 RefCountPtr< const Lang::Value > edges_;
36 const Ast::SourceLocation & edgesLoc_;
37 RefCountPtr< const Kernel::GraphDomain > domain_;
38 Kernel::ContRef cont_;
39 public:
40 Core_graph_cont_partitions( RefCountPtr< const Lang::Value > nodes, const Ast::SourceLocation & nodesLoc, RefCountPtr< const Lang::Value > edges, const Ast::SourceLocation & edgesLoc, RefCountPtr< const Kernel::GraphDomain > domain, const Kernel::ContRef & cont, const Ast::SourceLocation & partitionsLoc );
41 virtual ~Core_graph_cont_partitions( );
42 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
43 virtual Kernel::ContRef up( ) const;
44 virtual RefCountPtr< const char > description( ) const;
45 virtual void gcMark( Kernel::GCMarkedSet & marked );
48 class Core_graph_cont_nodes : public Kernel::Continuation
50 RefCountPtr< const Lang::Value > edges_;
51 const Ast::SourceLocation & edgesLoc_;
52 RefCountPtr< const Kernel::GraphDomain > domain_;
53 RefCountPtr< const Lang::SingleList > partitions_;
54 const Ast::SourceLocation & partitionsLoc_;
55 Kernel::ContRef cont_;
56 public:
57 Core_graph_cont_nodes( RefCountPtr< const Lang::Value > edges, const Ast::SourceLocation & edgesLoc, RefCountPtr< const Kernel::GraphDomain > domain, const RefCountPtr< const Lang::SingleList > & partitions, const Kernel::ContRef & cont, const Ast::SourceLocation & partitionsLoc, const Ast::SourceLocation & nodesLoc );
58 virtual ~Core_graph_cont_nodes( );
59 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
60 virtual Kernel::ContRef up( ) const;
61 virtual RefCountPtr< const char > description( ) const;
62 virtual void gcMark( Kernel::GCMarkedSet & marked );
65 class Core_graph_cont_edges : public Kernel::Continuation
67 RefCountPtr< const Lang::SingleList > nodes_;
68 RefCountPtr< const Kernel::GraphDomain > domain_;
69 RefCountPtr< const Lang::SingleList > partitions_;
70 const Ast::SourceLocation & nodesLoc_;
71 const Ast::SourceLocation & partitionsLoc_;
72 /* The edgesLoc passed to the contructor will be stored as traceLoc_. */
73 Kernel::ContRef cont_;
74 public:
75 Core_graph_cont_edges( RefCountPtr< const Lang::SingleList > nodes, RefCountPtr< const Kernel::GraphDomain > domain, const RefCountPtr< const Lang::SingleList > & partitions, const Kernel::ContRef & cont, const Ast::SourceLocation & nodesLoc, const Ast::SourceLocation & partitionsLoc, const Ast::SourceLocation & edgesLoc );
76 virtual ~Core_graph_cont_edges( );
77 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
78 virtual Kernel::ContRef up( ) const;
79 virtual RefCountPtr< const char > description( ) const;
80 virtual void gcMark( Kernel::GCMarkedSet & marked );
81 private:
82 RefCountPtr< const Lang::Graph > constructGraph( const RefCountPtr< const Lang::SingleList > & edges, Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
85 class Core_walk_cont_edges : public Kernel::Continuation
87 RefCountPtr< const Lang::Graph > graph_;
88 RefCountPtr< const Lang::Node > first_;
89 RefCountPtr< const Lang::Node > last_;
90 const Ast::SourceLocation & callLoc_;
91 /* The edgesLoc passed to the contructor will be stored as traceLoc_. */
92 Kernel::ContRef cont_;
93 public:
94 Core_walk_cont_edges( const RefCountPtr< const Lang::Graph > & graph, const RefCountPtr< const Lang::Node > & first, const RefCountPtr< const Lang::Node > & last, const Ast::SourceLocation & edgesLoc, const Kernel::ContRef & cont, const Ast::SourceLocation & callLoc );
95 virtual ~Core_walk_cont_edges( );
96 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
97 virtual Kernel::ContRef up( ) const;
98 virtual RefCountPtr< const char > description( ) const;
99 virtual void gcMark( Kernel::GCMarkedSet & marked );
102 class NodeDataReceiverFormals : public Kernel::EvaluatedFormals
104 public:
105 NodeDataReceiverFormals( )
106 : Kernel::EvaluatedFormals( Ast::FileID::build_internal( "< NodeData receiver >" ), true )
108 appendEvaluatedCoreFormal( "key", Kernel::THE_SLOT_VARIABLE );
109 appendEvaluatedCoreFormal( "value", Kernel::THE_VOID_VARIABLE );
110 appendEvaluatedCoreFormal( "partition", Kernel::THE_VOID_VARIABLE );
114 class EdgeDataReceiverFormals : public Kernel::EvaluatedFormals
116 public:
117 EdgeDataReceiverFormals( )
118 : Kernel::EvaluatedFormals( Ast::FileID::build_internal( "< EdgeData receiver >" ), true )
120 appendEvaluatedCoreFormal( "source", Kernel::THE_SLOT_VARIABLE );
121 appendEvaluatedCoreFormal( "target", Kernel::THE_SLOT_VARIABLE );
122 appendEvaluatedCoreFormal( "value", Kernel::THE_VOID_VARIABLE );
123 appendEvaluatedCoreFormal( "label", Kernel::THE_VOID_VARIABLE );
124 appendEvaluatedCoreFormal( "directed", Kernel::THE_VOID_VARIABLE );