module

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package module implements module loading and dependency resolution for AILANG.

Package module provides path resolution utilities for AILANG modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader handles module loading and dependency resolution

func NewLoader

func NewLoader() *Loader

NewLoader creates a new module loader

func (*Loader) DumpModules

func (l *Loader) DumpModules(w io.Writer)

Writer interface for dumping module information

func (*Loader) GetDependencyGraph

func (l *Loader) GetDependencyGraph() map[string][]string

GetDependencyGraph returns the full dependency graph

func (*Loader) Load

func (l *Loader) Load(importPath string) (*Module, error)

Load loads a module by its import path

func (*Loader) LoadFile

func (l *Loader) LoadFile(filePath string) (*Module, error)

LoadFile loads a module from a specific file path

func (*Loader) TopologicalSort

func (l *Loader) TopologicalSort() ([]string, error)

TopologicalSort returns modules in dependency order

type Module

type Module struct {
	// Identity is the canonical module path (e.g., "std/list", "data/tree")
	Identity string

	// FilePath is the absolute path to the module file
	FilePath string

	// AST is the parsed module AST
	AST *ast.Module

	// Program is the full parsed program including the module
	Program *ast.Program

	// Dependencies are the modules this module imports
	Dependencies []string

	// Exports are the symbols exported by this module
	Exports map[string]ast.Node
}

Module represents a parsed AILANG module

type ModuleError

type ModuleError struct {
	Code    string   // Error code (e.g., LDR001)
	Message string   // Human-readable message
	Path    string   // Module path that caused the error
	Cycle   []string // For circular dependencies
	Trace   []string // Resolution trace
	Cause   error    // Underlying error
}

ModuleError represents a module loading error with structured information

func (*ModuleError) Error

func (e *ModuleError) Error() string

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver handles module path resolution with platform-specific normalization

func NewResolver

func NewResolver() *Resolver

NewResolver creates a new path resolver

func (*Resolver) GetModuleIdentity

func (r *Resolver) GetModuleIdentity(filePath string) (string, error)

GetModuleIdentity derives a module identity from a file path

func (*Resolver) GetResolutionOrder

func (r *Resolver) GetResolutionOrder(importPath, currentFile string) []string

GetResolutionOrder returns the order in which paths will be searched

func (*Resolver) NormalizePath

func (r *Resolver) NormalizePath(path string) (string, error)

NormalizePath normalizes a file path for the current platform

func (*Resolver) ResolveImport

func (r *Resolver) ResolveImport(importPath string, currentFile string) (string, error)

ResolveImport resolves an import path to a file path

func (*Resolver) ValidateModuleName

func (r *Resolver) ValidateModuleName(declaredName, filePath string) error

ValidateModuleName checks if a module name matches its expected name based on file path

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL