Skip to content

Commit bfb8f13

Browse files
Mark Freemangopherbot
authored andcommitted
internal/pkgbits: indent productions and hoist some types up
The types being hoisted are those which cannot be referenced; that is, where Ref[T] is illegal. These are most clearly owned by pkgbits. The types which follow are those which can be referenced. Referenceable types are more hazy due to the reference mechanism of UIR - sections. These are a detail of the UIR file format and are surfaced directly to importers. I suspect that pkgbits would benefit from a reference mechanism not dependent on sections. This would permit us to push down many types from the noder into pkgbits, reducing the interface surface without giving up deduplication. Change-Id: Ifaf5cd9de20c767ad0941413385b308d628aac6c Reviewed-on: https://go-review.googlesource.com/c/go/+/674635 Auto-Submit: Mark Freeman <mark@golang.org> TryBot-Bypass: Mark Freeman <mark@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
1 parent 07b94b2 commit bfb8f13

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

src/internal/pkgbits/doc.go

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,88 @@ package pkgbits.
88
99
The most basic primitives are laid out as below.
1010
11-
Bool = [ Sync ] byte .
12-
Int64 = [ Sync ] zvarint .
13-
Uint64 = [ Sync ] uvarint .
11+
Bool = [ Sync ] byte .
12+
Int64 = [ Sync ] zvarint .
13+
Uint64 = [ Sync ] uvarint .
1414
15-
zvarint = (* a zig-zag encoded signed variable-width integer *) .
16-
uvarint = (* an unsigned variable-width integer *) .
15+
zvarint = (* a zig-zag encoded signed variable-width integer *) .
16+
uvarint = (* an unsigned variable-width integer *) .
17+
18+
# References
19+
References specify the location of a value. While the representation here is
20+
fixed, the interpretation of a reference is left to other packages.
21+
22+
Ref[T] = [ Sync ] Uint64 . // points to a value of type T
23+
24+
# Markers
25+
Markers provide a mechanism for asserting that encoders and decoders
26+
are synchronized. If an unexpected marker is found, decoding panics.
27+
28+
Sync = uvarint // indicates what should follow if synchronized
29+
WriterPCs
30+
.
31+
32+
A marker also records a configurable number of program counters (PCs) during
33+
encoding to assist with debugging.
34+
35+
WriterPCs = uvarint // the number of PCs that follow
36+
{ uvarint } // the PCs
37+
.
38+
39+
Note that markers are always defined using terminals — they never contain a
40+
marker themselves.
1741
1842
# Strings
1943
A string is a series of bytes.
2044
21-
// TODO(markfreeman): Does this need a marker?
22-
String = { byte } .
45+
// TODO(markfreeman): Does this need a marker?
46+
String = { byte } .
2347
2448
Strings are typically not encoded directly. Rather, they are deduplicated
2549
during encoding and referenced where needed; this process is called interning.
2650
27-
StringRef = [ Sync ] Ref[String] .
51+
StringRef = [ Sync ] Ref[String] .
2852
2953
Note that StringRef is *not* equivalent to Ref[String] due to the extra marker.
3054
31-
# References
32-
References specify the location of a value. While the representation here is
33-
fixed, the interpretation of a reference is left to other packages.
34-
35-
Ref[T] = [ Sync ] Uint64 . // points to a value of type T
36-
3755
# Slices
3856
Slices are a convenience for encoding a series of values of the same type.
3957
40-
// TODO(markfreeman): Does this need a marker?
41-
Slice[T] = Uint64 // the number of values in the slice
42-
{ T } // the values
43-
.
58+
// TODO(markfreeman): Does this need a marker?
59+
Slice[T] = Uint64 // the number of values in the slice
60+
{ T } // the values
61+
.
4462
4563
# Constants
4664
Constants appear as defined via the package constant.
4765
48-
Constant = [ Sync ]
49-
Bool // whether the constant is a complex number
50-
Scalar // the real part
51-
[ Scalar ] // if complex, the imaginary part
52-
.
66+
Constant = [ Sync ]
67+
Bool // whether the constant is a complex number
68+
Scalar // the real part
69+
[ Scalar ] // if complex, the imaginary part
70+
.
5371
5472
A scalar represents a value using one of several potential formats. The exact
5573
format and interpretation is distinguished by a code preceding the value.
5674
57-
Scalar = [ Sync ]
58-
Uint64 // the code indicating the type of Val
59-
Val
60-
.
61-
62-
Val = Bool
63-
| Int64
64-
| StringRef
65-
| Term // big integer
66-
| Term Term // big ratio, numerator / denominator
67-
| BigBytes // big float, precision 512
68-
.
75+
Scalar = [ Sync ]
76+
Uint64 // the code indicating the type of Val
77+
Val
78+
.
6979
70-
Term = BigBytes
71-
Bool // whether the term is negative
72-
.
80+
Val = Bool
81+
| Int64
82+
| StringRef
83+
| Term // big integer
84+
| Term Term // big ratio, numerator / denominator
85+
| BigBytes // big float, precision 512
86+
.
7387
74-
BigBytes = StringRef . // bytes of a big value
75-
76-
# Markers
77-
Markers provide a mechanism for asserting that encoders and decoders are
78-
synchronized. If an unexpected marker is found, decoding panics.
88+
Term = BigBytes
89+
Bool // whether the term is negative
90+
.
7991
80-
Sync = uvarint // indicates what should follow if synchronized
81-
WriterPCs
82-
.
83-
84-
A marker also records a configurable number of program counters (PCs) during
85-
encoding to assist with debugging.
86-
87-
WriterPCs = uvarint // the number of PCs that follow
88-
{ uvarint } // the PCs
89-
.
90-
91-
Note that markers are always defined using terminals — they never contain a
92-
marker themselves.
92+
BigBytes = StringRef . // bytes of a big value
9393
*/
9494

9595
// Package pkgbits implements low-level coding abstractions for Unified IR's

0 commit comments

Comments
 (0)