summaryrefslogtreecommitdiff
path: root/src/module.h
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-12-26 15:34:47 (GMT)
committerMarius Kintel <marius@kintel.net>2011-12-26 15:34:47 (GMT)
commit4ff2d1af446c1f276c644b12e6ec4cc6db0b6d65 (patch)
tree10e9e52c2483efd6149f189c21366cdb0b11de77 /src/module.h
parentf0817a1c167c9d9f0ecf0ef8ec7bee03d61e63f2 (diff)
Some light refactoring attempts, didn't get very far..
Diffstat (limited to 'src/module.h')
-rw-r--r--src/module.h62
1 files changed, 39 insertions, 23 deletions
diff --git a/src/module.h b/src/module.h
index c28ab34..557b7c5 100644
--- a/src/module.h
+++ b/src/module.h
@@ -9,28 +9,38 @@
class ModuleInstantiation
{
public:
- std::string label;
- std::string modname;
+ 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<class Expression*> argexpr;
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;
- const class Context *ctx;
-
- ModuleInstantiation() : tag_root(false), tag_highlight(false), tag_background(false), ctx(NULL) { }
- virtual ~ModuleInstantiation();
+protected:
+ std::string modname;
- std::string dump(const std::string &indent) const;
- class AbstractNode *evaluate(const Context *ctx) const;
- std::vector<AbstractNode*> evaluateChildren(const Context *ctx = NULL) const;
+ friend class Module;
};
class IfElseModuleInstantiation : public ModuleInstantiation {
public:
+ IfElseModuleInstantiation() : ModuleInstantiation("if") { }
virtual ~IfElseModuleInstantiation();
std::vector<AbstractNode*> evaluateElseChildren(const Context *ctx = NULL) const;
@@ -48,18 +58,18 @@ public:
class Module : public AbstractModule
{
public:
- typedef boost::unordered_map<std::string, class Module*> ModuleContainer;
- ModuleContainer usedlibs;
+ 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); }
- 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);
+ static void clear_library_cache();
- std::vector<std::string> argnames;
- std::vector<Expression*> argexpr;
+ typedef boost::unordered_map<std::string, class Module*> ModuleContainer;
+ ModuleContainer usedlibs;
std::vector<std::string> assignments_var;
std::vector<Expression*> assignments_expr;
@@ -71,11 +81,17 @@ public:
std::vector<ModuleInstantiation*> children;
- Module() { }
- virtual ~Module();
+ std::vector<std::string> argnames;
+ std::vector<Expression*> argexpr;
- virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
- virtual std::string dump(const std::string &indent, const std::string &name) const;
+protected:
+
+private:
+ struct libs_cache_ent {
+ Module *mod;
+ std::string cache_id, msg;
+ };
+ static boost::unordered_map<std::string, libs_cache_ent> libs_cache;
};
#endif
contact: Jan Huwald // Impressum