summaryrefslogtreecommitdiff
path: root/src/module.h
blob: 5262bfc68a0b9e38276ced204d191b1cdea52787 (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
#ifndef MODULE_H_
#define MODULE_H_

#include <string>
#include <vector>
#include <boost/unordered_map.hpp>
#include "value.h"

class ModuleInstantiation
{
public:
	std::string label;
	std::string modname;
	std::vector<std::string> argnames;
	std::vector<class Expression*> argexpr;
	std::vector<Value> argvalues;
	std::vector<ModuleInstantiation*> children;

	bool tag_root;
	bool tag_highlight;
	bool tag_background;
	const class Context *ctx;

	ModuleInstantiation() : tag_root(false), tag_highlight(false), tag_background(false), ctx(NULL) { }
	virtual ~ModuleInstantiation();

	std::string dump(const std::string &indent) const;
	class AbstractNode *evaluate(const Context *ctx) const;
};

class IfElseModuleInstantiation : public ModuleInstantiation {
public:
	virtual ~IfElseModuleInstantiation();

	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:
	typedef boost::unordered_map<std::string, class Module*> ModuleContainer;
	ModuleContainer usedlibs;

	struct libs_cache_ent {
		Module *mod;
		std::string cache_id, msg;
	};
	static boost::unordered_map<std::string, libs_cache_ent> libs_cache;
	static Module *compile_library(std::string filename);

	std::vector<std::string> argnames;
	std::vector<Expression*> argexpr;

	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;

	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;
};

#endif
contact: Jan Huwald // Impressum