package analysis
import "github.com/azin-lang/Azin/internal/codegen/c/analysis"
Index
- Variables
- func FunctionName(fn *ast.FuncStmt) string
-
type Analyzer
- func New(t Transpiler) *Analyzer
- func (a *Analyzer) Analyze(program *ast.Program)
- func (a *Analyzer) AnalyzeUsage(program *ast.Program)
- func (a *Analyzer) BuildCallGraph()
- func (a *Analyzer) CollectFunctions(program *ast.Program)
- func (a *Analyzer) CollectReachableTypes(program *ast.Program)
- func (a *Analyzer) CollectTypes(program *ast.Program)
- func (a *Analyzer) ComputeReachability()
- func (a *Analyzer) HasErrors() bool
- func (a *Analyzer) MarkTypeUsed(name string)
- func (a *Analyzer) RemoveUnusedFunctions(program *ast.Program)
- func (a *Analyzer) RemoveUnusedTypes(program *ast.Program)
- func (a *Analyzer) RemoveUnusedVariables(program *ast.Program)
- func (a *Analyzer) ReportError(format string, args ...any)
- func (a *Analyzer) Reset()
- func (a *Analyzer) Walk(program *ast.Program)
- func (a *Analyzer) WalkMain(program *ast.Program)
- type Builtin
- type FuncInfo
- type Transpiler
Variables
var Builtins = map[string]Builtin{ "printf": {"stdio.h"}, "fprintf": {"stdio.h"}, "sprintf": {"stdio.h"}, "snprintf": {"stdio.h"}, "scanf": {"stdio.h"}, "sscanf": {"stdio.h"}, "malloc": {"stdlib.h"}, "calloc": {"stdlib.h"}, "realloc": {"stdlib.h"}, "free": {"stdlib.h"}, "exit": {"stdlib.h"}, "strlen": {"string.h"}, "strcpy": {"string.h"}, "strcmp": {"string.h"}, "memset": {"string.h"}, "memcpy": {"string.h"}, }
Functions
func FunctionName
func FunctionName(fn *ast.FuncStmt) string
Types
type Analyzer
type Analyzer struct { Transpiler Transpiler Errors []error Functions map[string]FuncInfo Structs map[string]*ast.StructStmt Enums map[string]*ast.EnumStmt Calls map[string]map[string]struct{} ReachableFunctions map[string]struct{} TypeDependencies map[string]map[string]struct{} ReachableTypes map[string]struct{} Variables map[string]map[string]int }
func New
func New(t Transpiler) *Analyzer
func (*Analyzer) Analyze
func (a *Analyzer) Analyze(program *ast.Program)
func (*Analyzer) AnalyzeUsage
func (a *Analyzer) AnalyzeUsage(program *ast.Program)
func (*Analyzer) BuildCallGraph
func (a *Analyzer) BuildCallGraph()
func (*Analyzer) CollectFunctions
func (a *Analyzer) CollectFunctions(program *ast.Program)
func (*Analyzer) CollectReachableTypes
func (a *Analyzer) CollectReachableTypes(program *ast.Program)
CollectReachableTypes scans the AST after dead functions and dead variables have been pruned, marking only remaining types (and their field dependencies) as reachable.
func (*Analyzer) CollectTypes
func (a *Analyzer) CollectTypes(program *ast.Program)
func (*Analyzer) ComputeReachability
func (a *Analyzer) ComputeReachability()
func (*Analyzer) HasErrors
func (a *Analyzer) HasErrors() bool
func (*Analyzer) MarkTypeUsed
func (a *Analyzer) MarkTypeUsed(name string)
MarkTypeUsed resolves a struct or enum type and recursively marks all of its dependent types as used.
func (*Analyzer) RemoveUnusedFunctions
func (a *Analyzer) RemoveUnusedFunctions(program *ast.Program)
func (*Analyzer) RemoveUnusedTypes
func (a *Analyzer) RemoveUnusedTypes(program *ast.Program)
func (*Analyzer) RemoveUnusedVariables
func (a *Analyzer) RemoveUnusedVariables(program *ast.Program)
func (*Analyzer) ReportError
func (a *Analyzer) ReportError(format string, args ...any)
func (*Analyzer) Reset
func (a *Analyzer) Reset()
func (*Analyzer) Walk
func (a *Analyzer) Walk(program *ast.Program)
func (*Analyzer) WalkMain
func (a *Analyzer) WalkMain(program *ast.Program)
type Builtin
type Builtin struct { Include string }
func LookupBuiltin
func LookupBuiltin(name string) (Builtin, bool)
type FuncInfo
type FuncInfo struct { Stmt *ast.FuncStmt Index int }
type Transpiler
type Transpiler interface { RequireInclude(string) SetFunctionIndex(string, int) FunctionIndex(string) (int, bool) RegisterForwardDeclaration(string, *ast.FuncStmt) SetEnum(string) }