coan 4.2.4
The Integer Operations component interface.
Collaboration diagram for The Integer Operations component interface.:

Data Structures

struct  int_spec

Files

file  integer_ops.c
file  integer_ops.h

Defines

#define RANK(int_type)   ((int_type) >> 16)
#define SIZEOF(int_type)   (((int_type) >> 8) & ~0xff00)
#define IS_SIGNED(int_type)   ((int_type) & 1)
#define MAKE_SIGNED(int_type)   ((int_type) | 1)
#define MAKE_UNSIGNED(int_type)   ((int_type) & ~1)
#define INT_UNION_INITOR   {0LL}
#define INT_SPEC_INITOR   {INT_UNION_INITOR,INT_UNDEF}

Typedefs

typedef struct int_spec int_spec_t
typedef int_spec_tinteger_bin_op_t )(int_spec_t const *, int_spec_t const *)

Enumerations

enum  int_type {
  INT_UNDEF = 0, INT_CHAR = (1 << 16) | (sizeof(char) << 8) | 1, INT_UCHAR = (1 << 16) | sizeof(char) << 8, INT_SHORT = (2 << 16) | (sizeof(short) << 8) | 1,
  INT_USHORT = (2 << 16) | sizeof(short) << 8, INT_INT = (3 << 16) | (sizeof(int) << 8) | 1, INT_UINT = (3 << 16) | sizeof(int) << 8, INT_LONG = (4 << 16) | (sizeof(long) << 8) | 1,
  INT_ULONG = (4 << 16) | sizeof(long) << 8, INT_LLONG = (5 << 16) | (sizeof(long long) << 8) | 1, INT_ULLONG = (5 << 16) | sizeof(long long) << 8, INT_TOO_BIG = 6 << 16,
  INT_INSOLUBLE = INT_TOO_BIG
}

Functions

int_spec_t lt (int_spec_t const *l, int_spec_t const *r)
int_spec_t gt (int_spec_t const *l, int_spec_t const *r)
int_spec_t le (int_spec_t const *l, int_spec_t const *r)
int_spec_t ge (int_spec_t const *l, int_spec_t const *r)
int_spec_t eq (int_spec_t const *l, int_spec_t const *r)
int_spec_t ne (int_spec_t const *l, int_spec_t const *r)
int_spec_t bit_and (int_spec_t const *l, int_spec_t const *r)
int_spec_t bit_or (int_spec_t const *l, int_spec_t const *r)
int_spec_t bit_xor (int_spec_t const *l, int_spec_t const *r)
int_spec_t complement (int_spec_t const *int_spec)
int_spec_t minus (int_spec_t const *int_spec)
int_spec_t lshift (int_spec_t const *l, int_spec_t const *r)
int_spec_t rshift (int_spec_t const *l, int_spec_t const *r)
int_spec_t add (int_spec_t const *l, int_spec_t const *r)
int_spec_t subtract (int_spec_t const *l, int_spec_t const *r)
int_spec_t multiply (int_spec_t const *l, int_spec_t const *r)
int_spec_t divide (int_spec_t const *l, int_spec_t const *r)
int_spec_t modulus (int_spec_t const *l, int_spec_t const *r)
int_spec_t boolean_and (int_spec_t const *l, int_spec_t const *r)
int_spec_t boolean_or (int_spec_t const *l, int_spec_t const *r)
int_spec_t negate (int_spec_t const *int_spec)

Define Documentation

#define INT_SPEC_INITOR   {INT_UNION_INITOR,INT_UNDEF}

Initialiser for type int_spec_t

Definition at line 105 of file integer_ops.h.

Referenced by add(), bit_and(), bit_or(), bit_xor(), complement(), divide(), eval_character_constant(), le(), lshift(), minus(), modulus(), multiply(), rshift(), and subtract().

#define INT_UNION_INITOR   {0LL}

Initialiser for union of all integer types

Definition at line 102 of file integer_ops.h.

Referenced by boolean_and(), boolean_or(), eq(), eval_numeral(), lt(), ne(), and negate().

#define IS_SIGNED (   int_type)    ((int_type) & 1)

Say whether an int_type represents a signed type

Definition at line 80 of file integer_ops.h.

Referenced by check_shift_validity(), do_usual_conversions(), eval_numeral(), and sign_extend().

#define MAKE_SIGNED (   int_type)    ((int_type) | 1)

Get the signed variant of an int_type

Definition at line 83 of file integer_ops.h.

#define MAKE_UNSIGNED (   int_type)    ((int_type) & ~1)

Get the unsigned variant of an int_type

Definition at line 86 of file integer_ops.h.

Referenced by do_usual_conversions(), and eval_numeral().

#define RANK (   int_type)    ((int_type) >> 16)

Get the integer conversion rank from an int_type

Definition at line 74 of file integer_ops.h.

Referenced by do_usual_conversions(), and sign_extend().

#define SIZEOF (   int_type)    (((int_type) >> 8) & ~0xff00)

Get the size of an integer type from an int_type

Definition at line 77 of file integer_ops.h.

Referenced by check_shift_validity(), and do_usual_conversions().


Typedef Documentation

typedef struct int_spec int_spec_t

Structure representing the an integer value

typedef int_spec_t( integer_bin_op_t)(int_spec_t const *, int_spec_t const *)

Function type of binary operations on int_spec_t objects

Definition at line 108 of file integer_ops.h.


Enumeration Type Documentation

enum int_type

Encoding of integer types. The upper 3rd byte encodes the integer conversion rank of the integer type. See standard ISO/IEC 9899:1999 6.3.1.1 The upper 2nd byte contains the size of the type. The lowest byte encodes the signedness of the type, 0 = unsigned, 1 = signed.

Enumerator:
INT_UNDEF 

No defined type

INT_CHAR 

char

INT_UCHAR 

unsigned char

INT_SHORT 

short int

INT_USHORT 

unsigned short int

INT_INT 

int

INT_UINT 

unsigned int

INT_LONG 

long int

INT_ULONG 

unsigned long int

INT_LLONG 

long long int

INT_ULLONG 

unsigned Long long int

INT_TOO_BIG 

Integer value too large for its type

INT_INSOLUBLE 

Thing was not an int at all

Definition at line 57 of file integer_ops.h.


Function Documentation

int_spec_t add ( int_spec_t const *  l,
int_spec_t const *  r 
)

addition op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the addition as an int_spec_t

Definition at line 499 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_add().

Here is the call graph for this function:

int_spec_t bit_and ( int_spec_t const *  l,
int_spec_t const *  r 
)

bit_and op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the operation as an int_spec_t

Definition at line 345 of file integer_ops.c.

References do_usual_conversions(), INT_SPEC_INITOR, int_spec::type, and int_spec::val.

Referenced by op_bit_and().

Here is the call graph for this function:

int_spec_t bit_or ( int_spec_t const *  l,
int_spec_t const *  r 
)

bit_inclusive_or op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the operation as an int_spec_t

Definition at line 356 of file integer_ops.c.

References do_usual_conversions(), INT_SPEC_INITOR, int_spec::type, and int_spec::val.

Referenced by op_bit_or().

Here is the call graph for this function:

int_spec_t bit_xor ( int_spec_t const *  l,
int_spec_t const *  r 
)

bit_exclusive_or op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the operation as an int_spec_t

Definition at line 367 of file integer_ops.c.

References do_usual_conversions(), INT_SPEC_INITOR, int_spec::type, and int_spec::val.

Referenced by op_bit_xor().

Here is the call graph for this function:

int_spec_t boolean_and ( int_spec_t const *  l,
int_spec_t const *  r 
)

boolean_and op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the conjunction as an int_spec_t

Definition at line 664 of file integer_ops.c.

References INT_INT, INT_UNION_INITOR, and int_spec::val.

Referenced by op_and().

int_spec_t boolean_or ( int_spec_t const *  l,
int_spec_t const *  r 
)

boolean_or op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the conjunction as an int_spec_t

Definition at line 677 of file integer_ops.c.

References INT_INT, INT_UNION_INITOR, and int_spec::val.

int_spec_t complement ( int_spec_t const *  int_spec)

complement op on an int_spec_t object.

Parameters:
int_specThe int_spec to be complemented.
Returns:
The result of the operation as an int_spec_t

Definition at line 378 of file integer_ops.c.

References INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by dropping_line(), eval_unary(), flushline_live(), and parse_command_args().

int_spec_t divide ( int_spec_t const *  l,
int_spec_t const *  r 
)

divide op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the division as an int_spec_t

Definition at line 595 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_divide().

Here is the call graph for this function:

int_spec_t eq ( int_spec_t const *  l,
int_spec_t const *  r 
)

equality op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 328 of file integer_ops.c.

References INT_INT, INT_UNION_INITOR, and int_spec::val.

Referenced by canonical_string_equal(), file_tree_equal(), getopt_long(), op_eq(), ptr_set_equal(), and symbol_equal().

int_spec_t ge ( int_spec_t const *  l,
int_spec_t const *  r 
)

greater-than-or-equal op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 322 of file integer_ops.c.

References le().

Referenced by op_ge().

Here is the call graph for this function:

int_spec_t gt ( int_spec_t const *  l,
int_spec_t const *  r 
)

greater-than op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 284 of file integer_ops.c.

References lt().

Referenced by op_gt().

Here is the call graph for this function:

int_spec_t le ( int_spec_t const *  l,
int_spec_t const *  r 
)

less-than-or-equal op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 290 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by ge(), and op_le().

Here is the call graph for this function:

int_spec_t lshift ( int_spec_t const *  l,
int_spec_t const *  r 
)

left_shift op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the shift as an int_spec_t

Definition at line 431 of file integer_ops.c.

References check_shift_validity(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_lshift().

Here is the call graph for this function:

int_spec_t lt ( int_spec_t const *  l,
int_spec_t const *  r 
)

less-than op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 252 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_UINT, INT_ULLONG, INT_ULONG, INT_UNION_INITOR, int_spec::type, and int_spec::val.

Referenced by gt(), and op_lt().

Here is the call graph for this function:

int_spec_t minus ( int_spec_t const *  int_spec)

unary_minus op on an int_spec_t object.

Parameters:
int_specThe int_spec to be negated.
Returns:
The result of the operation as an int_spec_t

Definition at line 401 of file integer_ops.c.

References INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by eval_unary().

int_spec_t modulus ( int_spec_t const *  l,
int_spec_t const *  r 
)

modulus op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the mod op as an int_spec_t

Definition at line 627 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_mod().

Here is the call graph for this function:

int_spec_t multiply ( int_spec_t const *  l,
int_spec_t const *  r 
)

multiply op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the multiplication as an int_spec_t

Definition at line 563 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_mult().

Here is the call graph for this function:

int_spec_t ne ( int_spec_t const *  l,
int_spec_t const *  r 
)

inequality op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the comparison as an int_spec_t

Definition at line 336 of file integer_ops.c.

References INT_INT, INT_UNION_INITOR, and int_spec::val.

Referenced by op_ne().

int_spec_t negate ( int_spec_t const *  int_spec)

boolean_negation op on an int_spec_t object.

Parameters:
int_specThe int_spec to be negated.
Returns:
The result of the negation as an int_spec_t

Definition at line 690 of file integer_ops.c.

References INT_INT, INT_UNION_INITOR, and int_spec::val.

Referenced by eval_unary().

int_spec_t rshift ( int_spec_t const *  l,
int_spec_t const *  r 
)

right_shift op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the shift as an int_spec_t

Definition at line 465 of file integer_ops.c.

References check_shift_validity(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_rshift().

Here is the call graph for this function:

int_spec_t subtract ( int_spec_t const *  l,
int_spec_t const *  r 
)

subtraction op on two int_spec_t objects.

Parameters:
lThe left hand operand
rThe right hand operand.
Returns:
The result of the subtraction as an int_spec_t

Definition at line 531 of file integer_ops.c.

References do_usual_conversions(), INT_INT, INT_LLONG, INT_LONG, INT_SPEC_INITOR, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by op_subtract().

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines