fix Related to UnaryOp and Range for customizer

This commit is contained in:
amarjeet 2016-09-26 10:35:15 +05:30
parent ece05e318f
commit b426db8ab1
4 changed files with 20 additions and 7 deletions

View file

@ -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)
{
}

View file

@ -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<Expression> begin;
shared_ptr<Expression> step;
shared_ptr<Expression> end;

View file

@ -1,7 +1,6 @@
#include "parameterset.h"
#include "comment.h"
#include "modcontext.h"
#include "filemodule.h"
#include "expression.h"
#include <boost/property_tree/json_parser.hpp>

View file

@ -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);