resolver

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package resolver turns syntax imports into project or compiler-known package identities before type checking. Backends therefore never interpret a raw TypeRB import path on their own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectExports

func CollectExports(statements []ast.Statement) map[string]Export

func ValidateImportGraph

func ValidateImportGraph(catalog *Catalog, results map[string]Result) map[string][]diagnostic.Diagnostic

ValidateImportGraph rejects project import cycles with a deterministic path. A single cross-mode rule keeps initialization order independent of Ruby, TypeScript, or Go runtime loader behavior.

Types

type Binding

type Binding struct {
	Import  *Import
	Name    string
	Export  *Export
	Member  *Member
	Library *stdlib.Symbol
}

func (Binding) Type

func (b Binding) Type() types.Type

type Catalog

type Catalog struct {
	Modules map[string]*Module
}

func NewCatalog

func NewCatalog(modules []Module) (*Catalog, map[string][]diagnostic.Diagnostic)

type EnumVariant

type EnumVariant struct {
	Name   string
	Fields []RecordField
}

type Export

type Export struct {
	Name           string
	Kind           ExportKind
	Type           types.Type
	Parameters     []types.Type
	Required       int
	Variadic       bool
	Members        map[string]Member
	Fields         []RecordField
	EnumMembers    []string
	EnumVariants   []EnumVariant
	TypeParameters []string
	Superclass     string
	Span           token.Span
}

type ExportKind

type ExportKind string
const (
	ClassExport     ExportKind = "class"
	RecordExport    ExportKind = "record"
	EnumExport      ExportKind = "enum"
	ModuleExport    ExportKind = "module"
	InterfaceExport ExportKind = "interface"
	FunctionExport  ExportKind = "function"
	ValueExport     ExportKind = "value"
)

type Import

type Import struct {
	Node       *ast.ImportStatement
	Kind       ImportKind
	Path       string
	ModulePath string
	Alias      string
	Symbols    []string
	Definition *stdlib.Package
	Exports    map[string]Export
	Filename   string
}

func (*Import) RuntimePath

func (i *Import) RuntimePath() string

type ImportKind

type ImportKind string
const (
	StandardImport ImportKind = "standard"
	ProjectImport  ImportKind = "project"
)

type Member

type Member struct {
	Name       string
	Kind       ExportKind
	Type       types.Type
	Parameters []types.Type
	Required   int
	Variadic   bool
	Class      bool
	Readonly   bool
}

type Module

type Module struct {
	Path     string
	Filename string
	Program  *ast.Program
	Exports  map[string]Export
}

type Options

type Options struct {
	Mode          string
	SourceRoot    string
	Filename      string
	CompilerOwned bool
	Catalog       *Catalog
	Declarations  *declaration.Catalog
}

type RecordField

type RecordField struct {
	Name     string
	JSONName string
	Type     types.Type
}

type Result

type Result struct {
	Imports      map[*ast.ImportStatement]*Import
	Packages     map[string]*Import
	Symbols      map[string]Binding
	NativeSyntax bool
	Declarations *declaration.Catalog
}

func Resolve

func Resolve(program *ast.Program, options Options) (Result, []diagnostic.Diagnostic)

func (Result) ImportedType

func (r Result) ImportedType(typeName string) (Binding, bool)

func (Result) Member

func (r Result) Member(alias, name string) (Binding, bool)

func (Result) ReceiverMethod

func (r Result) ReceiverMethod(receiver types.Type, name string) (Binding, bool)

ReceiverMethod returns an implicit portable method binding. The binding is deliberately backed by the same standard package definition as its function form, even though TypeRB source does not need to import the method.

func (Result) TypeMember

func (r Result) TypeMember(typeName, name string) (Binding, bool)

Jump to

Keyboard shortcuts

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