compiler

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileSourceToTypeScript

func CompileSourceToTypeScript(source string, packageName string) (string, error)

CompileSourceToTypeScript is the WASM adapter for browser source compilation.

func FormatDiagnostic

func FormatDiagnostic(diag Diagnostic) string

FormatDiagnostic returns the canonical human-readable form of one diagnostic.

func FormatDiagnostics

func FormatDiagnostics(diagnostics []Diagnostic) string

FormatDiagnostics returns the canonical human-readable diagnostic summary.

Types

type CompilationResult

type CompilationResult struct {
	// CompiledPackages contains package paths compiled to TypeScript.
	CompiledPackages []string
	// CopiedPackages contains package paths copied from override packages.
	CopiedPackages []string
	// OriginalPackages contains the package patterns or package paths requested.
	OriginalPackages []string
	// Diagnostics contains all diagnostics produced by the compile request.
	Diagnostics []Diagnostic
}

CompilationResult describes a compiler run after adapter normalization.

type CompileError

type CompileError struct {
	// Diagnostics are the structured compiler diagnostics.
	Diagnostics []Diagnostic
}

CompileError wraps structured diagnostics for ordinary Go error paths.

func NewCompileError

func NewCompileError(diagnostics []Diagnostic) *CompileError

NewCompileError creates a compile error from diagnostics.

func (*CompileError) Error

func (e *CompileError) Error() string

Error returns the human-readable diagnostic summary.

type CompileRequest

type CompileRequest struct {
	// Patterns are the Go package patterns requested by the caller.
	Patterns []string
	// Dir is the working directory for package loading.
	Dir string
	// OutputPath is the root where TypeScript output would be written.
	OutputPath string
	// CacheRoot is the explicit compiler cache root. Empty disables caching.
	CacheRoot string
	// BuildFlags are forwarded to the Go package loader.
	BuildFlags []string
	// OverrideDirs are additional GoScript override roots.
	OverrideDirs []string
	// PackageBlocklist rejects package paths in the loaded dependency closure.
	PackageBlocklist []string
	// DependencyMode controls whether dependencies are included in the graph.
	DependencyMode DependencyMode
	// RuntimeEmissionMode controls runtime package emission policy.
	RuntimeEmissionMode RuntimeEmissionMode
	// ProtobufTypeScriptBinding binds .pb.go files to sibling .pb.ts files.
	ProtobufTypeScriptBinding bool
	// Tests controls whether package loading includes Go package-test variants.
	Tests bool
	// AllDependencies controls whether the package graph should include deps.
	AllDependencies bool
	// DisableEmitBuiltin controls whether runtime packages are emitted.
	DisableEmitBuiltin bool
}

CompileRequest describes one compiler invocation after adapter normalization.

type CompileRequestOwner

type CompileRequestOwner struct{}

CompileRequestOwner owns adapter input normalization and validation.

func NewCompileRequestOwner

func NewCompileRequestOwner() *CompileRequestOwner

NewCompileRequestOwner creates a compile request owner.

func (*CompileRequestOwner) NewRequest

func (o *CompileRequestOwner) NewRequest(conf Config, patterns []string) *CompileRequest

NewRequest builds a request from public compiler config and package patterns.

func (*CompileRequestOwner) Validate

func (o *CompileRequestOwner) Validate(req *CompileRequest) []Diagnostic

Validate returns request diagnostics that must stop compilation before output.

type CompileService

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

CompileService owns the v2 compiler pipeline.

func NewCompileService

func NewCompileService(overrideDirs ...string) *CompileService

NewCompileService creates a compile service with every pipeline owner.

func (*CompileService) Compile

Compile runs one request through the v2 pipeline.

func (*CompileService) CompilerCacheOwner added in v0.2.7

func (s *CompileService) CompilerCacheOwner() *CompilerCacheOwner

CompilerCacheOwner returns the compiler cache owner.

func (*CompileService) LoweringOwner

func (s *CompileService) LoweringOwner() *LoweringOwner

LoweringOwner returns the lowering owner.

func (*CompileService) OverrideRegistryOwner

func (s *CompileService) OverrideRegistryOwner() *OverrideRegistryOwner

OverrideRegistryOwner returns the override registry owner.

func (*CompileService) PackageGraphOwner

func (s *CompileService) PackageGraphOwner() *PackageGraphOwner

PackageGraphOwner returns the package graph owner.

func (*CompileService) RequestOwner

func (s *CompileService) RequestOwner() *CompileRequestOwner

RequestOwner returns the compile request owner.

func (*CompileService) RuntimeContractOwner

func (s *CompileService) RuntimeContractOwner() *RuntimeContractOwner

RuntimeContractOwner returns the runtime contract owner.

func (*CompileService) SemanticModelOwner

func (s *CompileService) SemanticModelOwner() *SemanticModelOwner

SemanticModelOwner returns the semantic model owner.

func (*CompileService) TypeScriptEmitOwner

func (s *CompileService) TypeScriptEmitOwner() *TypeScriptEmitOwner

TypeScriptEmitOwner returns the TypeScript emit owner.

type Compiler

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

Compiler is the public Go adapter for the v2 compile service.

func NewCompiler

func NewCompiler(conf *Config, le *logrus.Entry, _ *packages.Config) (*Compiler, error)

NewCompiler builds a compiler adapter over the v2 compile service.

func (*Compiler) CompilePackages

func (c *Compiler) CompilePackages(ctx context.Context, patterns ...string) (*CompilationResult, error)

CompilePackages compiles Go package patterns through the v2 pipeline.

type CompilerCacheOwner added in v0.2.7

type CompilerCacheOwner struct{}

CompilerCacheOwner owns persistent compiler artifact lookup, replay, and store.

func NewCompilerCacheOwner added in v0.2.7

func NewCompilerCacheOwner() *CompilerCacheOwner

NewCompilerCacheOwner creates the compiler cache owner.

func (*CompilerCacheOwner) Enabled added in v0.2.7

func (o *CompilerCacheOwner) Enabled(req *CompileRequest) bool

func (*CompilerCacheOwner) Entries added in v0.2.7

func (o *CompilerCacheOwner) Entries(
	req *CompileRequest,
	graph *PackageGraph,
	overridePlan *overrideCopyPlan,
) []compilerCacheEntry

func (*CompilerCacheOwner) Replay added in v0.2.7

func (o *CompilerCacheOwner) Replay(
	ctx context.Context,
	req *CompileRequest,
	entries []compilerCacheEntry,
) (*CompilationResult, bool)

func (*CompilerCacheOwner) StoreCopied added in v0.2.7

func (o *CompilerCacheOwner) StoreCopied(
	req *CompileRequest,
	entries []compilerCacheEntry,
	plan *overrideCopyPlan,
)

func (*CompilerCacheOwner) StoreGenerated added in v0.2.7

func (o *CompilerCacheOwner) StoreGenerated(
	req *CompileRequest,
	entries []compilerCacheEntry,
	program *LoweredProgram,
	files map[string]string,
)

type Config

type Config struct {

	// Dir is the working directory for the compiler.
	Dir string
	// OutputPath is the output path root.
	OutputPath string
	// CacheRoot is the explicit compiler cache root. Empty disables caching.
	CacheRoot string
	// BuildFlags are the Go build flags to use during package loading.
	BuildFlags []string
	// OverrideDirs are additional GoScript override roots.
	OverrideDirs []string
	// PackageBlocklist rejects package paths in the loaded dependency closure.
	PackageBlocklist []string
	// AllDependencies controls whether dependencies are included in the graph.
	AllDependencies bool
	// DisableEmitBuiltin controls whether runtime packages are emitted.
	DisableEmitBuiltin bool
	// ProtobufTypeScriptBinding binds .pb.go files to sibling .pb.ts files.
	ProtobufTypeScriptBinding bool
	// contains filtered or unexported fields
}

Config is the public compiler configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the config and initializes owned defaults.

type DependencyMode

type DependencyMode string

DependencyMode describes how much of the loaded package graph to keep.

const (
	// DependencyModeRequested keeps only requested package nodes.
	DependencyModeRequested DependencyMode = "requested"
	// DependencyModeAll keeps reachable dependency package nodes.
	DependencyModeAll DependencyMode = "all"
)

type Diagnostic

type Diagnostic struct {
	// Severity is the diagnostic severity.
	Severity DiagnosticSeverity
	// Code is a stable machine-readable diagnostic code.
	Code string
	// Message is the short human-readable diagnostic.
	Message string
	// Detail carries optional longer guidance.
	Detail string
	// Position is the optional source point that caused the diagnostic.
	Position *DiagnosticPosition
}

Diagnostic is a structured compiler message surfaced by every adapter.

type DiagnosticPosition

type DiagnosticPosition struct {
	// File is the raw file identity from the compiler source owner.
	File string
	// DisplayFile is the request-relative file identity for human output.
	DisplayFile string
	// Line is the 1-based source line.
	Line int
	// Column is the 1-based source column.
	Column int
}

DiagnosticPosition identifies the source point that caused a diagnostic.

type DiagnosticSeverity

type DiagnosticSeverity string

DiagnosticSeverity is the severity of a compiler diagnostic.

const (
	// DiagnosticSeverityError marks a diagnostic that stops compilation.
	DiagnosticSeverityError DiagnosticSeverity = "error"
	// DiagnosticSeverityWarning marks a diagnostic that does not stop compilation.
	DiagnosticSeverityWarning DiagnosticSeverity = "warning"
)

type LoweredProgram

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

LoweredProgram is the compiler-owned IR consumed by TypeScript emission.

type LoweringOptions

type LoweringOptions struct {
	// SourceRoot is the request source root that may contain sibling protobuf TypeScript files.
	SourceRoot string
	// DisplayRoot is the request root used to format source file names in diagnostics.
	DisplayRoot string
	// OutputPath is the TypeScript output root used for generated relative imports.
	OutputPath string
	// ProtobufTypeScriptBinding binds .pb.go files to sibling .pb.ts files.
	ProtobufTypeScriptBinding bool
	// TrimTypeInfo drops metadata used only by reflect from named type registration payloads.
	TrimTypeInfo bool
}

LoweringOptions are request-scoped lowering switches.

type LoweringOwner

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

LoweringOwner owns conversion from the semantic model to compiler IR.

func NewLoweringOwner

func NewLoweringOwner(runtimeOwner *RuntimeContractOwner, overrideOwner *OverrideRegistryOwner) *LoweringOwner

NewLoweringOwner creates the lowering owner.

func (*LoweringOwner) Build

Build converts the semantic model into the compiler IR.

type OverrideFacts

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

OverrideFacts is the immutable compiler-visible view of GoScript overrides.

func (*OverrideFacts) HasPackage

func (f *OverrideFacts) HasPackage(pkgPath string) bool

HasPackage returns true when pkgPath has a GoScript override package.

func (*OverrideFacts) IsFunctionAsync

func (f *OverrideFacts) IsFunctionAsync(pkgPath, function string) bool

IsFunctionAsync returns true when override metadata marks a package-level function async.

func (*OverrideFacts) IsMethodAsync

func (f *OverrideFacts) IsMethodAsync(pkgPath, method string) bool

IsMethodAsync returns true when override metadata marks a method async.

func (*OverrideFacts) Metadata

func (f *OverrideFacts) Metadata(pkgPath string) OverrideMetadata

Metadata returns compiler-visible override metadata for a package path.

type OverrideMetadata

type OverrideMetadata struct {
	// Dependencies are override package dependencies.
	Dependencies []string
	// AsyncFunctions maps package-level function names to async status.
	AsyncFunctions map[string]bool
	// AsyncMethods maps Type.Method keys to async status.
	AsyncMethods map[string]bool
}

OverrideMetadata describes compiler-visible facts from a package override.

type OverrideParityVerifier

type OverrideParityVerifier struct{}

OverrideParityVerifier owns compiler-side parity checks for ledgered overrides.

func NewOverrideParityVerifier

func NewOverrideParityVerifier() *OverrideParityVerifier

NewOverrideParityVerifier creates the override parity verifier.

func (*OverrideParityVerifier) Verify

func (v *OverrideParityVerifier) Verify(
	ctx context.Context,
	graph *PackageGraph,
	facts *OverrideFacts,
) []Diagnostic

Verify checks ledgered override packages against JS/WASM Go exports and effective TypeScript package exports.

func (*OverrideParityVerifier) VerifyNoDeferred

func (v *OverrideParityVerifier) VerifyNoDeferred(facts *OverrideFacts, pkgPaths ...string) []Diagnostic

VerifyNoDeferred reports transient parity entries that remain in packages whose parity surface is expected to be closed.

type OverrideRegistryOwner

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

OverrideRegistryOwner owns GoScript override package metadata and copy plans.

func NewOverrideRegistryOwner

func NewOverrideRegistryOwner(overrideDirs ...string) *OverrideRegistryOwner

NewOverrideRegistryOwner creates the override registry owner.

func (*OverrideRegistryOwner) CopyPackages

func (o *OverrideRegistryOwner) CopyPackages(
	ctx context.Context,
	req *CompileRequest,
	plan *overrideCopyPlan,
) ([]string, []Diagnostic)

CopyPackages writes override packages from a copy plan to the request output tree.

func (*OverrideRegistryOwner) CopyPlan

func (o *OverrideRegistryOwner) CopyPlan(
	ctx context.Context,
	req *CompileRequest,
	graph *PackageGraph,
) (*overrideCopyPlan, []Diagnostic)

CopyPlan builds the ordered override package copy plan for a request.

func (*OverrideRegistryOwner) Facts

Facts returns the immutable compiler-visible override facts.

func (*OverrideRegistryOwner) IsFunctionAsync

func (o *OverrideRegistryOwner) IsFunctionAsync(pkgPath, function string) (bool, error)

IsFunctionAsync returns true when override metadata marks a package-level function async.

func (*OverrideRegistryOwner) IsMethodAsync

func (o *OverrideRegistryOwner) IsMethodAsync(pkgPath, method string) (bool, error)

IsMethodAsync returns true when override metadata marks a method async.

func (*OverrideRegistryOwner) Metadata

func (o *OverrideRegistryOwner) Metadata(pkgPath string) (*OverrideMetadata, error)

Metadata returns compiler-visible override metadata for a package path.

type PackageGraph

type PackageGraph struct {
	// RequestedPatterns are the package patterns from the compile request.
	RequestedPatterns []string
	// RequestedPackagePaths are the loaded package paths for requested patterns.
	RequestedPackagePaths []string
	// Nodes are the deterministic package graph nodes.
	Nodes []*PackageGraphNode
	// NodesByPackagePath maps package path to graph node.
	NodesByPackagePath map[string]*PackageGraphNode
	// contains filtered or unexported fields
}

PackageGraph is the immutable package graph produced for a compile request.

type PackageGraphNode

type PackageGraphNode struct {
	// ID is the go/packages package identity.
	ID string
	// PkgPath is the stable Go package path.
	PkgPath string
	// Name is the Go package name.
	Name string
	// ModulePath is the owning module path when known.
	ModulePath string
	// ModuleDir is the owning module directory when known.
	ModuleDir string
	// ForTest is the package path under test for Go test variants.
	ForTest string
	// GoFiles are the package source files.
	GoFiles []string
	// CompiledGoFiles are files selected by build constraints.
	CompiledGoFiles []string
	// Imports are imported package paths.
	Imports []string
	// Requested marks packages matched by request patterns.
	Requested bool
	// OverrideCandidate marks packages with a matching GoScript override package.
	OverrideCandidate bool
}

PackageGraphNode is one package in the loaded graph.

type PackageGraphOwner

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

PackageGraphOwner owns Go package loading and graph identity.

func NewPackageGraphOwner

func NewPackageGraphOwner(overrideOwners ...*OverrideRegistryOwner) *PackageGraphOwner

NewPackageGraphOwner creates the package graph owner.

func (*PackageGraphOwner) Load

Load builds the package graph for a validated request.

func (*PackageGraphOwner) LoadIdentity added in v0.2.7

func (o *PackageGraphOwner) LoadIdentity(ctx context.Context, req *CompileRequest) (*PackageGraph, []Diagnostic)

LoadIdentity builds the package identity graph needed for cache lookup.

func (*PackageGraphOwner) LoadTestGraph

func (o *PackageGraphOwner) LoadTestGraph(ctx context.Context, req *CompileRequest) (*PackageTestGraph, []Diagnostic)

LoadTestGraph builds package-scoped test graph facts for a validated request.

type PackageTestFunction

type PackageTestFunction struct {
	// Name is the Go TestXxx function name.
	Name string
	// PackagePath is the package variant that exports the function.
	PackagePath string
}

PackageTestFunction describes one discovered ordinary Go test function.

type PackageTestGraph

type PackageTestGraph struct {
	// RequestedPatterns are the package patterns from the compile request.
	RequestedPatterns []string
	// Packages are deterministic package-test facts keyed by package under test.
	Packages []*PackageTestGraphPackage
	// contains filtered or unexported fields
}

PackageTestGraph is the package-scoped graph used by GoScript test runners.

func (*PackageTestGraph) PackageByPath

func (g *PackageTestGraph) PackageByPath(path string) *PackageTestGraphPackage

PackageByPath returns the package facts for a package under test.

type PackageTestGraphPackage

type PackageTestGraphPackage struct {
	// PackagePath is the package under test.
	PackagePath string
	// PackageName is the base package name.
	PackageName string
	// PackageID is the go/packages package identity for the package under test.
	PackageID string
	// GoFiles are the package source files.
	GoFiles []string
	// CompiledGoFiles are files selected by build constraints.
	CompiledGoFiles []string
	// SamePackageTests is the same-package test variant when present.
	SamePackageTests *PackageTestGraphVariant
	// ExternalPackageTests is the external-package test variant when present.
	ExternalPackageTests *PackageTestGraphVariant
	// Diagnostics are package or variant load diagnostics attached to this package.
	Diagnostics []Diagnostic
}

PackageTestGraphPackage describes one requested package under test.

func (*PackageTestGraphPackage) HasTests

func (p *PackageTestGraphPackage) HasTests() bool

HasTests returns true when the package has any loaded test variant.

type PackageTestGraphVariant

type PackageTestGraphVariant struct {
	// ID is the go/packages package identity.
	ID string
	// PkgPath is the stable Go package path for this variant.
	PkgPath string
	// Name is the Go package name for this variant.
	Name string
	// ForTest is the package path this variant tests.
	ForTest string
	// GoFiles are the package source files.
	GoFiles []string
	// CompiledGoFiles are files selected by build constraints.
	CompiledGoFiles []string
	// Imports are packages imported directly by this test variant.
	Imports []string
	// Diagnostics are load diagnostics attached to this variant.
	Diagnostics []Diagnostic
	// Tests are ordinary TestXxx functions discovered in this variant.
	Tests []PackageTestFunction
}

PackageTestGraphVariant describes one Go test package variant.

type RuntimeContractOwner

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

RuntimeContractOwner owns generated-code helper names and runtime capabilities.

func NewRuntimeContractOwner

func NewRuntimeContractOwner() *RuntimeContractOwner

NewRuntimeContractOwner creates the runtime contract owner.

func (*RuntimeContractOwner) BuiltinImport

func (o *RuntimeContractOwner) BuiltinImport() RuntimeImport

BuiltinImport returns the runtime import used by generated package modules.

func (*RuntimeContractOwner) Helper

Helper returns one runtime helper contract.

func (*RuntimeContractOwner) HelperName

func (o *RuntimeContractOwner) HelperName(helper RuntimeHelper) (string, bool)

HelperName returns the exported runtime symbol for a helper.

func (*RuntimeContractOwner) Helpers

Helpers returns every compiler-visible runtime helper contract.

func (*RuntimeContractOwner) HelpersByCategory

func (o *RuntimeContractOwner) HelpersByCategory(category RuntimeHelperCategory) []RuntimeHelperContract

HelpersByCategory returns helper contracts in a category.

func (*RuntimeContractOwner) MissingRuntimeExports

func (o *RuntimeContractOwner) MissingRuntimeExports() ([]string, error)

MissingRuntimeExports returns helper exports absent from the real runtime source.

func (*RuntimeContractOwner) QualifiedHelper

func (o *RuntimeContractOwner) QualifiedHelper(helper RuntimeHelper) string

QualifiedHelper returns a generated-code reference to a runtime helper.

type RuntimeEmissionMode

type RuntimeEmissionMode string

RuntimeEmissionMode describes how runtime packages should be handled.

const (
	// RuntimeEmissionModeEmit emits required runtime packages with output.
	RuntimeEmissionModeEmit RuntimeEmissionMode = "emit"
	// RuntimeEmissionModeReference references runtime packages without emitting them.
	RuntimeEmissionModeReference RuntimeEmissionMode = "reference"
)

type RuntimeHelper

type RuntimeHelper string

RuntimeHelper identifies one compiler-visible helper exported by @goscript/builtin.

const (
	RuntimeHelperPrintln      RuntimeHelper = "builtin.println"
	RuntimeHelperPrint        RuntimeHelper = "builtin.print"
	RuntimeHelperInt          RuntimeHelper = "builtin.int"
	RuntimeHelperUint         RuntimeHelper = "builtin.uint"
	RuntimeHelperInt64        RuntimeHelper = "builtin.int64"
	RuntimeHelperUint64       RuntimeHelper = "builtin.uint64"
	RuntimeHelperByte         RuntimeHelper = "builtin.byte"
	RuntimeHelperFloat32      RuntimeHelper = "builtin.float32"
	RuntimeHelperLen          RuntimeHelper = "builtin.len"
	RuntimeHelperCap          RuntimeHelper = "builtin.cap"
	RuntimeHelperClear        RuntimeHelper = "builtin.clear"
	RuntimeHelperPanic        RuntimeHelper = "builtin.panic"
	RuntimeHelperRecover      RuntimeHelper = "builtin.recover"
	RuntimeHelperRecovered    RuntimeHelper = "builtin.recovered"
	RuntimeHelperMin          RuntimeHelper = "builtin.min"
	RuntimeHelperMax          RuntimeHelper = "builtin.max"
	RuntimeHelperComplex      RuntimeHelper = "builtin.complex"
	RuntimeHelperComplex64    RuntimeHelper = "builtin.complex64"
	RuntimeHelperReal         RuntimeHelper = "builtin.real"
	RuntimeHelperImag         RuntimeHelper = "builtin.imag"
	RuntimeHelperUint64Shl    RuntimeHelper = "builtin.uint64Shl"
	RuntimeHelperUint64Shr    RuntimeHelper = "builtin.uint64Shr"
	RuntimeHelperInt64Shl     RuntimeHelper = "builtin.int64Shl"
	RuntimeHelperInt64Shr     RuntimeHelper = "builtin.int64Shr"
	RuntimeHelperUintShr      RuntimeHelper = "builtin.uintShr"
	RuntimeHelperUint64Div    RuntimeHelper = "builtin.uint64Div"
	RuntimeHelperUint64Mod    RuntimeHelper = "builtin.uint64Mod"
	RuntimeHelperUint64Mul    RuntimeHelper = "builtin.uint64Mul"
	RuntimeHelperUint64Add    RuntimeHelper = "builtin.uint64Add"
	RuntimeHelperUint64Sub    RuntimeHelper = "builtin.uint64Sub"
	RuntimeHelperUint64And    RuntimeHelper = "builtin.uint64And"
	RuntimeHelperUint64AndNot RuntimeHelper = "builtin.uint64AndNot"
	RuntimeHelperUint64Or     RuntimeHelper = "builtin.uint64Or"
	RuntimeHelperUint64Xor    RuntimeHelper = "builtin.uint64Xor"
	RuntimeHelperInt64Div     RuntimeHelper = "builtin.int64Div"
	RuntimeHelperInt64Mod     RuntimeHelper = "builtin.int64Mod"
	RuntimeHelperInt64Mul     RuntimeHelper = "builtin.int64Mul"
	RuntimeHelperInt64Add     RuntimeHelper = "builtin.int64Add"
	RuntimeHelperInt64Sub     RuntimeHelper = "builtin.int64Sub"
	RuntimeHelperInt64And     RuntimeHelper = "builtin.int64And"
	RuntimeHelperInt64AndNot  RuntimeHelper = "builtin.int64AndNot"
	RuntimeHelperInt64Or      RuntimeHelper = "builtin.int64Or"
	RuntimeHelperInt64Xor     RuntimeHelper = "builtin.int64Xor"

	RuntimeHelperAssignStruct          RuntimeHelper = "value.assignStruct"
	RuntimeHelperMarkAsStructValue     RuntimeHelper = "value.markAsStructValue"
	RuntimeHelperCloneStructValue      RuntimeHelper = "value.cloneStructValue"
	RuntimeHelperCloneArrayValue       RuntimeHelper = "value.cloneArrayValue"
	RuntimeHelperPointerValue          RuntimeHelper = "value.pointerValue"
	RuntimeHelperPointerValueOrNil     RuntimeHelper = "value.pointerValueOrNil"
	RuntimeHelperArrayEqual            RuntimeHelper = "value.arrayEqual"
	RuntimeHelperNamedStructConversion RuntimeHelper = "value.namedStructConversion"
	RuntimeHelperUnsafePointerCast     RuntimeHelper = "value.unsafePointerCast"
	RuntimeHelperComparableEqual       RuntimeHelper = "value.comparableEqual"
	RuntimeHelperPointerEqual          RuntimeHelper = "value.pointerEqual"

	RuntimeHelperVarRef                RuntimeHelper = "varref.varRef"
	RuntimeHelperFieldRef              RuntimeHelper = "varref.fieldRef"
	RuntimeHelperUnref                 RuntimeHelper = "varref.unref"
	RuntimeHelperIsVarRef              RuntimeHelper = "varref.isVarRef"
	RuntimeHelperUnsupportedPointerRef RuntimeHelper = "varref.unsupportedPointerRef"

	RuntimeHelperMakeSlice                    RuntimeHelper = "slice.makeSlice"
	RuntimeHelperGoSlice                      RuntimeHelper = "slice.goSlice"
	RuntimeHelperArrayToSlice                 RuntimeHelper = "slice.arrayToSlice"
	RuntimeHelperArrayPointerFromIndexRef     RuntimeHelper = "slice.arrayPointerFromIndexRef"
	RuntimeHelperSliceToArray                 RuntimeHelper = "slice.sliceToArray"
	RuntimeHelperSliceToArrayPointer          RuntimeHelper = "slice.sliceToArrayPointer"
	RuntimeHelperAppend                       RuntimeHelper = "slice.append"
	RuntimeHelperAppendSlice                  RuntimeHelper = "slice.appendSlice"
	RuntimeHelperByteSliceHint                RuntimeHelper = "slice.byteSliceHint"
	RuntimeHelperAppendZero                   RuntimeHelper = "slice.appendZero"
	RuntimeHelperAppendZeros                  RuntimeHelper = "slice.appendZeros"
	RuntimeHelperCopy                         RuntimeHelper = "slice.copy"
	RuntimeHelperAsArray                      RuntimeHelper = "slice.asArray"
	RuntimeHelperStringToRunes                RuntimeHelper = "slice.stringToRunes"
	RuntimeHelperRangeString                  RuntimeHelper = "slice.rangeString"
	RuntimeHelperStringToRune                 RuntimeHelper = "slice.stringToRune"
	RuntimeHelperRunesToString                RuntimeHelper = "slice.runesToString"
	RuntimeHelperStringToBytes                RuntimeHelper = "slice.stringToBytes"
	RuntimeHelperBytesToString                RuntimeHelper = "slice.bytesToString"
	RuntimeHelperStringEqual                  RuntimeHelper = "slice.stringEqual"
	RuntimeHelperStringCompare                RuntimeHelper = "slice.stringCompare"
	RuntimeHelperStringHeaderRef              RuntimeHelper = "slice.stringHeaderRef"
	RuntimeHelperSliceHeaderRef               RuntimeHelper = "slice.sliceHeaderRef"
	RuntimeHelperGenericBytesOrStringToString RuntimeHelper = "slice.genericBytesOrStringToString"
	RuntimeHelperIndexStringOrBytes           RuntimeHelper = "slice.indexStringOrBytes"
	RuntimeHelperArrayIndex                   RuntimeHelper = "slice.arrayIndex"
	RuntimeHelperSliceStringOrBytes           RuntimeHelper = "slice.sliceStringOrBytes"
	RuntimeHelperIndexRef                     RuntimeHelper = "slice.indexRef"
	RuntimeHelperIndexAddress                 RuntimeHelper = "slice.indexAddress"
	RuntimeHelperIndexByteAddress             RuntimeHelper = "slice.indexByteAddress"
	RuntimeHelperUnsafePointerRef             RuntimeHelper = "slice.unsafePointerRef"

	RuntimeHelperMakeMap        RuntimeHelper = "map.makeMap"
	RuntimeHelperMapGet         RuntimeHelper = "map.mapGet"
	RuntimeHelperMapSet         RuntimeHelper = "map.mapSet"
	RuntimeHelperMapHas         RuntimeHelper = "map.mapHas"
	RuntimeHelperDeleteMapEntry RuntimeHelper = "map.deleteMapEntry"

	RuntimeHelperNewError           RuntimeHelper = "error.newError"
	RuntimeHelperToGoError          RuntimeHelper = "error.toGoError"
	RuntimeHelperWrapPrimitiveError RuntimeHelper = "error.wrapPrimitiveError"

	RuntimeHelperTypeKind                 RuntimeHelper = "type.TypeKind"
	RuntimeHelperRegisterStructType       RuntimeHelper = "type.registerStructType"
	RuntimeHelperRegisterInterfaceType    RuntimeHelper = "type.registerInterfaceType"
	RuntimeHelperGetTypeByName            RuntimeHelper = "type.getTypeByName"
	RuntimeHelperTypeAssert               RuntimeHelper = "type.typeAssert"
	RuntimeHelperTypeAssertTuple          RuntimeHelper = "type.typeAssertTuple"
	RuntimeHelperMustTypeAssert           RuntimeHelper = "type.mustTypeAssert"
	RuntimeHelperIs                       RuntimeHelper = "type.is"
	RuntimeHelperTypeSwitch               RuntimeHelper = "type.typeSwitch"
	RuntimeHelperTypedNil                 RuntimeHelper = "type.typedNil"
	RuntimeHelperInterfaceValue           RuntimeHelper = "type.interfaceValue"
	RuntimeHelperBasicInterfaceValue      RuntimeHelper = "type.basicInterfaceValue"
	RuntimeHelperNamedValueInterfaceValue RuntimeHelper = "type.namedValueInterfaceValue"
	RuntimeHelperCallInterfaceMethod      RuntimeHelper = "type.callInterfaceMethod"
	RuntimeHelperFunctionValue            RuntimeHelper = "type.functionValue"
	RuntimeHelperNamedFunction            RuntimeHelper = "type.namedFunction"
	RuntimeHelperGenericZero              RuntimeHelper = "type.genericZero"
	RuntimeHelperGenericTypeArgsMarker    RuntimeHelper = "type.genericTypeArgsMarker"
	RuntimeHelperStripGenericTypeArgs     RuntimeHelper = "type.stripGenericTypeArgs"
	RuntimeHelperCallGenericMethod        RuntimeHelper = "type.callGenericMethod"

	RuntimeHelperMakeChannel     RuntimeHelper = "channel.makeChannel"
	RuntimeHelperMakeChannelRef  RuntimeHelper = "channel.makeChannelRef"
	RuntimeHelperChanSend        RuntimeHelper = "channel.chanSend"
	RuntimeHelperChanRecv        RuntimeHelper = "channel.chanRecv"
	RuntimeHelperChanRecvWithOk  RuntimeHelper = "channel.chanRecvWithOk"
	RuntimeHelperSelectStatement RuntimeHelper = "channel.selectStatement"

	RuntimeHelperDisposableStack      RuntimeHelper = "defer.DisposableStack"
	RuntimeHelperAsyncDisposableStack RuntimeHelper = "defer.AsyncDisposableStack"

	RuntimeHelperGetHostRuntime      RuntimeHelper = "host.getHostRuntime"
	RuntimeHelperWriteHostStdoutText RuntimeHelper = "host.writeHostStdoutText"
	RuntimeHelperWriteHostStderrText RuntimeHelper = "host.writeHostStderrText"
	RuntimeHelperIsMainScript        RuntimeHelper = "host.isMainScript"
)

type RuntimeHelperCategory

type RuntimeHelperCategory string

RuntimeHelperCategory names a runtime helper family owned by the contract.

const (
	RuntimeHelperCategoryBuiltin RuntimeHelperCategory = "builtin"
	RuntimeHelperCategoryValue   RuntimeHelperCategory = "value"
	RuntimeHelperCategoryVarRef  RuntimeHelperCategory = "varref"
	RuntimeHelperCategorySlice   RuntimeHelperCategory = "slice"
	RuntimeHelperCategoryMap     RuntimeHelperCategory = "map"
	RuntimeHelperCategoryError   RuntimeHelperCategory = "error"
	RuntimeHelperCategoryType    RuntimeHelperCategory = "type"
	RuntimeHelperCategoryChannel RuntimeHelperCategory = "channel"
	RuntimeHelperCategoryDefer   RuntimeHelperCategory = "defer"
	RuntimeHelperCategoryHost    RuntimeHelperCategory = "host"
)

type RuntimeHelperContract

type RuntimeHelperContract struct {
	Helper   RuntimeHelper
	Export   string
	Category RuntimeHelperCategory
}

RuntimeHelperContract describes one helper exported by the runtime package.

type RuntimeImport

type RuntimeImport struct {
	Alias  string
	Source string
}

RuntimeImport is a generated TypeScript import owned by the runtime contract.

type SemanticModel

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

SemanticModel is the immutable compiler semantic surface consumed by lowering.

type SemanticModelOwner

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

SemanticModelOwner owns immutable Go semantic facts used by lowering.

func NewSemanticModelOwner

func NewSemanticModelOwner(overrideOwners ...*OverrideRegistryOwner) *SemanticModelOwner

NewSemanticModelOwner creates the semantic model owner.

func (*SemanticModelOwner) Build

Build constructs semantic facts for a package graph.

type TypeScriptEmitOwner

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

TypeScriptEmitOwner owns deterministic TypeScript file emission.

func NewTypeScriptEmitOwner

func NewTypeScriptEmitOwner(runtimeOwners ...*RuntimeContractOwner) *TypeScriptEmitOwner

NewTypeScriptEmitOwner creates the TypeScript emit owner.

func (*TypeScriptEmitOwner) Emit

func (o *TypeScriptEmitOwner) Emit(
	ctx context.Context,
	req *CompileRequest,
	program *LoweredProgram,
) ([]string, []Diagnostic)

Emit writes a lowered program to the configured TypeScript output tree.

func (*TypeScriptEmitOwner) EmitToMemory

func (o *TypeScriptEmitOwner) EmitToMemory(
	ctx context.Context,
	program *LoweredProgram,
) (map[string]string, []Diagnostic)

EmitToMemory renders a lowered program into deterministic slash-path files.

func (*TypeScriptEmitOwner) WriteFiles added in v0.2.7

func (o *TypeScriptEmitOwner) WriteFiles(
	ctx context.Context,
	req *CompileRequest,
	program *LoweredProgram,
	files map[string]string,
) ([]string, []Diagnostic)

WriteFiles writes an in-memory emitted file tree to the request output root.

Directories

Path Synopsis
Package gotest owns GoScript package-test execution.
Package gotest owns GoScript package-test execution.
Package wasm provides the WASM-friendly compiler adapter surface.
Package wasm provides the WASM-friendly compiler adapter surface.

Jump to

Keyboard shortcuts

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