| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../common_elements.dart'; | 10 import '../common_elements.dart'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 /// Returns the [ConstructorEntity] corresponding to the generative or factory | 56 /// Returns the [ConstructorEntity] corresponding to the generative or factory |
| 57 /// constructor [node]. | 57 /// constructor [node]. |
| 58 ConstructorEntity getConstructor(ir.Member node); | 58 ConstructorEntity getConstructor(ir.Member node); |
| 59 | 59 |
| 60 /// Returns the [FieldEntity] corresponding to the field [node]. | 60 /// Returns the [FieldEntity] corresponding to the field [node]. |
| 61 FieldEntity getField(ir.Field node); | 61 FieldEntity getField(ir.Field node); |
| 62 | 62 |
| 63 /// Returns the [ClassEntity] corresponding to the class [node]. | 63 /// Returns the [ClassEntity] corresponding to the class [node]. |
| 64 ClassEntity getClass(ir.Class node); | 64 ClassEntity getClass(ir.Class node); |
| 65 | 65 |
| 66 /// Returns the [Local] corresponding to the [node]. The node must be either | |
| 67 /// a [ir.FunctionDeclaration] or [ir.FunctionExpression]. | |
| 68 // TODO(johnniwinther): Move this to [KernelToElementMapForImpact]. | |
| 69 Local getLocalFunction(ir.TreeNode node); | |
| 70 | |
| 71 /// Returns the super [MemberEntity] for a super invocation, get or set of | 66 /// Returns the super [MemberEntity] for a super invocation, get or set of |
| 72 /// [name] from the member [context]. | 67 /// [name] from the member [context]. |
| 73 /// | 68 /// |
| 74 /// The IR doesn't always resolve super accesses to the corresponding | 69 /// The IR doesn't always resolve super accesses to the corresponding |
| 75 /// [target]. If not, the target is computed using [name] and [setter] from | 70 /// [target]. If not, the target is computed using [name] and [setter] from |
| 76 /// the enclosing class of [context]. | 71 /// the enclosing class of [context]. |
| 77 MemberEntity getSuperMember(ir.Member context, ir.Name name, ir.Member target, | 72 MemberEntity getSuperMember(ir.Member context, ir.Name name, ir.Member target, |
| 78 {bool setter: false}); | 73 {bool setter: false}); |
| 79 | 74 |
| 80 /// Returns the [Name] corresponding to [name]. | 75 /// Returns the [Name] corresponding to [name]. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 /// Computes the native behavior for calling [procedure]. | 142 /// Computes the native behavior for calling [procedure]. |
| 148 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure, | 143 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure, |
| 149 {bool isJsInterop}); | 144 {bool isJsInterop}); |
| 150 | 145 |
| 151 /// Compute the kind of foreign helper function called by [node], if any. | 146 /// Compute the kind of foreign helper function called by [node], if any. |
| 152 ForeignKind getForeignKind(ir.StaticInvocation node); | 147 ForeignKind getForeignKind(ir.StaticInvocation node); |
| 153 | 148 |
| 154 /// Computes the [InterfaceType] referenced by a call to the | 149 /// Computes the [InterfaceType] referenced by a call to the |
| 155 /// [JS_INTERCEPTOR_CONSTANT] function, if any. | 150 /// [JS_INTERCEPTOR_CONSTANT] function, if any. |
| 156 InterfaceType getInterfaceTypeForJsInterceptorCall(ir.StaticInvocation node); | 151 InterfaceType getInterfaceTypeForJsInterceptorCall(ir.StaticInvocation node); |
| 152 |
| 153 /// Returns the [Local] corresponding to the [node]. The node must be either |
| 154 /// a [ir.FunctionDeclaration] or [ir.FunctionExpression]. |
| 155 Local getLocalFunction(ir.TreeNode node); |
| 157 } | 156 } |
| 158 | 157 |
| 159 /// Interface that translates between Kernel IR nodes and entities used for | 158 /// Interface that translates between Kernel IR nodes and entities used for |
| 160 /// global type inference and building the SSA graph for members. | 159 /// global type inference and building the SSA graph for members. |
| 161 abstract class KernelToElementMapForBuilding implements KernelToElementMap { | 160 abstract class KernelToElementMapForBuilding implements KernelToElementMap { |
| 162 /// [ElementEnvironment] for library, class and member lookup. | 161 /// [ElementEnvironment] for library, class and member lookup. |
| 163 ElementEnvironment get elementEnvironment; | 162 ElementEnvironment get elementEnvironment; |
| 164 | 163 |
| 165 /// Returns the list of [DartType]s corresponding to [types]. | 164 /// Returns the list of [DartType]s corresponding to [types]. |
| 166 List<DartType> getDartTypes(List<ir.DartType> types); | 165 List<DartType> getDartTypes(List<ir.DartType> types); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 /// Returns the inferred type of a dynamic [selector] access on a receiver of | 354 /// Returns the inferred type of a dynamic [selector] access on a receiver of |
| 356 /// type [mask]. | 355 /// type [mask]. |
| 357 TypeMask selectorTypeOf(Selector selector, TypeMask mask); | 356 TypeMask selectorTypeOf(Selector selector, TypeMask mask); |
| 358 | 357 |
| 359 /// Returns the returned type annotation in the [nativeBehavior]. | 358 /// Returns the returned type annotation in the [nativeBehavior]. |
| 360 TypeMask typeFromNativeBehavior( | 359 TypeMask typeFromNativeBehavior( |
| 361 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld); | 360 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld); |
| 362 } | 361 } |
| 363 | 362 |
| 364 /// Map from kernel IR nodes to local entities. | 363 /// Map from kernel IR nodes to local entities. |
| 365 // TODO(johnniwinther): Add `getLocalFunction`. | |
| 366 abstract class KernelToLocalsMap { | 364 abstract class KernelToLocalsMap { |
| 367 /// The member currently being built. | 365 /// The member currently being built. |
| 368 MemberEntity get currentMember; | 366 MemberEntity get currentMember; |
| 369 | 367 |
| 370 // TODO(johnniwinther): Make these return the [KernelToLocalsMap] to use from | 368 // TODO(johnniwinther): Make these return the [KernelToLocalsMap] to use from |
| 371 // now on. | 369 // now on. |
| 372 /// Call to notify that [member] is currently being inlined. | 370 /// Call to notify that [member] is currently being inlined. |
| 373 void enterInlinedMember(covariant MemberEntity member); | 371 void enterInlinedMember(covariant MemberEntity member); |
| 374 | 372 |
| 375 /// Call to notify that [member] is no longer being inlined. | 373 /// Call to notify that [member] is no longer being inlined. |
| 376 void leaveInlinedMember(covariant MemberEntity member); | 374 void leaveInlinedMember(covariant MemberEntity member); |
| 377 | 375 |
| 378 /// Returns the [Local] for [node]. | 376 /// Returns the [Local] for [node]. |
| 379 Local getLocal(ir.VariableDeclaration node); | 377 Local getLocalVariable(ir.VariableDeclaration node); |
| 378 |
| 379 /// Returns the [Local] corresponding to the [node]. The node must be either |
| 380 /// a [ir.FunctionDeclaration] or [ir.FunctionExpression]. |
| 381 Local getLocalFunction(ir.TreeNode node); |
| 380 | 382 |
| 381 /// Returns the [JumpTarget] for the break statement [node]. | 383 /// Returns the [JumpTarget] for the break statement [node]. |
| 382 JumpTarget getJumpTargetForBreak(ir.BreakStatement node); | 384 JumpTarget getJumpTargetForBreak(ir.BreakStatement node); |
| 383 | 385 |
| 384 /// Returns `true` if [node] should generate a `continue` to its [JumpTarget]. | 386 /// Returns `true` if [node] should generate a `continue` to its [JumpTarget]. |
| 385 bool generateContinueForBreak(ir.BreakStatement node); | 387 bool generateContinueForBreak(ir.BreakStatement node); |
| 386 | 388 |
| 387 /// Returns the [JumpTarget] defined by the labelled statement [node] or | 389 /// Returns the [JumpTarget] defined by the labelled statement [node] or |
| 388 /// `null` if [node] is not a jump target. | 390 /// `null` if [node] is not a jump target. |
| 389 JumpTarget getJumpTargetForLabel(ir.LabeledStatement node); | 391 JumpTarget getJumpTargetForLabel(ir.LabeledStatement node); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 419 /// [closureClassMaps]. | 421 /// [closureClassMaps]. |
| 420 CapturedLoopScope getCapturedLoopScope( | 422 CapturedLoopScope getCapturedLoopScope( |
| 421 ClosureDataLookup closureLookup, ir.TreeNode node); | 423 ClosureDataLookup closureLookup, ir.TreeNode node); |
| 422 } | 424 } |
| 423 | 425 |
| 424 /// Comparator for the canonical order or named arguments. | 426 /// Comparator for the canonical order or named arguments. |
| 425 // TODO(johnniwinther): Remove this when named parameters are sorted in dill. | 427 // TODO(johnniwinther): Remove this when named parameters are sorted in dill. |
| 426 int namedOrdering(ir.VariableDeclaration a, ir.VariableDeclaration b) { | 428 int namedOrdering(ir.VariableDeclaration a, ir.VariableDeclaration b) { |
| 427 return a.name.compareTo(b.name); | 429 return a.name.compareTo(b.name); |
| 428 } | 430 } |
| OLD | NEW |