|
1 | 1 | /* |
2 | | - Copyright 2024 The GoPlus Authors (goplus.org) |
3 | | - Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | - you may not use this file except in compliance with the License. |
5 | | - You may obtain a copy of the License at |
6 | | - http://www.apache.org/licenses/LICENSE-2.0 |
7 | | - Unless required by applicable law or agreed to in writing, software |
8 | | - distributed under the License is distributed on an "AS IS" BASIS, |
9 | | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
10 | | - See the License for the specific language governing permissions and |
11 | | - limitations under the License. |
| 2 | +Copyright 2024 The GoPlus Authors (goplus.org) |
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | +
|
| 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +
|
| 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +See the License for the specific language governing permissions and |
| 13 | +limitations under the License. |
12 | 14 | */ |
13 | 15 |
|
14 | 16 | package gogen |
@@ -165,14 +167,25 @@ func Lookup(scope *types.Scope, name string) (obj types.Object) { |
165 | 167 | // ---------------------------------------------------------------------------- |
166 | 168 |
|
167 | 169 | var ( |
168 | | - TyByte = types.Universe.Lookup("byte").Type().(*types.Basic) |
169 | | - TyRune = types.Universe.Lookup("rune").Type().(*types.Basic) |
| 170 | + TyByte *types.Basic |
| 171 | + TyRune *types.Basic |
| 172 | + |
| 173 | + TyError types.Type |
| 174 | + TyAny types.Type |
| 175 | + TyEmptyInterface types.Type |
170 | 176 | ) |
171 | 177 |
|
172 | | -var ( |
| 178 | +func init() { |
| 179 | + universe := types.Universe |
| 180 | + iotaObj = universe.Lookup("iota") |
| 181 | + TyByte = universe.Lookup("byte").Type().(*types.Basic) |
| 182 | + TyRune = universe.Lookup("rune").Type().(*types.Basic) |
| 183 | + TyError = universe.Lookup("error").Type() |
| 184 | + TyAny = universe.Lookup("any").Type() |
173 | 185 | TyEmptyInterface = types.NewInterfaceType(nil, nil) |
174 | | - TyError = types.Universe.Lookup("error").Type() |
175 | | -) |
| 186 | +} |
| 187 | + |
| 188 | +// ---------------------------------------------------------------------------- |
176 | 189 |
|
177 | 190 | // refType: &T |
178 | 191 | type refType struct { |
|
0 commit comments