compiler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(md protoreflect.MessageDescriptor, options Options) *tdp.Type

Compile compiles a descriptor into a [Type], for optimized parsing.

Panics if md is too complicated (i.e. it exceeds internal limitations for the compiler).

Types

type Archetype

type Archetype struct {
	// The Layout for the field's storage in the message.
	Layout layout.Layout
	// Bits to allocate for this field.
	Bits uint32

	// Set if this is a Oneof field.
	Oneof bool

	// The Getter thunk for this field.
	//
	// This func MUST be a reference to a function or a global closure, so that
	// it is not a GC-managed pointer.
	Getter Getter

	// Parsers available for different forms of this field.
	Parsers []Parser
}

Archetype represents a class of fields that have the same layout within a *message. This includes parsing and access information.

Archetypes are used to organize field allocation and parsing strategies for use in the construction of a [hyperpb.Type].

type ExtensionMap

ExtensionMap implements ExtensionResolver using a map.

func ExtensionsFromFile

func ExtensionsFromFile(files *protoregistry.Files) ExtensionMap

ExtensionsFromFile builds an ExtensionMap from the given collection of files.

func (ExtensionMap) FindExtensionsByMessage

func (e ExtensionMap) FindExtensionsByMessage(
	name protoreflect.FullName,
) []protoreflect.ExtensionDescriptor

FindExtensionsByMessage implements ExtensionResolver.

type ExtensionResolver

type ExtensionResolver interface {
	// FindExtensionsByMessage looks up all known extensions for the message with
	// the given name.
	FindExtensionsByMessage(name protoreflect.FullName) []protoreflect.ExtensionDescriptor
}

ExtensionResolver provides a mechanism for retrieving the extensions associated with some message.

This functionality is provided by protoregistry.Types.RangeExtensionsByMessage, but there is no standard interface for this.

type ExtensionsFromRegistry

type ExtensionsFromRegistry protoregistry.Types

ExtensionsFromRegistry wraps a protoregistry.Types to implement ExtensionResolver.

func (*ExtensionsFromRegistry) FindExtensionsByMessage

func (e *ExtensionsFromRegistry) FindExtensionsByMessage(
	name protoreflect.FullName,
) []protoreflect.ExtensionDescriptor

FindExtensionsByMessage implements ExtensionResolver.

type Getter

Getter is a strongly-typed version of tdp.Getter.

type Options

type Options struct {
	Profile    profile.Profile
	Extensions ExtensionResolver

	// Backend connects a [compiler] with backend configuration defined in another
	// package.
	//
	// This type mostly exists to break a circular dependency.
	Backend interface {
		// SelectArchetype classifies a field into a particular archetype.
		//
		// prof is a profile that inquires for the profile of a field within the context
		// of parsing fd. It takes a FieldDescriptor rather than a FieldSite because
		// the caller is responsible for constructing the FieldSite.
		//
		// Returns nil if the field is not supported yet.
		SelectArchetype(protoreflect.FieldDescriptor, profile.Field) *Archetype

		// PopulateMethods gives the backend an opportunity to populate the
		// fast-path methods of the generated type.
		PopulateMethods(*protoiface.Methods)
	}
}

CompileOption is a configuration setting for Compile.

type Parser

type Parser struct {
	Kind protowire.Type

	// If set, the parser will always Retry this field instead of going to the
	// next one if it parses successfully. Used for repeated fields.
	Retry bool

	// The bool return must always be true.
	//
	// This func MUST be a reference to a function or a global closure, so that
	// it is not a GC-managed pointer.
	Thunk vm.Thunk
}

Parser is a parser within an Archetype.

Directories

Path Synopsis
Package linker provides a general-purpose in-memory linker, that is used to assemble the output buffer within the compiler.
Package linker provides a general-purpose in-memory linker, that is used to assemble the output buffer within the compiler.

Jump to

Keyboard shortcuts

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