#include <Expr.h>
Public Member Functions | |
Expr (AstKind kind, Type *type, Location loc=0) | |
Expr (AstKind kind, Location loc=0) | |
virtual | ~Expr () |
Location | getLocation () const |
Returns the location of this expression. | |
bool | hasType () const |
Returns true if this expression has a type associated with it. | |
Type * | getType () const |
Returns the type of this expression. | |
void | setType (Type *type) |
Sets the type of this expression. | |
bool | hasResolvedType () const |
bool | isStaticDiscreteExpr () const |
Returns true if this expression can be evaluated as to a static discrete value. | |
bool | staticDiscreteValue (llvm::APInt &result) const |
Attempts to evaluate this expression as a constant descrete expression. | |
bool | staticStringValue (std::string &result) const |
Attempts to evaluate this expression as a constant string expression. | |
bool | isStaticStringExpr () const |
Returns true if this expression evaluates to a static string expression. | |
bool | isMutable (Expr *&immutable) |
Determines if this expression is mutable. | |
Expr * | ignoreInjPrj () |
bool | denotesName () const |
Static Public Member Functions | |
static bool | classof (const Expr *node) |
Support isa and dyn_cast. | |
static bool | classof (const Ast *node) |
Definition at line 31 of file Expr.h.
static bool comma::Expr::classof | ( | const Ast * | node | ) | [inline, static] |
Reimplemented in comma::AggregateExpr, comma::AttribExpr, comma::ScalarBoundAE, comma::FirstAE, comma::LastAE, comma::ArrayBoundAE, comma::FirstArrayAE, comma::LastArrayAE, comma::DeclRefExpr, comma::FunctionCallExpr, comma::IndexedArrayExpr, comma::SelectedExpr, comma::InjExpr, comma::PrjExpr, comma::IntegerLiteral, comma::StringLiteral, comma::NullExpr, comma::QualifiedExpr, comma::DereferenceExpr, comma::ConversionExpr, comma::AllocatorExpr, and comma::DiamondExpr.
static bool comma::Expr::classof | ( | const Expr * | node | ) | [inline, static] |
Support isa and dyn_cast.
Reimplemented from comma::Ast.
Reimplemented in comma::AggregateExpr, comma::AttribExpr, comma::ScalarBoundAE, comma::FirstAE, comma::LastAE, comma::ArrayBoundAE, comma::FirstArrayAE, comma::LastArrayAE, comma::DeclRefExpr, comma::FunctionCallExpr, comma::IndexedArrayExpr, comma::SelectedExpr, comma::InjExpr, comma::PrjExpr, comma::IntegerLiteral, comma::StringLiteral, comma::NullExpr, comma::QualifiedExpr, comma::DereferenceExpr, comma::ConversionExpr, comma::AllocatorExpr, and comma::DiamondExpr.
bool Expr::denotesName | ( | ) | const |
Location comma::Expr::getLocation | ( | ) | const [inline, virtual] |
Returns the location of this expression.
Reimplemented from comma::Ast.
Reimplemented in comma::FunctionCallExpr.
Type* comma::Expr::getType | ( | ) | const [inline] |
Returns the type of this expression.
Most expressions have a single well-known type. Others, such as FunctionCallExpr, can have multiple types temporarily associated with pending resolution in the type checker.
If this expression has a single well-known type, this method returns it. However, if the type is not known, this method will assert. One can call Expr::hasType to know if a type is available.
Reimplemented in comma::ScalarBoundAE, comma::ArrayBoundAE, comma::StringLiteral, comma::NullExpr, and comma::AllocatorExpr.
bool comma::Expr::hasResolvedType | ( | ) | const [inline] |
bool comma::Expr::hasType | ( | ) | const [inline] |
Expr * Expr::ignoreInjPrj | ( | ) |
bool Expr::isMutable | ( | Expr *& | immutable | ) |
Determines if this expression is mutable.
Mutable expressions always reduce to a DeclRefExpr which denotes:
A mutable DeclRefExpr may be wrapped by an inj, prj, dereference, component selection, or array index expression.
immutable | If this is not a mutable expression then immutable is set to first subexpression which forbids mutability. The purpose of this parameter is to provide the caller with the context as to why this is not mutable. |
bool Expr::isStaticDiscreteExpr | ( | ) | const |
bool Expr::isStaticStringExpr | ( | ) | const |
void comma::Expr::setType | ( | Type * | type | ) | [inline] |
Sets the type of this expression.
If the supplied type is null, then this expression is not associated with a type and Expr::hasType will subsequently return false.
bool Expr::staticDiscreteValue | ( | llvm::APInt & | result | ) | const |
Attempts to evaluate this expression as a constant descrete expression.
The correctness of this evaluation depends on the correctness of the given expression. For example, no checks are made that two distinct types are summed together.
result | If this is a static expression, result is set to the computed value. |
expr
is static and result
was set. False otherwise. bool Expr::staticStringValue | ( | std::string & | result | ) | const |