Documentation
¶
Index ¶
- func GetSecurityCategory(qualifiedName string) string
- func GetSliceGenericClass(qualifiedName string) string
- func GetStdlibEntry(name string) (goStdlibEntry, bool)
- func IsKnownInterface(qualifiedName string) bool
- type Analyzer
- type Scope
- type Symbol
- type SymbolKind
- type SymbolTable
- type TypeInfo
- type TypeKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSecurityCategory ¶ added in v0.0.16
GetSecurityCategory returns the security check category for a stdlib function (e.g., "sql", "html", "fetch", "files", "redirect", "shell"), or "" if none.
func GetSliceGenericClass ¶ added in v0.0.16
GetSliceGenericClass returns the generic classification for a stdlib/slice function: "T" (uses any), "K" (uses any2), "TK" (uses both), or "" (not generic).
func GetStdlibEntry ¶ added in v0.0.15
GetStdlibEntry returns the Kukicha stdlib registry entry for the given qualified name (e.g., "string.PadRight"). Returns the entry and true if found.
func IsKnownInterface ¶ added in v0.0.16
IsKnownInterface returns true if the qualified type name is a known interface from either the Go stdlib or the Kukicha stdlib registries.
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer performs semantic analysis on the AST
func NewWithFile ¶ added in v0.0.5
NewWithFile creates a new semantic analyzer with the source file path. The file path is used to allow Kukicha stdlib packages to use Go stdlib names.
func (*Analyzer) ExprTypes ¶ added in v0.0.13
func (a *Analyzer) ExprTypes() map[ast.Expression]*TypeInfo
ExprTypes returns the inferred types for expressions. Call after Analyze() to pass these to codegen via SetExprTypes.
func (*Analyzer) ReturnCounts ¶ added in v0.0.2
func (a *Analyzer) ReturnCounts() map[ast.Expression]int
ReturnCounts returns the inferred return counts for expressions. Call after Analyze() to pass these to codegen.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope represents a lexical scope
type Symbol ¶
type Symbol struct {
Name string
Kind SymbolKind
Type *TypeInfo
Defined ast.Position
Mutable bool
Exported bool
}
Symbol represents a symbol in the symbol table
type SymbolKind ¶
type SymbolKind int
SymbolKind represents the kind of symbol
const ( SymbolVariable SymbolKind = iota SymbolParameter SymbolFunction SymbolType SymbolInterface SymbolConst )
func (SymbolKind) String ¶
func (sk SymbolKind) String() string
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable manages scopes and symbols
func (*SymbolTable) CurrentScope ¶
func (st *SymbolTable) CurrentScope() *Scope
CurrentScope returns the current scope
func (*SymbolTable) Define ¶
func (st *SymbolTable) Define(symbol *Symbol) error
Define adds a symbol to the current scope
func (*SymbolTable) ExitScope ¶
func (st *SymbolTable) ExitScope()
ExitScope removes the current scope
func (*SymbolTable) Resolve ¶
func (st *SymbolTable) Resolve(name string) *Symbol
Resolve looks up a symbol
type TypeInfo ¶
type TypeInfo struct {
Kind TypeKind
Name string // For named types and placeholders
ElementType *TypeInfo // For lists, channels, references
KeyType *TypeInfo // For maps
ValueType *TypeInfo // For maps
Params []*TypeInfo // For functions
Returns []*TypeInfo // For functions
Constraint string // For placeholders: "any", "comparable", "cmp.Ordered"
Variadic bool // For functions: true if last param is variadic
ParamNames []string // For functions: parameter names (for named argument validation)
DefaultCount int // For functions: number of parameters with default values
Fields map[string]*TypeInfo // For structs: field name → field type
Methods map[string]*TypeInfo // For structs: method name → function TypeInfo
}
TypeInfo represents type information
type TypeKind ¶
type TypeKind int
TypeKind represents the kind of type
const ( TypeKindUnknown TypeKind = iota TypeKindInt TypeKindFloat TypeKindString TypeKindBool TypeKindList TypeKindMap TypeKindChannel TypeKindReference TypeKindFunction TypeKindStruct TypeKindInterface TypeKindNamed TypeKindPlaceholder // For generic type placeholders (element, item, etc.) TypeKindNil // For the 'empty' keyword (nil) )