OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection' show Queue; | 6 import 'dart:collection' show Queue; |
7 | 7 |
8 import 'package:kernel/ast.dart' as ir; | 8 import 'package:kernel/ast.dart' as ir; |
9 import 'package:kernel/checks.dart' show CheckParentPointers; | 9 import 'package:kernel/checks.dart' show CheckParentPointers; |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 LibraryElement, | 28 LibraryElement, |
29 LocalFunctionElement, | 29 LocalFunctionElement, |
30 MetadataAnnotation, | 30 MetadataAnnotation, |
31 MixinApplicationElement, | 31 MixinApplicationElement, |
32 TypeVariableElement; | 32 TypeVariableElement; |
33 import '../elements/modelx.dart' show ErroneousFieldElementX; | 33 import '../elements/modelx.dart' show ErroneousFieldElementX; |
34 import '../tree/tree.dart' show FunctionExpression, Node; | 34 import '../tree/tree.dart' show FunctionExpression, Node; |
35 import 'constant_visitor.dart'; | 35 import 'constant_visitor.dart'; |
36 import 'kernel_visitor.dart' show IrFunction, KernelVisitor; | 36 import 'kernel_visitor.dart' show IrFunction, KernelVisitor; |
37 | 37 |
38 typedef void WorkAction(); | |
39 | |
40 class WorkItem { | 38 class WorkItem { |
41 final Element element; | 39 final Element element; |
42 final WorkAction action; | 40 final void Function() action; |
43 | 41 |
44 WorkItem(this.element, this.action); | 42 WorkItem(this.element, this.action); |
45 } | 43 } |
46 | 44 |
47 class Kernel { | 45 class Kernel { |
48 final Compiler compiler; | 46 final Compiler compiler; |
49 | 47 |
50 final Map<LibraryElement, ir.Library> libraries = | 48 final Map<LibraryElement, ir.Library> libraries = |
51 <LibraryElement, ir.Library>{}; | 49 <LibraryElement, ir.Library>{}; |
52 | 50 |
(...skipping 20 matching lines...) Expand all Loading... |
73 | 71 |
74 final Map<ir.Node, Element> nodeToElement = <ir.Node, Element>{}; | 72 final Map<ir.Node, Element> nodeToElement = <ir.Node, Element>{}; |
75 final Map<ir.Node, Node> nodeToAst = <ir.Node, Node>{}; | 73 final Map<ir.Node, Node> nodeToAst = <ir.Node, Node>{}; |
76 | 74 |
77 /// FIFO queue of work that needs to be completed before the returned AST | 75 /// FIFO queue of work that needs to be completed before the returned AST |
78 /// nodes are correct. | 76 /// nodes are correct. |
79 final Queue<WorkItem> workQueue = new Queue<WorkItem>(); | 77 final Queue<WorkItem> workQueue = new Queue<WorkItem>(); |
80 | 78 |
81 Kernel(this.compiler); | 79 Kernel(this.compiler); |
82 | 80 |
83 void addWork(Element element, WorkAction action) { | 81 void addWork(Element element, void Function() action) { |
84 workQueue.addLast(new WorkItem(element, action)); | 82 workQueue.addLast(new WorkItem(element, action)); |
85 } | 83 } |
86 | 84 |
87 void checkMember(Element key, ir.TreeNode value) { | 85 void checkMember(Element key, ir.TreeNode value) { |
88 if (!checkedNodes.add(value)) return; | 86 if (!checkedNodes.add(value)) return; |
89 if (value.parent == null) { | 87 if (value.parent == null) { |
90 internalError(key, "Missing parent on IR node."); | 88 internalError(key, "Missing parent on IR node."); |
91 } | 89 } |
92 try { | 90 try { |
93 CheckParentPointers.check(value); | 91 CheckParentPointers.check(value); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 730 } |
733 | 731 |
734 class ConstructorTarget { | 732 class ConstructorTarget { |
735 final ConstructorElement element; | 733 final ConstructorElement element; |
736 final DartType type; | 734 final DartType type; |
737 | 735 |
738 ConstructorTarget(this.element, this.type); | 736 ConstructorTarget(this.element, this.type); |
739 | 737 |
740 String toString() => "ConstructorTarget($element, $type)"; | 738 String toString() => "ConstructorTarget($element, $type)"; |
741 } | 739 } |
OLD | NEW |