SectionPosBase
SectionPkg
SectionName
- SectionType // TODO(markfreeman) Define.
+ SectionType
SectionObj
SectionObjExt // TODO(markfreeman) Define.
SectionObjDict // TODO(markfreeman) Define.
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
Information about an object (e.g. variable, function, type name, etc.)
is split into multiple elements in different sections. Those elements
.
### Definition Section
-The definition section holds definitions for objects defined by the
-target package; it does not contain definitions for imported objects.
+The definition section holds definitions for objects defined by the target
+package; it does not contain definitions for imported objects.
SectionObj = { ObjectDef } .
-Object definitions can be one of several formats. To determine the
-correct format, the name section must be referenced for the object's
-type.
+Object definitions can be in one of several formats. To determine the correct
+format, the name section must be referenced; it contains a code indicating
+the object's type.
- ObjectDef = ObjectDefConst // TODO(markfreeman) Define.
- | ObjectDefFunc // TODO(markfreeman) Define.
- | ObjectDefAlias // TODO(markfreeman) Define.
- | ObjectDefNamedType // TODO(markfreeman) Define.
- | ObjectDefVar // TODO(markfreeman) Define.
+ ObjectDef = RefTable
+ [ Sync ]
+ ObjectSpec
.
+ 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
A reference table precedes every element. Each entry in the table
contains a (section, index) pair denoting the location of the
Elements encode references to other elements as an index in the
reference table — not the location of the referenced element directly.
- // TODO(markfreeman): Rename to RefUse.
- UseReloc = [ Sync ]
- RelElemIdx
- .
+ RefTableIdx = Uint64 .
+
+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
Primitive encoding is handled separately by the pkgbits package. Check