OpenASIP  2.0
Public Member Functions | Public Attributes | List of all members
Expression Class Reference

#include <ParserStructs.hh>

Collaboration diagram for Expression:
Collaboration graph

Public Member Functions

std::string toString () const
 

Public Attributes

std::string label
 Name of the label. More...
 
bool hasValue
 Is resolved value defined in struct. More...
 
UValue value
 Resolved value. More...
 
bool hasOffset
 Is offset defined. More...
 
bool isMinus
 Is offset minus. More...
 
UValue offset
 Value of offset. More...
 

Detailed Description

Parsed expression.

Expression is label with possibly some additional information.

Form: name[(+|-)offset][=literal] e.g. myDataStructLabel+8=16, myCodeLabel=3, myDataStructLabel+8 or myDataStructLabel

Part after '=' sign is just value of label, if value is always resolved by compiler and it is also given by user values will be compared to match.

Offset can be used for example with structures, if one want's to refer different datafields.

Definition at line 198 of file ParserStructs.hh.

Member Function Documentation

◆ toString()

std::string Expression::toString ( ) const
inline

String representation of term for error message generation.

Definition at line 218 of file ParserStructs.hh.

218  {
219 
220  std::stringstream retVal;
221 
222  retVal << label;
223 
224  if (hasOffset) {
225  if (isMinus) {
226  retVal << '-';
227  } else {
228  retVal << '+';
229  }
230 
231  retVal << std::dec << offset;
232  }
233 
234  if (hasValue) {
235  retVal << "=" << std::hex << value;
236  }
237 
238  return retVal.str();
239  }

References hasOffset, hasValue, isMinus, label, offset, and value.

Referenced by LiteralOrExpression::toString().

Member Data Documentation

◆ hasOffset

bool Expression::hasOffset

Is offset defined.

Definition at line 209 of file ParserStructs.hh.

Referenced by LabelManager::resolveExpressionValue(), and toString().

◆ hasValue

bool Expression::hasValue

Is resolved value defined in struct.

Definition at line 204 of file ParserStructs.hh.

Referenced by LabelManager::resolveExpressionValue(), and toString().

◆ isMinus

bool Expression::isMinus

Is offset minus.

Definition at line 211 of file ParserStructs.hh.

Referenced by LabelManager::resolveExpressionValue(), and toString().

◆ label

std::string Expression::label

◆ offset

UValue Expression::offset

Value of offset.

Definition at line 213 of file ParserStructs.hh.

Referenced by LabelManager::resolveExpressionValue(), and toString().

◆ value

UValue Expression::value

Resolved value.

Definition at line 206 of file ParserStructs.hh.

Referenced by LabelManager::resolveExpressionValue(), and toString().


The documentation for this class was generated from the following file:
Expression::isMinus
bool isMinus
Is offset minus.
Definition: ParserStructs.hh:211
Expression::hasValue
bool hasValue
Is resolved value defined in struct.
Definition: ParserStructs.hh:204
Expression::label
std::string label
Name of the label.
Definition: ParserStructs.hh:201
Expression::value
UValue value
Resolved value.
Definition: ParserStructs.hh:206
Expression::offset
UValue offset
Value of offset.
Definition: ParserStructs.hh:213
Expression::hasOffset
bool hasOffset
Is offset defined.
Definition: ParserStructs.hh:209