mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/noder: stub type section and adjust others
The type definition and object definition sections have nearly the same structure - help illustrate that through consistent naming. Change-Id: Ibed374fca4883a293a7fc16b36034e1acb38362a Reviewed-on: https://go-review.googlesource.com/c/go/+/677378 Auto-Submit: Mark Freeman <mark@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
25ca686a0b
commit
cc119ee391
1 changed files with 72 additions and 15 deletions
|
|
@ -26,7 +26,7 @@ determines its index in the series.
|
||||||
SectionPosBase
|
SectionPosBase
|
||||||
SectionPkg
|
SectionPkg
|
||||||
SectionName
|
SectionName
|
||||||
SectionType // TODO(markfreeman) Define.
|
SectionType
|
||||||
SectionObj
|
SectionObj
|
||||||
SectionObjExt // TODO(markfreeman) Define.
|
SectionObjExt // TODO(markfreeman) Define.
|
||||||
SectionObjDict // TODO(markfreeman) Define.
|
SectionObjDict // TODO(markfreeman) Define.
|
||||||
|
|
@ -137,6 +137,44 @@ Note, a PkgRef is *not* equivalent to Ref[Pkg] due to an extra marker.
|
||||||
Ref[Pkg]
|
Ref[Pkg]
|
||||||
.
|
.
|
||||||
|
|
||||||
|
## Type Section
|
||||||
|
The type section is a series of type definition elements.
|
||||||
|
|
||||||
|
SectionType = { TypeDef } .
|
||||||
|
|
||||||
|
A type definition can be in one of several formats, which are identified
|
||||||
|
by their TypeSpec code.
|
||||||
|
|
||||||
|
TypeDef = RefTable
|
||||||
|
[ Sync ]
|
||||||
|
[ Sync ]
|
||||||
|
Uint64 // denotes which TypeSpec to use
|
||||||
|
TypeSpec
|
||||||
|
.
|
||||||
|
|
||||||
|
TypeSpec = TypeSpecBasic // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecNamed // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecPointer // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecSlice // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecArray // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecChan // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecMap // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecSignature // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecStruct // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecInterface // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecUnion // TODO(markfreeman): Define.
|
||||||
|
| TypeSpecTypeParam // TODO(markfreeman): Define.
|
||||||
|
.
|
||||||
|
|
||||||
|
// TODO(markfreeman): Document the reader dictionary once we understand it more.
|
||||||
|
To use a type elsewhere, a TypeUse is encoded.
|
||||||
|
|
||||||
|
TypeUse = [ Sync ]
|
||||||
|
Bool // whether it is a derived type
|
||||||
|
[ Uint64 ] // if derived, an index into the reader dictionary
|
||||||
|
[ Ref[TypeDef] ] // else, a reference to the type
|
||||||
|
.
|
||||||
|
|
||||||
## Object Sections
|
## Object Sections
|
||||||
Information about an object (e.g. variable, function, type name, etc.)
|
Information about an object (e.g. variable, function, type name, etc.)
|
||||||
is split into multiple elements in different sections. Those elements
|
is split into multiple elements in different sections. Those elements
|
||||||
|
|
@ -160,22 +198,36 @@ for objects.
|
||||||
.
|
.
|
||||||
|
|
||||||
### Definition Section
|
### Definition Section
|
||||||
The definition section holds definitions for objects defined by the
|
The definition section holds definitions for objects defined by the target
|
||||||
target package; it does not contain definitions for imported objects.
|
package; it does not contain definitions for imported objects.
|
||||||
|
|
||||||
SectionObj = { ObjectDef } .
|
SectionObj = { ObjectDef } .
|
||||||
|
|
||||||
Object definitions can be one of several formats. To determine the
|
Object definitions can be in one of several formats. To determine the correct
|
||||||
correct format, the name section must be referenced for the object's
|
format, the name section must be referenced; it contains a code indicating
|
||||||
type.
|
the object's type.
|
||||||
|
|
||||||
ObjectDef = ObjectDefConst // TODO(markfreeman) Define.
|
ObjectDef = RefTable
|
||||||
| ObjectDefFunc // TODO(markfreeman) Define.
|
[ Sync ]
|
||||||
| ObjectDefAlias // TODO(markfreeman) Define.
|
ObjectSpec
|
||||||
| ObjectDefNamedType // TODO(markfreeman) Define.
|
|
||||||
| ObjectDefVar // TODO(markfreeman) Define.
|
|
||||||
.
|
.
|
||||||
|
|
||||||
|
ObjectSpec = ObjectSpecConst // TODO(markfreeman) Define.
|
||||||
|
| ObjectSpecFunc // TODO(markfreeman) Define.
|
||||||
|
| ObjectSpecAlias // TODO(markfreeman) Define.
|
||||||
|
| ObjectSpecNamedType // TODO(markfreeman) Define.
|
||||||
|
| ObjectSpecVar // TODO(markfreeman) Define.
|
||||||
|
.
|
||||||
|
|
||||||
|
To use an object definition elsewhere, an ObjectUse is encoded.
|
||||||
|
|
||||||
|
ObjectUse = [ Sync ]
|
||||||
|
[ Bool ]
|
||||||
|
Ref[ObjectDef]
|
||||||
|
Uint64 // the number of type arguments
|
||||||
|
{ TypeUse } // references to the type arguments
|
||||||
|
.
|
||||||
|
|
||||||
# References
|
# References
|
||||||
A reference table precedes every element. Each entry in the table
|
A reference table precedes every element. Each entry in the table
|
||||||
contains a (section, index) pair denoting the location of the
|
contains a (section, index) pair denoting the location of the
|
||||||
|
|
@ -193,10 +245,15 @@ referenced element.
|
||||||
Elements encode references to other elements as an index in the
|
Elements encode references to other elements as an index in the
|
||||||
reference table — not the location of the referenced element directly.
|
reference table — not the location of the referenced element directly.
|
||||||
|
|
||||||
// TODO(markfreeman): Rename to RefUse.
|
RefTableIdx = Uint64 .
|
||||||
UseReloc = [ Sync ]
|
|
||||||
RelElemIdx
|
To do this, the Ref[T] primitive is used as below; note that this is
|
||||||
.
|
the same shape as provided by package pkgbits, just with new
|
||||||
|
interpretation applied.
|
||||||
|
|
||||||
|
Ref[T] = [ Sync ]
|
||||||
|
RefTableIdx // the Uint64
|
||||||
|
.
|
||||||
|
|
||||||
# Primitives
|
# Primitives
|
||||||
Primitive encoding is handled separately by the pkgbits package. Check
|
Primitive encoding is handled separately by the pkgbits package. Check
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue