summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-06-07 10:47:53 +0200
committerClifford Wolf <clifford@clifford.at>2014-06-07 10:47:53 +0200
commit0b1ce63a19025f73fe4d2a54253134ea9a4de625 (patch)
tree090832d5943acde4fdf9a1a1b65057f341f623fb /frontends
parent7c8a7b2131aa672d04ee0ed641f3e6b120f3ec49 (diff)
Added support for repeat stmt in const functions
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/simplify.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 8a4d42e1..e5e8980a 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -2001,6 +2001,25 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
continue;
}
+ if (stmt->type == AST_REPEAT)
+ {
+ AstNode *num = stmt->children.at(0)->clone();
+ num->replace_variables(variables, fcall);
+ while (num->simplify(true, false, false, 1, -1, false, true)) { }
+
+ if (num->type != AST_CONSTANT)
+ log_error("Non-constant expression in constant function at %s:%d (called from %s:%d).\n",
+ stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum);
+
+ block->children.erase(block->children.begin());
+ for (int i = 0; i < num->bitsAsConst().as_int(); i++)
+ block->children.insert(block->children.begin(), stmt->children.at(1)->clone());
+
+ delete stmt;
+ delete num;
+ continue;
+ }
+
if (stmt->type == AST_CASE)
{
AstNode *expr = stmt->children.at(0)->clone();