diff options
author | Marius Kintel <marius@kintel.net> | 2013-04-05 05:30:09 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-04-05 05:30:09 (GMT) |
commit | 1b8b7aa5faa167af2687970f195e19439dab5a30 (patch) | |
tree | 5a01a4f97c91bbfeb8a975975da5c31232d7b921 /src/module.cc | |
parent | c7f83aa3e35baf8a517c40a367ec247a7061b225 (diff) |
I think this should fix issue #217
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/module.cc b/src/module.cc index e6dcb57..322085b 100644 --- a/src/module.cc +++ b/src/module.cc @@ -32,6 +32,9 @@ #include "function.h" #include "printutils.h" +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; +#include "boosty.h" #include <boost/foreach.hpp> #include <sstream> #include <sys/stat.h> @@ -67,6 +70,19 @@ IfElseModuleInstantiation::~IfElseModuleInstantiation() BOOST_FOREACH (ModuleInstantiation *v, else_children) delete v; } +/*! + Returns the absolute path to the given filename, unless it's empty. + */ +std::string ModuleInstantiation::getAbsolutePath(const std::string &filename) const +{ + if (!filename.empty() && !boosty::is_absolute(fs::path(filename))) { + return boosty::absolute(fs::path(this->modpath) / filename).string(); + } + else { + return filename; + } +} + std::string ModuleInstantiation::dump(const std::string &indent) const { std::stringstream dump; @@ -152,15 +168,15 @@ AbstractNode *Module::evaluate(const Context *ctx, const ModuleInstantiation *in c.functions_p = &functions; c.modules_p = &modules; - + if (!usedlibs.empty()) c.usedlibs_p = &usedlibs; else c.usedlibs_p = NULL; - + BOOST_FOREACH(const std::string &var, assignments_var) { c.set_variable(var, assignments.at(var)->evaluate(&c)); - } + } AbstractNode *node = new AbstractNode(inst); for (size_t i = 0; i < children.size(); i++) { |