compiler

package
v0.3.33 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package compiler owns the public compilation pipeline.

Index

Constants

View Source
const MainFunction = "main"

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer added in v0.3.11

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

Analyzer retains immutable compiler inputs that can be reused by repeated project analysis. AnalyzeProject remains the one-shot compatibility entry point; long-lived clients such as the compiler service and REPL should own one Analyzer for the lifetime of their project snapshot.

func NewAnalyzer added in v0.3.11

func NewAnalyzer() *Analyzer

func (*Analyzer) AnalyzeProject added in v0.3.11

func (a *Analyzer) AnalyzeProject(sources []SourceUnit, options Options) ([]*Artifact, error)

AnalyzeProject returns checked semantic artifacts without backend output, reusing prepared syntax trees and dependency-aware semantic state.

type Artifact

type Artifact struct {
	Filename        string
	Mode            string
	AST             *ast.Program
	IR              *ir.Program
	Output          []byte
	SourceMap       sourcemap.Map
	CompilerOwned   bool
	Official        bool
	ExternalPackage bool
	// CompilerGeneratedStart is the byte offset at which virtual package
	// extension source begins. Interactive consumers use it to distinguish
	// authored submissions from helper declarations loaded as definitions.
	CompilerGeneratedStart int
	// contains filtered or unexported fields
}

func AnalyzeProject added in v0.2.31

func AnalyzeProject(sources []SourceUnit, options Options) ([]*Artifact, error)

AnalyzeProject parses every unit before resolving or checking any body. It establishes the complete project catalog, import graph, exported signature environment, package integrations, typed IR, and backend-owned validation without generating backend source. Returned artifacts therefore have empty Output and SourceMap fields.

func Compile

func Compile(filename string, source []byte, mode string) (*Artifact, error)

func CompileProject

func CompileProject(sources []SourceUnit, options Options) ([]*Artifact, error)

CompileProject analyzes every source unit and then generates target-language output for the resulting typed IR. Editor integrations that do not consume generated output should use AnalyzeProject so diagnostics and semantic artifacts do not pay the backend generation cost.

func CompileWithOptions

func CompileWithOptions(filename string, source []byte, options Options) (*Artifact, error)

type CompileError

type CompileError struct {
	Filename    string
	Diagnostics []diagnostic.Diagnostic
}

func NewCompileError added in v0.2.4

func NewCompileError(filename string, fallback diagnostic.Code, items []diagnostic.Diagnostic) *CompileError

func (*CompileError) Error

func (e *CompileError) Error() string

type CompilerGeneratedSource added in v0.3.12

type CompilerGeneratedSource struct {
	ID     string
	Source []byte
	Origin token.Span
}

type Options

type Options struct {
	Mode                 string
	Package              string
	ModulePath           string
	GoModule             string
	RubyLoader           string
	TypeScriptRuntime    string
	SourceRoot           string
	ProjectRoot          string
	PackageOptions       map[string][]byte
	PackageAliases       map[string]string
	JobsConfiguration    string
	AllowUnusedImports   bool
	InteractiveModule    string
	NativePackages       *nativepackage.Catalog
	DeclarationProviders []declarationproviderhost.Source
}

type SourceUnit

type SourceUnit struct {
	Filename        string
	Source          []byte
	ModulePath      string
	Package         string
	PackageAliases  map[string]string
	CompilerOwned   bool
	Official        bool
	ExternalPackage bool
	// DeclarationProvider marks a package root module whose import activates a
	// fixed external declaration catalog. The module still owns ordinary target
	// runtime loading through its authored TypeRB source.
	DeclarationProvider bool
	// TestRegistration moves top-level test suites into this generated
	// function. An empty value keeps ordinary source behavior.
	TestRegistration string
	// MainReplacement disables automatic application startup while preserving
	// the rest of a module for a test build.
	MainReplacement string
	// CompilerGeneratedSources are virtual TypeRB fragments returned by a
	// package extension. They are parsed, resolved, checked, and lowered with
	// the owning module but remain distinct from the authored source for
	// diagnostics and incremental cache identity.
	CompilerGeneratedSources []CompilerGeneratedSource
}

Jump to

Keyboard shortcuts

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