MCPcopy Create free account
hub / github.com/microsoft/typescript-go / bindBinaryExpressionFlow

Method bindBinaryExpressionFlow

internal/binder/binder.go:2219–2259  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

2217}
2218
2219func (b *Binder) bindBinaryExpressionFlow(node *ast.Node) {
2220 expr := node.AsBinaryExpression()
2221 operator := expr.OperatorToken.Kind
2222 if ast.IsLogicalOrCoalescingBinaryOperator(operator) || ast.IsLogicalOrCoalescingAssignmentOperator(operator) {
2223 if isTopLevelLogicalExpression(node) {
2224 postExpressionLabel := b.createBranchLabel()
2225 saveCurrentFlow := b.currentFlow
2226 saveHasFlowEffects := b.hasFlowEffects
2227 b.hasFlowEffects = false
2228 b.bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel)
2229 if b.hasFlowEffects {
2230 b.currentFlow = b.finishFlowLabel(postExpressionLabel)
2231 } else {
2232 b.currentFlow = saveCurrentFlow
2233 }
2234 b.hasFlowEffects = b.hasFlowEffects || saveHasFlowEffects
2235 } else {
2236 b.bindLogicalLikeExpression(node, b.currentTrueTarget, b.currentFalseTarget)
2237 }
2238 } else {
2239 b.bind(expr.Left)
2240 b.bind(expr.Type)
2241 if operator == ast.KindCommaToken {
2242 b.maybeBindExpressionFlowIfCall(expr.Left)
2243 }
2244 b.bind(expr.OperatorToken)
2245 b.bind(expr.Right)
2246 if operator == ast.KindCommaToken {
2247 b.maybeBindExpressionFlowIfCall(expr.Right)
2248 }
2249 if ast.IsAssignmentOperator(operator) && !ast.IsAssignmentTarget(node) {
2250 b.bindAssignmentTargetFlow(expr.Left)
2251 if operator == ast.KindEqualsToken && expr.Left.Kind == ast.KindElementAccessExpression {
2252 elementAccess := expr.Left.AsElementAccessExpression()
2253 if isNarrowableOperand(elementAccess.Expression) {
2254 b.currentFlow = b.createFlowMutation(ast.FlowFlagsArrayMutation, b.currentFlow, node)
2255 }
2256 }
2257 }
2258 }
2259}
2260
2261func (b *Binder) bindLogicalLikeExpression(node *ast.Node, trueTarget *ast.FlowLabel, falseTarget *ast.FlowLabel) {
2262 expr := node.AsBinaryExpression()

Callers 1

bindChildrenMethod · 0.95

Calls 15

createBranchLabelMethod · 0.95
finishFlowLabelMethod · 0.95
bindMethod · 0.95
createFlowMutationMethod · 0.95
IsAssignmentOperatorFunction · 0.92
IsAssignmentTargetFunction · 0.92

Tested by

no test coverage detected