MCPcopy
hub / github.com/gopherjs/gopherjs / importInitializer

Method importInitializer

compiler/decls.go:199–207  ·  view source on GitHub ↗

importInitializer calls the imported package $init() function to ensure it is initialized before any code in the importer package runs.

(impPath string)

Source from the content-addressed store, hash-verified

197// importInitializer calls the imported package $init() function to ensure it is
198// initialized before any code in the importer package runs.
199func (fc *funcContext) importInitializer(impPath string) ast.Stmt {
200 pkgVar := fc.pkgCtx.pkgVars[impPath]
201 id := fc.newIdent(fmt.Sprintf(`%s.$init`, pkgVar), types.NewSignatureType(nil, nil, nil, nil, nil, false))
202 call := &ast.CallExpr{Fun: id}
203 fc.Blocking[call] = true
204 fc.Flattened[call] = true
205
206 return &ast.ExprStmt{X: call}
207}
208
209// varDecls translates all package-level variables.
210//

Callers 1

newImportDeclMethod · 0.95

Calls 1

newIdentMethod · 0.95

Tested by

no test coverage detected