Skip to content

ArgumentType

INCLUDE FILE
#include "ArgumentType.h"

class ArgumentType

Represents an argument type, which defines the valid values for an instruction's operands.

DEFINITION
class ArgumentType;

enum Type

The type of the argument type.

DEFINITION
enum Type;
VALUEDESCRIPTION
ANY

The argument type accepts any value.

ENCODING

The argument type accepts values that can be encoded by a specific encoding.

ENUM

The argument type accepts one of a fixed set of keywords.

MAP

The argument type accepts one of a fixed set of values that are mapped to other values.

RANGE

The argument type accepts values within a specific range.

constructor ArgumentType

Initialize an ArgumentType.

DEFINITION
ArgumentType ( Symbol  name );
PARAMETERDESCRIPTION
name

The name of the argument type.

destructor ~ArgumentTypevirtual

DEFINITION
virtual ~ArgumentType ( );

method as

Get the argument type as type T.

DEFINITION
template <typename T>
T * as ( );
RETURNSDESCRIPTION
T *

A pointer to the argument type as type T, or nullptr if it is not of type T.

method asconst

Get the argument type as type T.

DEFINITION
template <typename T>
const T * as ( ) const;
RETURNSDESCRIPTION
const T *

A pointer to the argument type as type T, or nullptr if it is not of type T.

method constraint_expressionconst virtual

Get the constraint expression for the argument type.

DEFINITION
virtual std::optional< Expression >  constraint_expression ( const Location & location,
Symbol  name ) const;
PARAMETERDESCRIPTION
location

The location of the argument in the source code.

name

The name to use for the argument.

RETURNSDESCRIPTION
std::optional< Expression >

The constraint expression, or {} if there is no constraint.

method isconst

Check if the argument type is of type T.

DEFINITION
template <typename T>
bool  is ( ) const;
RETURNSDESCRIPTION
bool

true if the argument type is of type T, false otherwise.

method is_validconst virtual

Check if an expression is valid for the argument type.

The default implementation returns {}. Subclasses should override this method to implement specific validation logic.

DEFINITION
virtual std::optional< bool >  is_valid ( const Expression & expression ) const;
PARAMETERDESCRIPTION
expression

The expression to check.

RETURNSDESCRIPTION
std::optional< bool >

true if the expression is known to be valid for the argument type, false if it is known to be invalid, {} if it is unknown.

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const = 0;
RETURNSDESCRIPTION
Type

The type of the argument type.

member name

The name of the argument type.

DEFINITION
Symbol  name;

class ArgumentTypeAny

Represents an argument type that accepts any value.

DEFINITION
class ArgumentTypeAny;

constructor ArgumentTypeAny

Initialize an ArgumentTypeAny.

DEFINITION
ArgumentTypeAny ( Symbol  name );
PARAMETERDESCRIPTION
name

The name of the argument type.

method is_validconst virtual

Check if an expression is valid for the argument type.

The default implementation returns {}. Subclasses should override this method to implement specific validation logic.

DEFINITION
virtual std::optional< bool >  is_valid ( const Expression & expression ) const;
PARAMETERDESCRIPTION
expression

The expression to check.

RETURNSDESCRIPTION
std::optional< bool >

true if the expression is known to be valid for the argument type, false if it is known to be invalid, {} if it is unknown.

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const;
RETURNSDESCRIPTION
Type

The type of the argument type.

class ArgumentTypeEncoding

Represents an argument type that accepts values that can be encoded by a specific encoding.

DEFINITION
class ArgumentTypeEncoding;

constructor ArgumentTypeEncoding

Initialize an ArgumentTypeEncoding.

DEFINITION
ArgumentTypeEncoding ( Symbol  name,
const IntegerEncoder & encoding );
PARAMETERDESCRIPTION
name

The name of the argument type.

encoding

The encoding used by the argument type.

method constraint_expressionconst virtual

Get the constraint expression for the argument type.

DEFINITION
virtual std::optional< Expression >  constraint_expression ( const Location & location,
Symbol  name ) const;
PARAMETERDESCRIPTION
location

The location of the argument in the source code.

name

The name to use for the argument.

RETURNSDESCRIPTION
std::optional< Expression >

The constraint expression, or {} if there is no constraint.

method is_validconst virtual

Check if an expression is valid for the argument type.

The default implementation returns {}. Subclasses should override this method to implement specific validation logic.

DEFINITION
virtual std::optional< bool >  is_valid ( const Expression & expression ) const;
PARAMETERDESCRIPTION
expression

The expression to check.

RETURNSDESCRIPTION
std::optional< bool >

true if the expression is known to be valid for the argument type, false if it is known to be invalid, {} if it is unknown.

method range_typeconst

DEFINITION
std::unique_ptr< ArgumentType >  range_type ( Symbol  range_name ) const;
PARAMETERDESCRIPTION
range_name
RETURNSDESCRIPTION
std::unique_ptr< ArgumentType >

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const;
RETURNSDESCRIPTION
Type

The type of the argument type.

member encoding

The encoding used by the argument type.

DEFINITION
IntegerEncoder  encoding;

class ArgumentTypeEnum

Represents an argument type that accepts one of a fixed set of keywords.

DEFINITION
class ArgumentTypeEnum;

constructor ArgumentTypeEnum

Initialize an ArgumentTypeEnum.

DEFINITION
ArgumentTypeEnum ( Symbol  name );
PARAMETERDESCRIPTION
name

The name of the argument type.

method entryconst

Get the value of the entry with the specified name.

DEFINITION
Value  entry ( Symbol  name ) const;
PARAMETERDESCRIPTION
name

The name of the entry.

RETURNSDESCRIPTION
Value

The value of the entry.

method has_entryconst

Check if the argument type has an entry with the specified name.

DEFINITION
bool  has_entry ( Symbol  name ) const;
PARAMETERDESCRIPTION
name

The name of the entry.

RETURNSDESCRIPTION
bool

true if the entry exists, false otherwise.

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const;
RETURNSDESCRIPTION
Type

The type of the argument type.

member entries

The accepted keywords and their corresponding values.

DEFINITION
std::unordered_map< Symbol, Value >  entries;

class ArgumentTypeMap

Represents an argument type that accepts one of a fixed set of values that are mapped to other values.

DEFINITION
class ArgumentTypeMap;

constructor ArgumentTypeMap

Initialize an ArgumentTypeMap.

DEFINITION
ArgumentTypeMap ( Symbol  name );
PARAMETERDESCRIPTION
name

The name of the argument type.

method entryconst

Get the mapped value for the specified input value.

DEFINITION
Value  entry ( const Value & value ) const;
PARAMETERDESCRIPTION
value

The input value.

RETURNSDESCRIPTION
Value

The mapped value.

method has_entryconst

Check if the argument type has an entry for the specified value.

DEFINITION
bool  has_entry ( const Value & value ) const;
PARAMETERDESCRIPTION
value

The value to check.

RETURNSDESCRIPTION
bool

true if the entry exists, false otherwise.

method is_validconst virtual

Check if an expression is valid for the argument type.

The default implementation returns {}. Subclasses should override this method to implement specific validation logic.

DEFINITION
virtual std::optional< bool >  is_valid ( const Expression & expression ) const;
PARAMETERDESCRIPTION
expression

The expression to check.

RETURNSDESCRIPTION
std::optional< bool >

true if the expression is known to be valid for the argument type, false if it is known to be invalid, {} if it is unknown.

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const;
RETURNSDESCRIPTION
Type

The type of the argument type.

member entries

The accepted input values and their corresponding mapped values.

DEFINITION
std::unordered_map< Value, Value >  entries;

class ArgumentTypeRange

Represents an argument type that accepts values within a specific range.

DEFINITION
class ArgumentTypeRange;

constructor ArgumentTypeRange

Initialize an ArgumentTypeRange.

DEFINITION
ArgumentTypeRange ( Symbol  name );
PARAMETERDESCRIPTION
name

The name of the argument type.

method constraint_expressionconst virtual

Get the constraint expression for the argument type.

DEFINITION
virtual std::optional< Expression >  constraint_expression ( const Location & location,
Symbol  name ) const;
PARAMETERDESCRIPTION
location

The location of the argument in the source code.

name

The name to use for the argument.

RETURNSDESCRIPTION
std::optional< Expression >

The constraint expression, or {} if there is no constraint.

method is_validconst virtual

Check if an expression is valid for the argument type.

The default implementation returns {}. Subclasses should override this method to implement specific validation logic.

DEFINITION
virtual std::optional< bool >  is_valid ( const Expression & expression ) const;
PARAMETERDESCRIPTION
expression

The expression to check.

RETURNSDESCRIPTION
std::optional< bool >

true if the expression is known to be valid for the argument type, false if it is known to be invalid, {} if it is unknown.

method typeconst virtual

Get the type of the argument type.

Subclasses must implement this method.

DEFINITION
virtual Type  type ( ) const;
RETURNSDESCRIPTION
Type

The type of the argument type.

member lower_bound

The lower bound of the accepted range.

DEFINITION
Value  lower_bound;

member upper_bound

The upper bound of the accepted range.

DEFINITION
Value  upper_bound;