Skip to content

Commit f1f547f

Browse files
committed
Add support for indexed package format. "Fix" bug 0055.
1 parent 5adaabd commit f1f547f

File tree

5 files changed

+674
-25
lines changed

5 files changed

+674
-25
lines changed

decl.go

+7
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,13 @@ func (d *decl) find_child_and_in_embedded(name string) *decl {
10361036
return nil
10371037
}
10381038

1039+
if d.is_alias() {
1040+
dd := d.type_dealias()
1041+
if dd != nil {
1042+
return dd.find_child_and_in_embedded(name)
1043+
}
1044+
}
1045+
10391046
if d.is_visited() {
10401047
return nil
10411048
}

package.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,15 @@ func (m *package_file_cache) process_package_data(data []byte) {
112112
if data[0] == 'B' {
113113
// binary format, skip 'B\n'
114114
data = data[2:]
115-
var p gc_bin_parser
116-
p.init(data, m)
117-
pp = &p
115+
if len(data) > 0 && data[0] == 'i' {
116+
var p gc_ibin_parser
117+
p.init(data[1:], m)
118+
pp = &p
119+
} else {
120+
var p gc_bin_parser
121+
p.init(data, m)
122+
pp = &p
123+
}
118124
} else {
119125
// textual format, find the beginning of the package clause
120126
i = bytes.Index(data, []byte{'p', 'a', 'c', 'k', 'a', 'g', 'e'})

package_bin.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ func (p *gc_bin_parser) parse_export(callback func(string, ast.Decl)) {
113113

114114
// read version specific flags - extend as necessary
115115
switch p.version {
116-
// case 6:
117-
// ...
118-
// fallthrough
119-
case 5, 4, 3, 2, 1:
116+
case 6, 5, 4, 3, 2, 1:
120117
p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
121118
p.trackAllTypes = p.int() != 0
122119
p.posInfoFormat = p.int() != 0
@@ -172,6 +169,9 @@ func (p *gc_bin_parser) pkg() string {
172169
} else {
173170
path = p.string()
174171
}
172+
if p.version >= 6 {
173+
p.int() // package height; unused by go/types
174+
}
175175

176176
// we should never see an empty package name
177177
if name == "" {
@@ -810,13 +810,13 @@ var predeclared = []ast.Expr{
810810
// TODO(nsf): don't think those are used in just package type info,
811811
// maybe for consts, but we are not interested in that
812812
// untyped types
813-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedBool],
814-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedInt],
815-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedRune],
816-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedFloat],
817-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedComplex],
818-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedString],
819-
ast.NewIdent(">_<"), // TODO: types.Typ[types.UntypedNil],
813+
ast.NewIdent("&untypedBool&"), // TODO: types.Typ[types.UntypedBool],
814+
ast.NewIdent("&untypedInt&"), // TODO: types.Typ[types.UntypedInt],
815+
ast.NewIdent("&untypedRune&"), // TODO: types.Typ[types.UntypedRune],
816+
ast.NewIdent("&untypedFloat&"), // TODO: types.Typ[types.UntypedFloat],
817+
ast.NewIdent("&untypedComplex&"), // TODO: types.Typ[types.UntypedComplex],
818+
ast.NewIdent("&untypedString&"), // TODO: types.Typ[types.UntypedString],
819+
ast.NewIdent("&untypedNil&"), // TODO: types.Typ[types.UntypedNil],
820820

821821
// package unsafe
822822
&ast.SelectorExpr{X: ast.NewIdent("unsafe"), Sel: ast.NewIdent("Pointer")},

0 commit comments

Comments
 (0)