...
1 package parser
2
3 import (
4 "github.com/dop251/goja/ast"
5 "github.com/dop251/goja/unistring"
6 )
7
8 type _scope struct {
9 outer *_scope
10 allowIn bool
11 allowLet bool
12 inIteration bool
13 inSwitch bool
14 inFuncParams bool
15 inFunction bool
16 inAsync bool
17 allowAwait bool
18 allowYield bool
19 declarationList []*ast.VariableDeclaration
20
21 labels []unistring.String
22 }
23
24 func (self *_parser) openScope() {
25 self.scope = &_scope{
26 outer: self.scope,
27 allowIn: true,
28 }
29 }
30
31 func (self *_parser) closeScope() {
32 self.scope = self.scope.outer
33 }
34
35 func (self *_scope) declare(declaration *ast.VariableDeclaration) {
36 self.declarationList = append(self.declarationList, declaration)
37 }
38
39 func (self *_scope) hasLabel(name unistring.String) bool {
40 for _, label := range self.labels {
41 if label == name {
42 return true
43 }
44 }
45 if self.outer != nil && !self.inFunction {
46
47 return self.outer.hasLabel(name)
48 }
49 return false
50 }
51
View as plain text