summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dxfdim.cc11
-rw-r--r--src/expr.cc16
-rw-r--r--src/module.cc25
-rw-r--r--src/module.h3
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;
};
contact: Jan Huwald // Impressum