CBMC
convert_int_literal.cpp File Reference

Statement List Language Conversion. More...

#include "convert_int_literal.h"
#include "convert_dint_literal.h"
#include "statement_list_types.h"
#include <util/arith_tools.h>
#include <util/bitvector_types.h>
#include <stdexcept>
+ Include dependency graph for convert_int_literal.cpp:

Go to the source code of this file.

Macros

#define STL_INT_MAX_VALUE   32767LL
 Maximum value of integer literals. More...
 
#define STL_INT_MIN_VALUE   -32768LL
 Minimum value of integer literals. More...
 
#define BASE_10   10u
 Base of decimal integer literals. More...
 
#define BASE_16   16u
 Base of hexadecimal integer literals. More...
 
#define BASE_2   2u
 Base of binary integer literals. More...
 
#define PREFIX_SEPARATOR   '#'
 Character between a prefix and another prefix or the actual literal. More...
 
#define OUT_OF_RANGE_MSG   "Int literal out of range"
 Message for the case of a literal being out of range. More...
 

Functions

static long long get_literal_value (const std::string &src, unsigned int base)
 
constant_exprt convert_int_dec_literal (const std::string &src)
 Converts a string into the corresponding 'Int' or 'DInt' expression. More...
 
constant_exprt convert_int_dec_literal_value (const std::string &src)
 Converts a string into the corresponding 'Int' expression. More...
 
constant_exprt convert_int_hex_literal (const std::string &src)
 Converts a string into the corresponding 'Int' or 'DInt' expression. More...
 
constant_exprt convert_int_hex_literal_value (const std::string &src)
 Converts a string into the corresponding 'Int' expression. More...
 
constant_exprt convert_int_bit_literal (const std::string &src)
 Converts a string into the corresponding 'Int' or 'DInt' expression. More...
 
constant_exprt convert_int_bit_literal_value (const std::string &src)
 Converts a string into the corresponding 'Int' expression. More...
 

Detailed Description

Statement List Language Conversion.

Definition in file convert_int_literal.cpp.

Macro Definition Documentation

◆ BASE_10

#define BASE_10   10u

Base of decimal integer literals.

Definition at line 26 of file convert_int_literal.cpp.

◆ BASE_16

#define BASE_16   16u

Base of hexadecimal integer literals.

Definition at line 28 of file convert_int_literal.cpp.

◆ BASE_2

#define BASE_2   2u

Base of binary integer literals.

Definition at line 30 of file convert_int_literal.cpp.

◆ OUT_OF_RANGE_MSG

#define OUT_OF_RANGE_MSG   "Int literal out of range"

Message for the case of a literal being out of range.

Definition at line 34 of file convert_int_literal.cpp.

◆ PREFIX_SEPARATOR

#define PREFIX_SEPARATOR   '#'

Character between a prefix and another prefix or the actual literal.

Definition at line 32 of file convert_int_literal.cpp.

◆ STL_INT_MAX_VALUE

#define STL_INT_MAX_VALUE   32767LL

Maximum value of integer literals.

Definition at line 22 of file convert_int_literal.cpp.

◆ STL_INT_MIN_VALUE

#define STL_INT_MIN_VALUE   -32768LL

Minimum value of integer literals.

Definition at line 24 of file convert_int_literal.cpp.

Function Documentation

◆ convert_int_bit_literal()

constant_exprt convert_int_bit_literal ( const std::string &  src)

Converts a string into the corresponding 'Int' or 'DInt' expression.

Parameters
srcString returned by the parser (base 2).
Returns
Constant expression representing the integer or double integer value.

Definition at line 115 of file convert_int_literal.cpp.

◆ convert_int_bit_literal_value()

constant_exprt convert_int_bit_literal_value ( const std::string &  src)

Converts a string into the corresponding 'Int' expression.

Parameters
srcString returned by the parser (base 2).
Returns
Constant expression representing the integer value.

Definition at line 132 of file convert_int_literal.cpp.

◆ convert_int_dec_literal()

constant_exprt convert_int_dec_literal ( const std::string &  src)

Converts a string into the corresponding 'Int' or 'DInt' expression.

Parameters
srcString returned by the parser (base 10).
Returns
Constant expression representing the integer or double integer value.

Definition at line 47 of file convert_int_literal.cpp.

◆ convert_int_dec_literal_value()

constant_exprt convert_int_dec_literal_value ( const std::string &  src)

Converts a string into the corresponding 'Int' expression.

Parameters
srcString returned by the parser (base 10).
Returns
Constant expression representing the integer value.

Definition at line 64 of file convert_int_literal.cpp.

◆ convert_int_hex_literal()

constant_exprt convert_int_hex_literal ( const std::string &  src)

Converts a string into the corresponding 'Int' or 'DInt' expression.

Parameters
srcString returned by the parser (base 16).
Returns
Constant expression representing the integer or double integer value.

Definition at line 81 of file convert_int_literal.cpp.

◆ convert_int_hex_literal_value()

constant_exprt convert_int_hex_literal_value ( const std::string &  src)

Converts a string into the corresponding 'Int' expression.

Parameters
srcString returned by the parser (base 16).
Returns
Constant expression representing the integer value.

Definition at line 98 of file convert_int_literal.cpp.

◆ get_literal_value()

static long long get_literal_value ( const std::string &  src,
unsigned int  base 
)
static

Definition at line 36 of file convert_int_literal.cpp.