tokstyle-0.0.9: TokTok C code style checker
Safe HaskellNone
LanguageHaskell2010

Tokstyle.Analysis.Symbolic

Synopsis

Documentation

data SVal Source #

A Symbolic Value represents the result of an expression.

Constructors

STop

Unknown value

SVar AccessPath

Initial value of a path

SAddr AccessPath

The address of a memory location (e.g. &a, or a literal string)

SNull

Literal NULL 0 nullptr

SBinOp BinaryOp SVal SVal 
SUnaryOp UnaryOp SVal 
SIte SVal SVal SVal

If-Then-Else (Phi node)

Instances

Instances details
Eq SVal Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

Methods

(==) :: SVal -> SVal -> Bool #

(/=) :: SVal -> SVal -> Bool #

Ord SVal Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

Methods

compare :: SVal -> SVal -> Ordering #

(<) :: SVal -> SVal -> Bool #

(<=) :: SVal -> SVal -> Bool #

(>) :: SVal -> SVal -> Bool #

(>=) :: SVal -> SVal -> Bool #

max :: SVal -> SVal -> SVal #

min :: SVal -> SVal -> SVal #

Show SVal Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

Methods

showsPrec :: Int -> SVal -> ShowS #

show :: SVal -> String #

showList :: [SVal] -> ShowS #

data Constraint Source #

A constraint on symbolic values.

Constructors

SEquals SVal SVal 
SNotEquals SVal SVal 
SBool SVal

The value is true/non-zero

data SState Source #

The symbolic state at a point in the program.

Constructors

SState 

Fields

Instances

Instances details
Eq SState Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

Methods

(==) :: SState -> SState -> Bool #

(/=) :: SState -> SState -> Bool #

Ord SState Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

Show SState Source # 
Instance details

Defined in Tokstyle.Analysis.Symbolic

assign :: AccessPath -> SVal -> SState -> SState Source #

Assign a value to a path, and handle invalidation of dependent paths.

addConstraint :: Constraint -> SState -> SState Source #

Add a new constraint to the state, with basic simplification.

canBeNull :: (SVal -> Bool) -> SVal -> SState -> Bool Source #

Solver: check if a value is known to be non-null. Takes a predicate to check if an initial SVar is known to be non-null (e.g. from declarations).

merge :: (SVal -> Bool) -> Maybe SVal -> SState -> SState -> SState Source #

Merge two symbolic states. If a condition is provided, differing values are merged into an SIte (Phi node). Otherwise, they are merged into an SIte with an inferred condition if possible, or STop (unknown) if no condition can be inferred. We also preserve non-nullness: if a path is non-null in both branches, the merged value is constrained to be non-null.

sIte :: SVal -> SVal -> SVal -> SVal Source #