Documentation
¶
Index ¶
- Variables
- func CanonicalModuleID(p string) string
- func IsTempPath(path string) bool
- func NormalizeRelativeImport(currentModulePath, relativePath string) string
- type LoadedModule
- type ModuleLoader
- func (ml *ModuleLoader) CanonicalPath(path string) (string, error)
- func (ml *ModuleLoader) ConfigureStdlibResolver(cliPath string, traceEnabled, strictMode bool)
- func (ml *ModuleLoader) DeleteCached(modulePath string)
- func (ml *ModuleLoader) EvaluateExport(ref core.GlobalRef) (eval.Value, error)
- func (ml *ModuleLoader) GetExport(modulePath, symbol string) (*ast.FuncDecl, error)
- func (ml *ModuleLoader) Load(path string) (*LoadedModule, error)
- func (ml *ModuleLoader) LoadAll(roots []string) (map[string]*LoadedModule, error)
- func (ml *ModuleLoader) LoadInterface(modulePath string) (*iface.Iface, error)
- func (ml *ModuleLoader) NormalizeContent(content []byte) []byte
- func (ml *ModuleLoader) Preload(path string, loaded *LoadedModule)
- func (ml *ModuleLoader) SetModulePrefixMap(prefixMap map[string]string)
- func (ml *ModuleLoader) SetPackageResolver(resolver PackageResolver)
- func (ml *ModuleLoader) SetStrictSyntaxMode(strict bool)
- type PackageResolver
- type StdlibResolver
Constants ¶
This section is empty.
Variables ¶
var BinaryVersion = "dev"
BinaryVersion is the version of the ailang binary. Set by main.go from build-time ldflags. Used to validate stdlib version compatibility.
Functions ¶
func CanonicalModuleID ¶
CanonicalModuleID returns the canonical module ID for a path Canonical form: repo-relative, forward slashes, no .ail extension
func IsTempPath ¶
IsTempPath returns true if the given path is in a temporary directory. This is used for relaxed module matching - files in temp directories are allowed to have mismatched module declarations.
Detection is conservative: if uncertain, returns false (doesn't auto-relax).
Patterns detected:
- os.TempDir() prefix (cross-platform)
- /tmp/ prefix (Unix)
- /var/folders/ prefix (macOS)
- Windows %TEMP% prefix
- Canonical paths starting with "tmp/" (after CanonicalModuleID strips leading /)
func NormalizeRelativeImport ¶
NormalizeRelativeImport resolves a relative import against the current module's canonical path. This is module-space resolution, not filesystem resolution.
If current module is "sunholo/billing_entitlements/entitlement" and relative is "plan", the result is "sunholo/billing_entitlements/plan".
If relative contains "/" (e.g., "sub/bar"), it resolves to the same prefix: "sunholo/billing_entitlements/sub/bar".
Types ¶
type LoadedModule ¶
type LoadedModule struct {
Path string
File *ast.File
Imports []string // Module paths this module imports
Exports map[string]*ast.FuncDecl // Export table (for now, just functions)
Types map[string]*ast.TypeDecl // Exported type declarations
Constructors map[string]string // Constructor name -> Type name mapping
Core *core.Program // Core representation (after elaboration)
Iface *iface.Iface // Module interface (after type checking)
CoreTI interface{} // Type info for Core expressions (types.CoreTypeInfo, interface{} to avoid import cycle)
}
LoadedModule represents a loaded and parsed module
type ModuleLoader ¶
type ModuleLoader struct {
// contains filtered or unexported fields
}
ModuleLoader loads and caches modules
func NewModuleLoader ¶
func NewModuleLoader(basePath string) *ModuleLoader
NewModuleLoader creates a new module loader
func (*ModuleLoader) CanonicalPath ¶
func (ml *ModuleLoader) CanonicalPath(path string) (string, error)
CanonicalPath returns the canonical path for a module
func (*ModuleLoader) ConfigureStdlibResolver ¶
func (ml *ModuleLoader) ConfigureStdlibResolver(cliPath string, traceEnabled, strictMode bool)
ConfigureStdlibResolver configures the stdlib resolver with CLI flags Call this before loading any stdlib modules
func (*ModuleLoader) DeleteCached ¶
func (ml *ModuleLoader) DeleteCached(modulePath string)
DeleteCached removes a module from the loader cache, forcing re-load on next access. This is used by hot reload to invalidate stale modules.
func (*ModuleLoader) EvaluateExport ¶
EvaluateExport evaluates a specific export from a module
func (*ModuleLoader) GetExport ¶
func (ml *ModuleLoader) GetExport(modulePath, symbol string) (*ast.FuncDecl, error)
GetExport retrieves an exported symbol from a module Returns (nil, nil) if the symbol is a type or constructor (not a function)
func (*ModuleLoader) Load ¶
func (ml *ModuleLoader) Load(path string) (*LoadedModule, error)
Load loads a module by path
func (*ModuleLoader) LoadAll ¶
func (ml *ModuleLoader) LoadAll(roots []string) (map[string]*LoadedModule, error)
LoadAll loads a module and all its transitive dependencies
func (*ModuleLoader) LoadInterface ¶
func (ml *ModuleLoader) LoadInterface(modulePath string) (*iface.Iface, error)
LoadInterface loads just the interface of a module (for the linker)
func (*ModuleLoader) NormalizeContent ¶
func (ml *ModuleLoader) NormalizeContent(content []byte) []byte
NormalizeContent normalizes file content (CRLF, BOM, etc.)
func (*ModuleLoader) Preload ¶
func (ml *ModuleLoader) Preload(path string, loaded *LoadedModule)
Preload adds a pre-loaded module to the cache
This is used to inject modules that were already loaded and elaborated by the pipeline, avoiding redundant loading and elaboration.
Parameters:
- path: The module path
- loaded: The LoadedModule with Core AST already populated
func (*ModuleLoader) SetModulePrefixMap ¶
func (ml *ModuleLoader) SetModulePrefixMap(prefixMap map[string]string)
SetModulePrefixMap sets the module_prefix → package name mapping. Input is pkgName → prefix (as built by the pipeline); this method inverts it to prefix → []pkgName for fast lookup during bare import resolution. Multiple packages may share a prefix (e.g., "sunholo/docparse" and "sunholo/ailang_parse" both use module_prefix="docparse"). All are stored so the resolver can try each until one succeeds.
func (*ModuleLoader) SetPackageResolver ¶
func (ml *ModuleLoader) SetPackageResolver(resolver PackageResolver)
SetPackageResolver sets the resolver for pkg/ imports.
func (*ModuleLoader) SetStrictSyntaxMode ¶
func (ml *ModuleLoader) SetStrictSyntaxMode(strict bool)
SetStrictSyntaxMode enables or disables strict syntax mode
type PackageResolver ¶
PackageResolver resolves package imports to source file paths. Implemented by pkg.PackageLoader.
type StdlibResolver ¶
type StdlibResolver struct {
// contains filtered or unexported fields
}
StdlibResolver resolves stdlib module paths using a search path strategy
func NewStdlibResolver ¶
func NewStdlibResolver(cliPath string, traceEnabled, strictMode bool) *StdlibResolver
NewStdlibResolver creates a new stdlib resolver
func (*StdlibResolver) ResolveStdlib ¶
func (r *StdlibResolver) ResolveStdlib(moduleName string) (string, error)
ResolveStdlib resolves a stdlib module name to an absolute file path Returns the resolved path or an error with search trace