coan 4.2.4
The Evaluation Result component interface.
Collaboration diagram for The Evaluation Result component interface.:

Data Structures

struct  eval_result

Files

file  eval_result.c
file  eval_result.h

Defines

#define EVAL_RESULT_INITOR   {0,0,0,INT_SPEC_INITOR,EVAL_PENDING,0}
#define SET_FLAGS(eval_result, bits)   ((eval_result).flags |= (bits))
#define SET_FLAGS_IF(cond, eval_result, bits)   (void)((cond) ? SET_FLAGS(eval_result,bits) : 0)
#define CLEAR_FLAGS(eval_result, bits)   ((eval_result).flags &= ~(bits))
#define CLEAR_FLAGS_IF(cond, eval_result, bits)   (void)((cond) ? CLEAR_FLAGS(eval_result,bits) : 0)
#define FLIP_FLAGS(eval_result, bits)   ((eval_result).flags ^= (bits))
#define FLAGS_IN(eval_result, bits)   ((eval_result).flags & (bits))
#define AFFIRM_FLAGS(eval_result, bits)   (((eval_result).flags & (bits)) == (bits))
#define DENY_FLAGS(eval_result, bits)   (((eval_result).flags & (bits)) == 0)
#define IS_TRUE(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_TRUE)
#define IS_FALSE(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_FALSE)
#define IS_CONST(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_CONST)
#define INT_WIDTH(eval_result)   ((eval_result).value.width)
#define UNRESOLVED(eval_result)   DENY_FLAGS(eval_result,EVAL_FALSE | EVAL_TRUE)
#define RESOLVED(eval_result)   !UNRESOLVED(eval_result)
#define SET_REPORTED(eval_result)   SET_FLAGS(eval_result,EVAL_REPORTED_SYM)
#define REPORTED(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_REPORTED_SYM)
#define DEL_PAREN(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_DEL_PAREN)
#define SET_DEL_PAREN(eval_result)   SET_FLAGS(eval_result,EVAL_DEL_PAREN)
#define SET_KEEP_PAREN(eval_result)   CLEAR_FLAGS(eval_result,EVAL_DEL_PAREN)
#define KEEP(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_KEEP)
#define SET_KEEP(eval_result)   SET_FLAGS(eval_result,EVAL_KEEP)
#define KEEP_CONST(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_KEEP_CONST)
#define SET_KEEP_CONST(eval_result)   SET_FLAGS(eval_result,EVAL_KEEP_CONST)
#define SET_CONST(eval_result)   SET_FLAGS(eval_result,EVAL_CONST)
#define SET_ILLEGAL(eval_result)   SET_FLAGS(eval_result,EVAL_ILLEGAL)
#define SET_LEGAL(eval_result)   CLEAR_FLAGS(eval_result,EVAL_ILLEGAL)
#define ILLEGAL(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_ILLEGAL)
#define LEGAL(eval_result)   !ILLEGAL(eval_result)
#define SET_UNRESOLVED(eval_result)   CLEAR_FLAGS(eval_result,EVAL_TRUE | EVAL_FALSE)
#define SET_INSOURCE_SYM(eval_result)   SET_FLAGS(eval_result,EVAL_INSOURCE_SYM)
#define INSOURCE_SYM(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_INSOURCE_SYM)
#define SET_GLOBAL_SYM(eval_result)   SET_FLAGS(eval_result,EVAL_GLOBAL_SYM)
#define GLOBAL_SYM(eval_result)   AFFIRM_FLAGS(eval_result,EVAL_GLOBAL_SYM)

Typedefs

typedef struct eval_result eval_result_t

Enumerations

enum  eval_flags {
  EVAL_PENDING, EVAL_CONST = 1, EVAL_KEEP = 2, EVAL_KEEP_CONST = EVAL_CONST | EVAL_KEEP,
  EVAL_DEL_PAREN = 4, EVAL_TRUE = 8, EVAL_FALSE = 16, EVAL_ILLEGAL = 32,
  EVAL_INSOURCE_SYM = 64, EVAL_GLOBAL_SYM = 128, EVAL_REPORTED_SYM = 256, EVAL_RESOLVED = EVAL_TRUE | EVAL_FALSE,
  EVAL_PARSED = EVAL_RESOLVED | EVAL_KEEP
}
enum  line_type_t {
  LT_IF, LT_TRUE, LT_FALSE, LT_ELIF,
  LT_ELTRUE, LT_ELFALSE, LT_ELSE, LT_ENDIF,
  LT_PLAIN, LT_EOF, LT_DIRECTIVE_DROP, LT_DIRECTIVE_KEEP,
  LT_SENTINEL
}

Functions

void eval_result_set_value (eval_result_t *result, int_spec_t const *int_spec)
void eval_result_clear (eval_result_t *result)
bool eval_result_parsed (eval_result_t *result)

Variables

int_spec_t const int_spec_false
int_spec_t const int_spec_true

Define Documentation

#define AFFIRM_FLAGS (   eval_result,
  bits 
)    (((eval_result).flags & (bits)) == (bits))

Test whether specified flags are set in an eval_result_t

Definition at line 168 of file eval_result.h.

#define CLEAR_FLAGS (   eval_result,
  bits 
)    ((eval_result).flags &= ~(bits))

Clear flags in an eval_result_t

Definition at line 151 of file eval_result.h.

#define CLEAR_FLAGS_IF (   cond,
  eval_result,
  bits 
)    (void)((cond) ? CLEAR_FLAGS(eval_result,bits) : 0)

Clear flags in an eval_result_t if a condition is true

Definition at line 155 of file eval_result.h.

Referenced by op_or().

#define DEL_PAREN (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_DEL_PAREN)

Test whether an eval_result_t stipulates deleting superfluous parentheses

Definition at line 222 of file eval_result.h.

Referenced by eval_table(), and eval_unary().

#define DENY_FLAGS (   eval_result,
  bits 
)    (((eval_result).flags & (bits)) == 0)

Test whether specified flags are clear in an eval_result_t

Definition at line 174 of file eval_result.h.

#define EVAL_RESULT_INITOR   {0,0,0,INT_SPEC_INITOR,EVAL_PENDING,0}

Static initialiser for type eval_result_t

Definition at line 138 of file eval_result.h.

Referenced by eval_possible_symbol(), eval_result_clear(), eval_table(), eval_unary(), integer_binary_op(), op_and(), op_divide(), op_mod(), and op_or().

#define FLAGS_IN (   eval_result,
  bits 
)    ((eval_result).flags & (bits))

Get the flags in eval_result_t that match a mask

Definition at line 164 of file eval_result.h.

Referenced by op_or().

#define FLIP_FLAGS (   eval_result,
  bits 
)    ((eval_result).flags ^= (bits))

Invert the values of specified flags in an eval_result_t

Definition at line 161 of file eval_result.h.

Referenced by eval_unary().

#define GLOBAL_SYM (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_GLOBAL_SYM)

Test whether an eval_result is a symbol defined or undefined globally

Definition at line 279 of file eval_result.h.

Referenced by symbol_is_configured(), and symbol_is_global().

#define ILLEGAL (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_ILLEGAL)

Test whether an eval_result_t represents a non-expression

Definition at line 260 of file eval_result.h.

#define INSOURCE_SYM (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_INSOURCE_SYM)

Test whether an eval_result is a symbol defined or undefined in-source

Definition at line 273 of file eval_result.h.

Referenced by symbol_is_configured().

#define INT_WIDTH (   eval_result)    ((eval_result).value.width)

Return the integer width of the value of an eval result

Definition at line 193 of file eval_result.h.

#define IS_CONST (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_CONST)

Test whether an eval_result_t represents a constant.

Definition at line 189 of file eval_result.h.

Referenced by integer_binary_op(), op_divide(), and op_mod().

#define IS_FALSE (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_FALSE)

Test whether an eval_result_t represents a false expression.

Definition at line 185 of file eval_result.h.

Referenced by eval_if(), eval_table(), op_and(), and op_or().

#define IS_TRUE (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_TRUE)

Test whether an eval_result_t represents a true expression

Definition at line 180 of file eval_result.h.

Referenced by eval_if(), eval_table(), op_and(), and op_or().

#define KEEP (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_KEEP)

Test whether an eval_result_t represents an expression we can't eliminate.

Definition at line 236 of file eval_result.h.

Referenced by eval_result_parsed(), and eval_table().

#define KEEP_CONST (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_KEEP_CONST)

Test whether an eval_result_t represents a non-eliminable constant

Definition at line 245 of file eval_result.h.

Referenced by eval_if(), eval_table(), op_and(), and op_or().

#define LEGAL (   eval_result)    !ILLEGAL(eval_result)

Test whether an eval_result_t represents a legal expression

Definition at line 263 of file eval_result.h.

Referenced by eval_table().

#define REPORTED (   eval_result)    AFFIRM_FLAGS(eval_result,EVAL_REPORTED_SYM)

Test whether an eval_result_t represents a symbol that has been reported.

The test supports the option of reporting symbols only once rather than at each occurrence.

Definition at line 217 of file eval_result.h.

Referenced by symbol_reported().

#define RESOLVED (   eval_result)    !UNRESOLVED(eval_result)

Test whether an eval_result_t represents a resolved expression.

Definition at line 203 of file eval_result.h.

Referenced by eval_result_parsed(), eval_table(), eval_unary(), integer_binary_op(), op_divide(), op_mod(), and symbol_resolve().

#define SET_CONST (   eval_result)    SET_FLAGS(eval_result,EVAL_CONST)

Flag an eval_result_t as a constant

Definition at line 251 of file eval_result.h.

Referenced by eval_unary().

#define SET_DEL_PAREN (   eval_result)    SET_FLAGS(eval_result,EVAL_DEL_PAREN)

Flag an eval_result_t for deletion of superflous parentheses.

Definition at line 227 of file eval_result.h.

Referenced by eval_table(), and eval_unary().

#define SET_FLAGS (   eval_result,
  bits 
)    ((eval_result).flags |= (bits))

Set flags in an eval_result_t

Definition at line 142 of file eval_result.h.

Referenced by eval_result_set_value(), and eval_unary().

#define SET_FLAGS_IF (   cond,
  eval_result,
  bits 
)    (void)((cond) ? SET_FLAGS(eval_result,bits) : 0)

Set flags in an eval_result_t if a condition is true

Definition at line 146 of file eval_result.h.

Referenced by op_and(), and op_or().

#define SET_GLOBAL_SYM (   eval_result)    SET_FLAGS(eval_result,EVAL_GLOBAL_SYM)

Flag an eval_result as symbol defined or undefined globally

Definition at line 276 of file eval_result.h.

Referenced by symbol_define(), and symbol_undefine().

#define SET_ILLEGAL (   eval_result)    SET_FLAGS(eval_result,EVAL_ILLEGAL)

Flag an eval_result_t as a non-expression

Definition at line 254 of file eval_result.h.

Referenced by eval_table(), and eval_unary().

#define SET_INSOURCE_SYM (   eval_result)    SET_FLAGS(eval_result,EVAL_INSOURCE_SYM)

Flag an eval_result as symbol defined or undefined in-source

Definition at line 270 of file eval_result.h.

Referenced by symbol_define(), and symbol_undefine().

#define SET_KEEP (   eval_result)    SET_FLAGS(eval_result,EVAL_KEEP)

Flag an eval_result_t as an expression we can't eliminate.

Definition at line 241 of file eval_result.h.

Referenced by eval_table(), eval_unary(), and symbol_resolve().

#define SET_KEEP_CONST (   eval_result)    SET_FLAGS(eval_result,EVAL_KEEP_CONST)

Flag an eval_result_t as a non-eliminable constant

Definition at line 248 of file eval_result.h.

#define SET_KEEP_PAREN (   eval_result)    CLEAR_FLAGS(eval_result,EVAL_DEL_PAREN)

Flag an eval_result_t for retention of parentheses.

Definition at line 231 of file eval_result.h.

Referenced by eval_table().

#define SET_LEGAL (   eval_result)    CLEAR_FLAGS(eval_result,EVAL_ILLEGAL)

Flag an eval_result_t as a legal expression

Definition at line 257 of file eval_result.h.

#define SET_REPORTED (   eval_result)    SET_FLAGS(eval_result,EVAL_REPORTED_SYM)

Test whether an eval_result_t represents insoluble text.

Flag an eval_result_t as qa symbol that has been reported.

Definition at line 209 of file eval_result.h.

Referenced by report_symbol().

#define SET_UNRESOLVED (   eval_result)    CLEAR_FLAGS(eval_result,EVAL_TRUE | EVAL_FALSE)

Flag an eval_result_t as unresolved

Definition at line 266 of file eval_result.h.

#define UNRESOLVED (   eval_result)    DENY_FLAGS(eval_result,EVAL_FALSE | EVAL_TRUE)

Test whether an eval_result_t represents unresolved text.

Definition at line 198 of file eval_result.h.

Referenced by eval_unary(), and op_and().


Typedef Documentation

typedef struct eval_result eval_result_t

Structure representing the evaluation of a text item


Enumeration Type Documentation

enum eval_flags

Bit flags denoting findings of evaluation

Enumerator:
EVAL_PENDING 

Expression not evaluated Evaluated text cannot be resolved

EVAL_CONST 

Expression is a constant

EVAL_KEEP 

Expression is not to be eliminated

EVAL_KEEP_CONST 

Expression is constant not be eliminated

EVAL_DEL_PAREN 

Redundant parentheses to deleted from expression

EVAL_TRUE 

Expression evaluates as true

EVAL_FALSE 

Expression evaluates as false

EVAL_ILLEGAL 

Text is not an expression

EVAL_INSOURCE_SYM 

Text is a symbol defined or undefined in-source

EVAL_GLOBAL_SYM 

Text is a symbol defined or undefined globally, i.e. by -D or -U

EVAL_REPORTED_SYM 

Test is a symbol that has been reported

EVAL_RESOLVED 

Expression is resolved

EVAL_PARSED 

Expression has been fully parsed

Definition at line 54 of file eval_result.h.

Enumeration of types of input lines

Enumerator:
LT_IF 

An hash-if that we can't resolve

LT_TRUE 

A true hash-if

LT_FALSE 

A false hash-if

LT_ELIF 

An hash-elif that we can't resolve

LT_ELTRUE 

A true hash-elif

LT_ELFALSE 

A false hash-elif

LT_ELSE 

An hash-else that we can't resolve

LT_ENDIF 

An hash-endif

LT_PLAIN 

A non-directive line

LT_EOF 

End of file

LT_DIRECTIVE_DROP 

A directive line of no more specific type that is to be dropped

LT_DIRECTIVE_KEEP 

A directive line of no more specific type that is to be kept

LT_SENTINEL 

Sentinel

Definition at line 85 of file eval_result.h.


Function Documentation

void eval_result_clear ( eval_result_t result)

Zero all fields in an eval_result_t

Parameters:
resultIf not NULL, pointer to an eval_result_t to be cleared.

If result is NULL the function is a no-op.

Definition at line 68 of file eval_result.c.

References canonical_string_dispose(), EVAL_RESULT_INITOR, eval_result::most_resolved, eval_result::sym_def, and eval_result::sym_name.

Referenced by symbol_dispose(), symbol_init(), and symbol_resolve().

Here is the call graph for this function:

bool eval_result_parsed ( eval_result_t result)

Say whether an eval_result_t has been fully parsed.

Parameters:
resultPointer the eval_result_t to be tested.
Returns:
Return true if result satisfies either of the flags EVAL_RESOLVED or EVAL_KEEP.

Definition at line 89 of file eval_result.c.

References KEEP, and RESOLVED.

void eval_result_set_value ( eval_result_t result,
int_spec_t const *  int_spec 
)

Assign a value in an eval_result_t

Parameters:
resultPointer the the eval_result_t to which a value is to be assigned.
int_specDescriptor of the integer value to be assigned.

Definition at line 61 of file eval_result.c.

References EVAL_FALSE, EVAL_TRUE, SET_FLAGS, int_spec::val, and eval_result::value.

Referenced by eval_possible_symbol(), eval_unary(), integer_binary_op(), op_and(), op_divide(), op_mod(), op_or(), symbol_resolve(), and symbol_undefine().


Variable Documentation

Constant int_spec_t representing falsity

Definition at line 55 of file eval_result.c.

Referenced by eval_possible_symbol(), eval_unary(), op_and(), op_or(), and symbol_undefine().

Constant int_spec_t representing truth

Definition at line 58 of file eval_result.c.

Referenced by eval_unary(), and op_or().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines