@@ -12,8 +12,8 @@ import (
12
12
"sort"
13
13
"strings"
14
14
15
- "github.com/gopherjs/gopherjs/compiler/analysis"
16
15
"github.com/gopherjs/gopherjs/compiler/astutil"
16
+ "github.com/gopherjs/gopherjs/compiler/internal/analysis"
17
17
"github.com/gopherjs/gopherjs/compiler/internal/typeparams"
18
18
"github.com/gopherjs/gopherjs/compiler/typesutil"
19
19
)
@@ -72,7 +72,7 @@ func (fc *funcContext) nestedFunctionContext(info *analysis.FuncInfo, inst typep
72
72
// namedFuncContext creates a new funcContext for a named Go function
73
73
// (standalone or method).
74
74
func (fc * funcContext ) namedFuncContext (inst typeparams.Instance ) * funcContext {
75
- info := fc .pkgCtx .FuncDeclInfos [ inst . Object .( * types. Func )]
75
+ info := fc .pkgCtx .FuncInfo ( inst )
76
76
c := fc .nestedFunctionContext (info , inst )
77
77
78
78
return c
@@ -82,7 +82,7 @@ func (fc *funcContext) namedFuncContext(inst typeparams.Instance) *funcContext {
82
82
// go/types doesn't generate *types.Func objects for function literals, we
83
83
// generate a synthetic one for it.
84
84
func (fc * funcContext ) literalFuncContext (fun * ast.FuncLit ) * funcContext {
85
- info := fc .pkgCtx .FuncLitInfos [ fun ]
85
+ info := fc .pkgCtx .FuncLitInfo ( fun )
86
86
sig := fc .pkgCtx .TypeOf (fun ).(* types.Signature )
87
87
o := types .NewFunc (fun .Pos (), fc .pkgCtx .Pkg , fc .newLitFuncName (), sig )
88
88
inst := typeparams.Instance {Object : o }
@@ -237,7 +237,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
237
237
}
238
238
239
239
bodyOutput := string (fc .CatchOutput (1 , func () {
240
- if len ( fc .Blocking ) != 0 {
240
+ if fc .IsBlocking () {
241
241
fc .pkgCtx .Scopes [body ] = fc .pkgCtx .Scopes [typ ]
242
242
fc .handleEscapingVars (body )
243
243
}
@@ -283,14 +283,14 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
283
283
if fc .HasDefer {
284
284
fc .localVars = append (fc .localVars , "$deferred" )
285
285
suffix = " }" + suffix
286
- if len ( fc .Blocking ) != 0 {
286
+ if fc .IsBlocking () {
287
287
suffix = " }" + suffix
288
288
}
289
289
}
290
290
291
291
localVarDefs := "" // Function-local var declaration at the top.
292
292
293
- if len ( fc .Blocking ) != 0 {
293
+ if fc .IsBlocking () {
294
294
localVars := append ([]string {}, fc .localVars ... )
295
295
// There are several special variables involved in handling blocking functions:
296
296
// $r is sometimes used as a temporary variable to store blocking call result.
@@ -314,7 +314,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
314
314
if fc .HasDefer {
315
315
prefix = prefix + " var $err = null; try {"
316
316
deferSuffix := " } catch(err) { $err = err;"
317
- if len ( fc .Blocking ) != 0 {
317
+ if fc .IsBlocking () {
318
318
deferSuffix += " $s = -1;"
319
319
}
320
320
if fc .resultNames == nil && fc .sig .HasResults () {
@@ -324,7 +324,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
324
324
if fc .resultNames != nil {
325
325
deferSuffix += fmt .Sprintf (" if (!$curGoroutine.asleep) { return %s; }" , fc .translateResults (fc .resultNames ))
326
326
}
327
- if len ( fc .Blocking ) != 0 {
327
+ if fc .IsBlocking () {
328
328
deferSuffix += " if($curGoroutine.asleep) {"
329
329
}
330
330
suffix = deferSuffix + suffix
0 commit comments