blob: a4901292f4652f76f4a4b2c1212d26b5359e680b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef MODULE_H_
#define MODULE_H_
#include <string>
#include <vector>
#include <boost/unordered_map.hpp>
#include "value.h"
class ModuleInstantiation
{
public:
ModuleInstantiation(const std::string &name = "")
: ctx(NULL),
tag_root(false), tag_highlight(false), tag_background(false), modname(name) { }
virtual ~ModuleInstantiation();
std::string dump(const std::string &indent) const;
class AbstractNode *evaluate(const class Context *ctx) const;
std::vector<AbstractNode*> evaluateChildren(const Context *ctx = NULL) const;
const std::string &name() const { return this->modname; }
bool isBackground() const { return this->tag_background; }
bool isHighlight() const { return this->tag_highlight; }
bool isRoot() const { return this->tag_root; }
std::vector<std::string> argnames;
std::vector<Value> argvalues;
std::vector<class Expression*> argexpr;
std::vector<ModuleInstantiation*> children;
const Context *ctx;
bool tag_root;
bool tag_highlight;
bool tag_background;
protected:
std::string modname;
friend class Module;
};
class IfElseModuleInstantiation : public ModuleInstantiation {
public:
IfElseModuleInstantiation() : ModuleInstantiation("if") { }
virtual ~IfElseModuleInstantiation();
std::vector<AbstractNode*> evaluateElseChildren(const Context *ctx = NULL) const;
std::vector<ModuleInstantiation*> else_children;
};
class AbstractModule
{
public:
virtual ~AbstractModule();
virtual class AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
virtual std::string dump(const std::string &indent, const std::string &name) const;
};
class Module : public AbstractModule
{
public:
Module() { }
virtual ~Module();
virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
virtual std::string dump(const std::string &indent, const std::string &name) const;
void addChild(ModuleInstantiation *ch) { this->children.push_back(ch); }
typedef boost::unordered_map<std::string, class Module*> ModuleContainer;
ModuleContainer usedlibs;
void handleDependencies();
std::vector<std::string> assignments_var;
std::vector<Expression*> assignments_expr;
typedef boost::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
FunctionContainer functions;
typedef boost::unordered_map<std::string, AbstractModule*> AbstractModuleContainer;
AbstractModuleContainer modules;
std::vector<ModuleInstantiation*> children;
std::vector<std::string> argnames;
std::vector<Expression*> argexpr;
protected:
private:
};
#endif
|