compiler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileSourceToTypeScript added in v0.0.71

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

CompileSourceToTypeScript is the WASM adapter for browser source compilation.

Types

type CompilationResult added in v0.0.25

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 added in v0.1.0

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

CompileError wraps structured diagnostics for ordinary Go error paths.

func NewCompileError added in v0.1.0

func NewCompileError(diagnostics []Diagnostic) *CompileError

NewCompileError creates a compile error from diagnostics.

func (*CompileError) Error added in v0.1.0

func (e *CompileError) Error() string

Error returns the human-readable diagnostic summary.

type CompileRequest added in v0.1.0

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
	// BuildFlags are forwarded to the Go package loader.
	BuildFlags []string
	// DependencyMode controls whether dependencies are included in the graph.
	DependencyMode DependencyMode
	// RuntimeEmissionMode controls runtime package emission policy.
	RuntimeEmissionMode RuntimeEmissionMode
	// 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 added in v0.1.0

type CompileRequestOwner struct{}

CompileRequestOwner owns adapter input normalization and validation.

func NewCompileRequestOwner added in v0.1.0

func NewCompileRequestOwner() *CompileRequestOwner

NewCompileRequestOwner creates a compile request owner.

func (*CompileRequestOwner) NewRequest added in v0.1.0

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

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

func (*CompileRequestOwner) Validate added in v0.1.0

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

Validate returns request diagnostics that must stop compilation before output.

type CompileService added in v0.1.0

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

CompileService owns the v2 compiler pipeline.

func NewCompileService added in v0.1.0

func NewCompileService() *CompileService

NewCompileService creates a compile service with every pipeline owner.

func (*CompileService) Compile added in v0.1.0

Compile runs one request through the v2 pipeline.

func (*CompileService) LoweringOwner added in v0.1.0

func (s *CompileService) LoweringOwner() *LoweringOwner

LoweringOwner returns the lowering owner.

func (*CompileService) OverrideRegistryOwner added in v0.1.0

func (s *CompileService) OverrideRegistryOwner() *OverrideRegistryOwner

OverrideRegistryOwner returns the override registry owner.

func (*CompileService) PackageGraphOwner added in v0.1.0

func (s *CompileService) PackageGraphOwner() *PackageGraphOwner

PackageGraphOwner returns the package graph owner.

func (*CompileService) RequestOwner added in v0.1.0

func (s *CompileService) RequestOwner() *CompileRequestOwner

RequestOwner returns the compile request owner.

func (*CompileService) RuntimeContractOwner added in v0.1.0

func (s *CompileService) RuntimeContractOwner() *RuntimeContractOwner

RuntimeContractOwner returns the runtime contract owner.

func (*CompileService) SemanticModelOwner added in v0.1.0

func (s *CompileService) SemanticModelOwner() *SemanticModelOwner

SemanticModelOwner returns the semantic model owner.

func (*CompileService) TypeScriptEmitOwner added in v0.1.0

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 Config

type Config struct {

	// Dir is the working directory for the compiler.
	Dir string
	// OutputPath is the output path root.
	OutputPath string
	// BuildFlags are the Go build flags to use during package loading.
	BuildFlags []string
	// AllDependencies controls whether dependencies are included in the graph.
	AllDependencies bool
	// DisableEmitBuiltin controls whether runtime packages are emitted.
	DisableEmitBuiltin 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 added in v0.1.0

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 added in v0.1.0

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
}

Diagnostic is a structured compiler message surfaced by every adapter.

type DiagnosticSeverity added in v0.1.0

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 added in v0.1.0

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

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

type LoweringOwner added in v0.1.0

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

LoweringOwner owns conversion from the semantic model to compiler IR.

func NewLoweringOwner added in v0.1.0

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

NewLoweringOwner creates the lowering owner.

func (*LoweringOwner) Build added in v0.1.0

Build converts the semantic model into the compiler IR.

type OverrideFacts added in v0.1.1

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

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

func (*OverrideFacts) HasPackage added in v0.1.1

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

HasPackage returns true when pkgPath has a GoScript override package.

func (*OverrideFacts) IsFunctionAsync added in v0.1.1

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

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

func (*OverrideFacts) IsMethodAsync added in v0.1.1

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

IsMethodAsync returns true when override metadata marks a method async.

func (*OverrideFacts) Metadata added in v0.1.1

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

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

type OverrideMetadata added in v0.1.0

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 OverrideRegistryOwner added in v0.1.0

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

OverrideRegistryOwner owns GoScript override package metadata and copy plans.

func NewOverrideRegistryOwner added in v0.1.0

func NewOverrideRegistryOwner() *OverrideRegistryOwner

NewOverrideRegistryOwner creates the override registry owner.

func (*OverrideRegistryOwner) CopyPackages added in v0.1.0

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 added in v0.1.0

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 added in v0.1.1

Facts returns the immutable compiler-visible override facts.

func (*OverrideRegistryOwner) IsFunctionAsync added in v0.1.1

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

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

func (*OverrideRegistryOwner) IsMethodAsync added in v0.1.0

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

IsMethodAsync returns true when override metadata marks a method async.

func (*OverrideRegistryOwner) Metadata added in v0.1.0

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

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

type PackageGraph added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

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

PackageGraphOwner owns Go package loading and graph identity.

func NewPackageGraphOwner added in v0.1.0

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

NewPackageGraphOwner creates the package graph owner.

func (*PackageGraphOwner) Load added in v0.1.0

Load builds the package graph for a validated request.

func (*PackageGraphOwner) LoadTestGraph added in v0.1.1

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

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

type PackageTestFunction added in v0.1.1

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 added in v0.1.1

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 added in v0.1.1

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

PackageByPath returns the package facts for a package under test.

type PackageTestGraphPackage added in v0.1.1

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 added in v0.1.1

func (p *PackageTestGraphPackage) HasTests() bool

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

type PackageTestGraphVariant added in v0.1.1

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 added in v0.1.0

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

RuntimeContractOwner owns generated-code helper names and runtime capabilities.

func NewRuntimeContractOwner added in v0.1.0

func NewRuntimeContractOwner() *RuntimeContractOwner

NewRuntimeContractOwner creates the runtime contract owner.

func (*RuntimeContractOwner) BuiltinImport added in v0.1.0

func (o *RuntimeContractOwner) BuiltinImport() RuntimeImport

BuiltinImport returns the runtime import used by generated package modules.

func (*RuntimeContractOwner) Helper added in v0.1.0

Helper returns one runtime helper contract.

func (*RuntimeContractOwner) HelperName added in v0.1.0

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

HelperName returns the exported runtime symbol for a helper.

func (*RuntimeContractOwner) Helpers added in v0.1.0

Helpers returns every compiler-visible runtime helper contract.

func (*RuntimeContractOwner) HelpersByCategory added in v0.1.0

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

HelpersByCategory returns helper contracts in a category.

func (*RuntimeContractOwner) MissingRuntimeExports added in v0.1.1

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

MissingRuntimeExports returns helper exports absent from the real runtime source.

func (*RuntimeContractOwner) QualifiedHelper added in v0.1.0

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

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

type RuntimeEmissionMode added in v0.1.0

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 added in v0.1.0

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"
	RuntimeHelperByte      RuntimeHelper = "builtin.byte"
	RuntimeHelperLen       RuntimeHelper = "builtin.len"
	RuntimeHelperCap       RuntimeHelper = "builtin.cap"
	RuntimeHelperClear     RuntimeHelper = "builtin.clear"
	RuntimeHelperPanic     RuntimeHelper = "builtin.panic"
	RuntimeHelperRecover   RuntimeHelper = "builtin.recover"
	RuntimeHelperMin       RuntimeHelper = "builtin.min"
	RuntimeHelperMax       RuntimeHelper = "builtin.max"
	RuntimeHelperComplex   RuntimeHelper = "builtin.complex"
	RuntimeHelperReal      RuntimeHelper = "builtin.real"
	RuntimeHelperImag      RuntimeHelper = "builtin.imag"
	RuntimeHelperUint64Shl RuntimeHelper = "builtin.uint64Shl"
	RuntimeHelperUint64Shr RuntimeHelper = "builtin.uint64Shr"
	RuntimeHelperUintShr   RuntimeHelper = "builtin.uintShr"
	RuntimeHelperUint64Mul RuntimeHelper = "builtin.uint64Mul"
	RuntimeHelperUint64Add RuntimeHelper = "builtin.uint64Add"
	RuntimeHelperUint64Sub RuntimeHelper = "builtin.uint64Sub"
	RuntimeHelperUint64And RuntimeHelper = "builtin.uint64And"
	RuntimeHelperUint64Or  RuntimeHelper = "builtin.uint64Or"
	RuntimeHelperUint64Xor RuntimeHelper = "builtin.uint64Xor"

	RuntimeHelperAssignStruct      RuntimeHelper = "value.assignStruct"
	RuntimeHelperMarkAsStructValue RuntimeHelper = "value.markAsStructValue"
	RuntimeHelperCloneStructValue  RuntimeHelper = "value.cloneStructValue"
	RuntimeHelperPointerValue      RuntimeHelper = "value.pointerValue"
	RuntimeHelperArrayEqual        RuntimeHelper = "value.arrayEqual"

	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"
	RuntimeHelperSliceToArray                 RuntimeHelper = "slice.sliceToArray"
	RuntimeHelperSliceToArrayPointer          RuntimeHelper = "slice.sliceToArrayPointer"
	RuntimeHelperAppend                       RuntimeHelper = "slice.append"
	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"
	RuntimeHelperGenericBytesOrStringToString RuntimeHelper = "slice.genericBytesOrStringToString"
	RuntimeHelperIndexStringOrBytes           RuntimeHelper = "slice.indexStringOrBytes"
	RuntimeHelperSliceStringOrBytes           RuntimeHelper = "slice.sliceStringOrBytes"
	RuntimeHelperIndexRef                     RuntimeHelper = "slice.indexRef"
	RuntimeHelperIndexAddress                 RuntimeHelper = "slice.indexAddress"

	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"
	RuntimeHelperNamedValueInterfaceValue RuntimeHelper = "type.namedValueInterfaceValue"
	RuntimeHelperFunctionValue            RuntimeHelper = "type.functionValue"
	RuntimeHelperNamedFunction            RuntimeHelper = "type.namedFunction"
	RuntimeHelperGenericZero              RuntimeHelper = "type.genericZero"
	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 added in v0.1.0

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 added in v0.1.0

type RuntimeHelperContract struct {
	Helper   RuntimeHelper
	Export   string
	Category RuntimeHelperCategory
}

RuntimeHelperContract describes one helper exported by the runtime package.

type RuntimeImport added in v0.1.0

type RuntimeImport struct {
	Alias  string
	Source string
}

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

type SemanticModel added in v0.1.0

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

SemanticModel is the immutable compiler semantic surface consumed by lowering.

type SemanticModelOwner added in v0.1.0

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

SemanticModelOwner owns immutable Go semantic facts used by lowering.

func NewSemanticModelOwner added in v0.1.0

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

NewSemanticModelOwner creates the semantic model owner.

func (*SemanticModelOwner) Build added in v0.1.0

Build constructs semantic facts for a package graph.

type TypeScriptEmitOwner added in v0.1.0

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

TypeScriptEmitOwner owns deterministic TypeScript file emission.

func NewTypeScriptEmitOwner added in v0.1.0

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

NewTypeScriptEmitOwner creates the TypeScript emit owner.

func (*TypeScriptEmitOwner) Emit added in v0.1.0

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 added in v0.1.1

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

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

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