From b426db8ab13beeaf6acb2181907a15f2cb295578 Mon Sep 17 00:00:00 2001 From: amarjeet Date: Mon, 26 Sep 2016 10:35:15 +0530 Subject: [PATCH] fix Related to UnaryOp and Range for customizer --- src/expr.cc | 18 ++++++++++++++++++ src/expression.h | 4 ++-- src/parameter/parameterset.cpp | 1 - .../allexpressionscomment-expected.ast | 4 ---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/expr.cc b/src/expr.cc index 0e965226..2cc9eb19 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -112,6 +112,13 @@ const char *UnaryOp::opString() const } } +bool UnaryOp::isLiteral() const { + + if(this->expr->isLiteral()) + return true; + return false; +} + void UnaryOp::print(std::ostream &stream) const { stream << opString() << *this->expr; @@ -305,6 +312,17 @@ void Range::print(std::ostream &stream) const stream << "]"; } +bool Range::isLiteral() const { + if(!this->step){ + if( begin->isLiteral() && end->isLiteral()) + return true; + }else{ + if( begin->isLiteral() && end->isLiteral() && step->isLiteral()) + return true; + } + return false; +} + Vector::Vector(const Location &loc) : Expression(loc) { } diff --git a/src/expression.h b/src/expression.h index 1c5c71f7..f2165ad9 100644 --- a/src/expression.h +++ b/src/expression.h @@ -27,7 +27,7 @@ public: Not, Negate }; - virtual bool isLiteral() const { return true;} + virtual bool isLiteral() const; UnaryOp(Op op, Expression *expr, const Location &loc); virtual ValuePtr evaluate(const class Context *context) const; virtual void print(std::ostream &stream) const; @@ -111,8 +111,8 @@ public: Range(Expression *begin, Expression *step, Expression *end, const Location &loc); ValuePtr evaluate(const class Context *context) const; virtual void print(std::ostream &stream) const; + virtual bool isLiteral() const; private: - virtual bool isLiteral() const { return true;} shared_ptr begin; shared_ptr step; shared_ptr end; diff --git a/src/parameter/parameterset.cpp b/src/parameter/parameterset.cpp index 7a902d3c..48e25bfd 100644 --- a/src/parameter/parameterset.cpp +++ b/src/parameter/parameterset.cpp @@ -1,7 +1,6 @@ #include "parameterset.h" #include "comment.h" #include "modcontext.h" -#include "filemodule.h" #include "expression.h" #include diff --git a/tests/regression/customizertest/allexpressionscomment-expected.ast b/tests/regression/customizertest/allexpressionscomment-expected.ast index c031c147..4a0037ee 100644 --- a/tests/regression/customizertest/allexpressionscomment-expected.ast +++ b/tests/regression/customizertest/allexpressionscomment-expected.ast @@ -40,11 +40,7 @@ t = (c > d); u = (e && g); v = (e || g); w = i; -@Description("description") -@Parameter("parameter") x = -i; -@Description("description") -@Parameter("parameter") y = !i; z = j; aa = (k ? l : m);