diff options
author | Marius Kintel <marius@kintel.net> | 2013-06-02 22:15:37 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-06-02 22:15:37 (GMT) |
commit | 85c83fbc04f4918159a598793cee47cdafabf8c4 (patch) | |
tree | d79d2c7d954424dd2354a16560b693351193d35b /src | |
parent | 40ad09637974f840ea4bdd3b7b27e2f5d7388c5b (diff) | |
parent | 41f352a7888aebfffd96b0e764e29b3f0cbf01fa (diff) |
Merge branch 'master' into issue181
Diffstat (limited to 'src')
-rw-r--r-- | src/dxfdim.cc | 11 | ||||
-rw-r--r-- | src/expr.cc | 16 | ||||
-rw-r--r-- | src/module.cc | 25 | ||||
-rw-r--r-- | src/module.h | 3 |
4 files changed, 43 insertions, 12 deletions
diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 66842d2..a241b87 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -160,9 +160,16 @@ Value builtin_dxf_cross(const Context *ctx, const EvalContext *evalctx) } std::stringstream keystream; + fs::path filepath(filename); + uintmax_t filesize = -1; + time_t lastwritetime = -1; + if (fs::exists(filepath) && fs::is_regular_file(filepath)) { + filesize = fs::file_size(filepath); + lastwritetime = fs::last_write_time(filepath); + } keystream << filename << "|" << layername << "|" << xorigin << "|" << yorigin - << "|" << scale << "|" << fs::last_write_time(filename) - << "|" << fs::file_size(filename); + << "|" << scale << "|" << lastwritetime + << "|" << filesize; std::string key = keystream.str(); if (dxf_cross_cache.find(key) != dxf_cross_cache.end()) diff --git a/src/expr.cc b/src/expr.cc index 1381c24..2e069f0 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -172,23 +172,27 @@ std::string Expression::toString() const if (this->type == "*" || this->type == "/" || this->type == "%" || this->type == "+" || this->type == "-" || this->type == "<" || this->type == "<=" || this->type == "==" || - this->type == "!=" || this->type == ">=" || this->type == ">") { + this->type == "!=" || this->type == ">=" || this->type == ">" || + this->type == "&&" || this->type == "||") { stream << "(" << *this->children[0] << " " << this->type << " " << *this->children[1] << ")"; } else if (this->type == "?:") { - stream << "(" << *this->children[0] << " ? " << this->type << " : " << *this->children[1] << ")"; + stream << "(" << *this->children[0] << " ? " << *this->children[1] << " : " << *this->children[2] << ")"; } else if (this->type == "[]") { - stream << "(" << *this->children[0] << "[" << *this->children[1] << "])"; + stream << *this->children[0] << "[" << *this->children[1] << "]"; } else if (this->type == "I") { - stream << "(-" << *this->children[0] << ")"; + stream << "-" << *this->children[0]; + } + else if (this->type == "!") { + stream << "!" << *this->children[0]; } else if (this->type == "C") { stream << this->const_value; } else if (this->type == "R") { - stream << "[" << *this->children[0] << " : " << *this->children[1] << " : " << this->children[2] << "]"; + stream << "[" << *this->children[0] << " : " << *this->children[1] << " : " << *this->children[2] << "]"; } else if (this->type == "V") { stream << "["; @@ -202,7 +206,7 @@ std::string Expression::toString() const stream << this->var_name; } else if (this->type == "N") { - stream << "(" << *this->children[0] << "." << this->var_name << ")"; + stream << *this->children[0] << "." << this->var_name; } else if (this->type == "F") { stream << this->call_funcname << "("; diff --git a/src/module.cc b/src/module.cc index b9b23d8..046d0c4 100644 --- a/src/module.cc +++ b/src/module.cc @@ -102,16 +102,35 @@ std::string ModuleInstantiation::dump(const std::string &indent) const if (scope.numElements() == 0) { dump << ");\n"; } else if (scope.numElements() == 1) { - dump << ")\n"; - dump << scope.dump(indent + "\t"); + dump << ") "; + dump << scope.dump(""); } else { dump << ") {\n"; - scope.dump(indent + "\t"); + dump << scope.dump(indent + "\t"); dump << indent << "}\n"; } return dump.str(); } +std::string IfElseModuleInstantiation::dump(const std::string &indent) const +{ + std::stringstream dump; + dump << ModuleInstantiation::dump(indent); + dump << indent; + if (else_scope.numElements() > 0) { + dump << indent << "else "; + if (else_scope.numElements() == 1) { + dump << else_scope.dump(""); + } + else { + dump << "{\n"; + dump << else_scope.dump(indent + "\t"); + dump << indent << "}\n"; + } + } + return dump.str(); +} + AbstractNode *ModuleInstantiation::evaluate(const Context *ctx) const { EvalContext c(ctx, this->arguments, &this->scope); diff --git a/src/module.h b/src/module.h index ad2a46c..682e65b 100644 --- a/src/module.h +++ b/src/module.h @@ -19,7 +19,7 @@ public: : tag_root(false), tag_highlight(false), tag_background(false), recursioncount(0), modname(name) { } virtual ~ModuleInstantiation(); - std::string dump(const std::string &indent) const; + virtual std::string dump(const std::string &indent) const; class AbstractNode *evaluate(const class Context *ctx) const; std::vector<AbstractNode*> instantiateChildren(const Context *evalctx) const; @@ -51,6 +51,7 @@ public: IfElseModuleInstantiation() : ModuleInstantiation("if") { } virtual ~IfElseModuleInstantiation(); std::vector<AbstractNode*> instantiateElseChildren(const Context *evalctx) const; + virtual std::string dump(const std::string &indent) const; LocalScope else_scope; }; |