Skip to content

Commit

Permalink
rename shouldLowerSuperPropertyAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Apr 2, 2022
1 parent 02a794e commit d8ec066
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 19 additions & 19 deletions internal/js_parser/js_parser.go
Expand Up @@ -573,13 +573,13 @@ type fnOrArrowDataVisit struct {
tryBodyCount int32
tryCatchLoc logger.Loc

isArrow bool
isAsync bool
isGenerator bool
isInsideLoop bool
isInsideSwitch bool
isOutsideFnOrArrow bool
shouldLowerSuper bool
isArrow bool
isAsync bool
isGenerator bool
isInsideLoop bool
isInsideSwitch bool
isOutsideFnOrArrow bool
shouldLowerSuperPropertyAccess bool
}

type superHelpers struct {
Expand Down Expand Up @@ -10210,7 +10210,7 @@ func (p *parser) visitClass(nameScopeLoc logger.Loc, class *js_ast.Class) js_ast
p.fnOnlyDataVisit.thisClassStaticRef = &shadowRef

// Need to lower "super" since it won't be valid outside the class body
p.fnOrArrowDataVisit.shouldLowerSuper = true
p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess = true
}

p.pushScopeForVisitPass(js_ast.ScopeClassStaticInit, property.ClassStaticBlock.Loc)
Expand Down Expand Up @@ -10280,8 +10280,8 @@ func (p *parser) visitClass(nameScopeLoc logger.Loc, class *js_ast.Class) js_ast

// The value of "this" and "super" is shadowed inside property values
oldFnOnlyDataVisit := p.fnOnlyDataVisit
oldShouldLowerSuper := p.fnOrArrowDataVisit.shouldLowerSuper
p.fnOrArrowDataVisit.shouldLowerSuper = false
oldShouldLowerSuperPropertyAccess := p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess
p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess = false
p.fnOnlyDataVisit.isThisNested = true
p.fnOnlyDataVisit.isNewTargetAllowed = true
p.fnOnlyDataVisit.thisClassStaticRef = nil
Expand Down Expand Up @@ -10317,7 +10317,7 @@ func (p *parser) visitClass(nameScopeLoc logger.Loc, class *js_ast.Class) js_ast
p.fnOnlyDataVisit.thisClassStaticRef = &shadowRef

// Need to lower "super" since it won't be valid outside the class body
p.fnOrArrowDataVisit.shouldLowerSuper = true
p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess = true
}
if nameToKeep != "" {
wasAnonymousNamedExpr := p.isAnonymousNamedExpr(property.InitializerOrNil)
Expand All @@ -10329,7 +10329,7 @@ func (p *parser) visitClass(nameScopeLoc logger.Loc, class *js_ast.Class) js_ast

// Restore "this" so it will take the inherited value in property keys
p.fnOnlyDataVisit = oldFnOnlyDataVisit
p.fnOrArrowDataVisit.shouldLowerSuper = oldShouldLowerSuper
p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess = oldShouldLowerSuperPropertyAccess

// Restore the ability to use "arguments" in decorators and computed properties
p.currentScope.ForbidArguments = false
Expand Down Expand Up @@ -13389,9 +13389,9 @@ func (p *parser) visitExprInOut(expr js_ast.Expr, in exprIn) (js_ast.Expr, exprO
asyncArrowNeedsToBeLowered := e.IsAsync && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait)
oldFnOrArrowData := p.fnOrArrowDataVisit
p.fnOrArrowDataVisit = fnOrArrowDataVisit{
isArrow: true,
isAsync: e.IsAsync,
shouldLowerSuper: oldFnOrArrowData.shouldLowerSuper || asyncArrowNeedsToBeLowered,
isArrow: true,
isAsync: e.IsAsync,
shouldLowerSuperPropertyAccess: oldFnOrArrowData.shouldLowerSuperPropertyAccess || asyncArrowNeedsToBeLowered,
}

// Mark if we're inside an async arrow function. This value should be true
Expand Down Expand Up @@ -13831,9 +13831,9 @@ func (p *parser) visitFn(fn *js_ast.Fn, scopeLoc logger.Loc, tsDecoratorScope *j
oldFnOrArrowData := p.fnOrArrowDataVisit
oldFnOnlyData := p.fnOnlyDataVisit
p.fnOrArrowDataVisit = fnOrArrowDataVisit{
isAsync: fn.IsAsync,
isGenerator: fn.IsGenerator,
shouldLowerSuper: fn.IsAsync && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait),
isAsync: fn.IsAsync,
isGenerator: fn.IsGenerator,
shouldLowerSuperPropertyAccess: fn.IsAsync && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait),
}
p.fnOnlyDataVisit = fnOnlyDataVisit{
isThisNested: true,
Expand All @@ -13845,7 +13845,7 @@ func (p *parser) visitFn(fn *js_ast.Fn, scopeLoc logger.Loc, tsDecoratorScope *j
// "super" property accesses within this function. This object will be
// populated if "super" is used, and then any necessary helper functions
// will be placed in the function body by "lowerFunction" below.
if p.fnOrArrowDataVisit.shouldLowerSuper {
if p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess {
p.fnOnlyDataVisit.superHelpers = &superHelpers{
getRef: js_ast.InvalidRef,
setRef: js_ast.InvalidRef,
Expand Down
2 changes: 1 addition & 1 deletion internal/js_parser/js_parser_lower.go
Expand Up @@ -2833,7 +2833,7 @@ func (p *parser) lowerTemplateLiteral(loc logger.Loc, e *js_ast.ETemplate) js_as
}

func (p *parser) shouldLowerSuperPropertyAccess(expr js_ast.Expr) bool {
if p.fnOrArrowDataVisit.shouldLowerSuper {
if p.fnOrArrowDataVisit.shouldLowerSuperPropertyAccess {
_, isSuper := expr.Data.(*js_ast.ESuper)
return isSuper
}
Expand Down

0 comments on commit d8ec066

Please sign in to comment.