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

Tokstyle.Analysis.Scope

Description

This module implements the Scope Binding pass.

This pass traverses the AST and replaces all variable names (Text) with unique identifiers (ScopedId). This eliminates any ambiguity from name shadowing and is a prerequisite for a correct and precise points-to analysis.

Synopsis

Documentation

data ScopedId Source #

A unique identifier for a variable, including its original name and scope info.

Constructors

ScopedId 

Fields

Instances

Instances details
Eq ScopedId Source # 
Instance details

Defined in Tokstyle.Analysis.Scope

Ord ScopedId Source # 
Instance details

Defined in Tokstyle.Analysis.Scope

Show ScopedId Source # 
Instance details

Defined in Tokstyle.Analysis.Scope

Pretty ScopedId Source # 
Instance details

Defined in Tokstyle.Analysis.Scope

Methods

pretty :: ScopedId -> Doc ann #

prettyList :: [ScopedId] -> Doc ann #

data ScopeState Source #

The state for the scope analysis traversal.

Constructors

ScopeState 

Fields

Instances

Instances details
Show ScopeState Source # 
Instance details

Defined in Tokstyle.Analysis.Scope

runScopePass :: [Node (Lexeme Text)] -> ([Node (Lexeme ScopedId)], ScopeState) Source #

Runs the scope binding pass on a list of translation units.

initialScopeState :: ScopeState Source #

The initial state for the scope analysis.

dummyScopedId :: Text -> ScopedId Source #

Creates a dummy ScopedId for non-variable identifiers like struct fields.