comma::Expr Class Reference

#include <Expr.h>

Inheritance diagram for comma::Expr:
Inheritance graph
[legend]
Collaboration diagram for comma::Expr:
Collaboration graph
[legend]

List of all members.

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.
TypegetType () 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.
ExprignoreInjPrj ()
bool denotesName () const

Static Public Member Functions

static bool classof (const Expr *node)
 Support isa and dyn_cast.
static bool classof (const Ast *node)

Detailed Description

Definition at line 31 of file Expr.h.


Constructor & Destructor Documentation

comma::Expr::Expr ( AstKind  kind,
Type type,
Location  loc = 0 
) [inline]

Definition at line 34 of file Expr.h.

comma::Expr::Expr ( AstKind  kind,
Location  loc = 0 
) [inline]

Definition at line 39 of file Expr.h.

virtual comma::Expr::~Expr (  )  [inline, virtual]

Definition at line 44 of file Expr.h.


Member Function Documentation

static bool comma::Expr::classof ( const Ast node  )  [inline, static]
static bool comma::Expr::classof ( const Expr node  )  [inline, static]
bool Expr::denotesName (  )  const

Returns true if this node denotes a name as defined in the Comma grammar.

Definition at line 131 of file Expr.cpp.

Location comma::Expr::getLocation (  )  const [inline, virtual]

Returns the location of this expression.

Reimplemented from comma::Ast.

Reimplemented in comma::FunctionCallExpr.

Definition at line 47 of file Expr.h.

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.

Definition at line 61 of file Expr.h.

bool comma::Expr::hasResolvedType (  )  const [inline]

Returns true if this expression has a resolved type.

An expression is considered to have a resolved type if its type has been set and it is not a universal type.

Definition at line 76 of file Expr.h.

bool comma::Expr::hasType (  )  const [inline]

Returns true if this expression has a type associated with it.

Definition at line 50 of file Expr.h.

Expr * Expr::ignoreInjPrj (  ) 

Strips any outer layers of inj/prj expressions and returns the inner operand.

Definition at line 110 of file Expr.cpp.

bool Expr::isMutable ( Expr *&  immutable  ) 

Determines if this expression is mutable.

Mutable expressions always reduce to a DeclRefExpr which denotes:

  • An object declaration;
  • A renamed object declaration which signifies a mutable expression.

A mutable DeclRefExpr may be wrapped by an inj, prj, dereference, component selection, or array index expression.

Parameters:
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.
Returns:
True if this is a mutable expression false otherwise.

Definition at line 26 of file Expr.cpp.

bool Expr::isStaticDiscreteExpr (  )  const

Returns true if this expression can be evaluated as to a static discrete value.

Definition at line 456 of file Eval.cpp.

bool Expr::isStaticStringExpr (  )  const

Returns true if this expression evaluates to a static string expression.

Definition at line 472 of file Eval.cpp.

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.

Definition at line 70 of file Expr.h.

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.

Parameters:
result If this is a static expression, result is set to the computed value.
Returns:
True if expr is static and result was set. False otherwise.

Definition at line 437 of file Eval.cpp.

bool Expr::staticStringValue ( std::string &  result  )  const

Attempts to evaluate this expression as a constant string expression.

Parameters:
result If this is a static expression, result is set to the computed value.
Returns:
True if expr is static and result was set. False otherwise.

Definition at line 462 of file Eval.cpp.


The documentation for this class was generated from the following files:

Generated on 1 Feb 2010 for Comma by  doxygen 1.6.1