options

package
v0.0.0-...-4f6f732 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package options contains the logic for interpreting options. The parse step of compilation stores the options in uninterpreted form, which contains raw identifiers and literal values.

The process of interpreting an option is to resolve identifiers, by examining descriptors for the Options types and their available extensions (custom options). As field names are resolved, the values can be type-checked against the types indicated in field descriptors.

On success, the various fields and extensions of the options message are populated and the field holding the uninterpreted form is cleared.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index map[*ast.OptionNode][]int32

Index is a mapping of AST nodes that define options to a corresponding path into the containing file descriptor. The path is a sequence of field tags and indexes that define a traversal path from the root (the file descriptor) to the resolved option field.

func InterpretOptions

func InterpretOptions(linked linker.Result, handler *reporter.Handler) (Index, error)

InterpretOptions interprets options in the given linked result, returning an index that can be used to generate source code info. This step mutates the linked result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.

The given handler is used to report errors and warnings. If any errors are reported, this function returns a non-nil error.

func InterpretOptionsLenient

func InterpretOptionsLenient(linked linker.Result) (Index, error)

InterpretOptionsLenient interprets options in a lenient/best-effort way in the given linked result, returning an index that can be used to generate source code info. This step mutates the linked result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.

In lenient more, errors resolving option names and type errors are ignored. Any options that are uninterpretable (due to such errors) will remain in the "uninterpreted_option" fields.

func InterpretUnlinkedOptions

func InterpretUnlinkedOptions(parsed parser.Result) (Index, error)

InterpretUnlinkedOptions does a best-effort attempt to interpret options in the given parsed result, returning an index that can be used to generate source code info. This step mutates the parsed result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.

This is the same as InterpretOptionsLenient except that it accepts an unlinked result. Because the file is unlinked, custom options cannot be interpreted. Other errors resolving option names or type errors will be effectively ignored. Any options that are uninterpretable (due to such errors) will remain in the "uninterpreted_option" fields.

Jump to

Keyboard shortcuts

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