Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: pkg/fletchc/lib/src/fletch_registry.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
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.
4
5 library fletchc.fletch_codegen_registry;
6
7 import 'package:compiler/src/compiler.dart' show
8 GlobalDependencyRegistry;
9
10 import 'package:compiler/src/common/codegen.dart' show
11 CodegenRegistry;
12
13 import 'package:compiler/src/common/registry.dart' show
14 Registry;
15
16 import 'package:compiler/src/universe/selector.dart' show
17 Selector;
18
19 import 'package:compiler/src/universe/use.dart' show
20 DynamicUse,
21 StaticUse;
22
23 import 'package:compiler/src/elements/elements.dart' show
24 ClassElement,
25 Element,
26 FunctionElement,
27 LocalElement;
28
29 import 'package:compiler/src/dart_types.dart' show
30 DartType,
31 InterfaceType;
32
33 import 'fletch_compiler_implementation.dart' show
34 FletchCompilerImplementation;
35
36 import 'fletch_enqueuer.dart' show
37 FletchEnqueuer;
38
39 /// Represents ways a function can used as a closure. See also [Closurization]
40 /// in [./dynamic_call_enqueuer.dart].
41 enum ClosureKind {
42 // Notes:
43 //
44 // * We don't need to distinguish between instance/static/top-level
45 // tear-offs. This information is implicit in the function whose usage is
46 // described..
47 //
48 // * [localFunction] is sufficiently different from [tearOff], that it
49 // probably leads to less confusion having separate kinds; we don't normally
50 // refer to a local function closure as a "tear-off". But the information is
51 // implicit in the associated element.
52 //
53 // * [functionLike] is different from [tearOff] as the former will not imply
54 // a synthetic class (stubs are added to the enclosing/holder class)
55 //
56 // * [superTearOff] is probably redundant with [tearOff].
57
58 /// The result of getting a member function (this can be an instance, a
59 /// static, or top-level function). See also [functionLikeTearOff].
60 tearOff,
61
62 /// The "call" method of a class that has a call method (and thus implements
63 /// [Function])
64 functionLike,
65
66 /// The result of getting an instance method named "call"
67 functionLikeTearOff,
68
69 /// A local function (aka closure) that has escaped
70 localFunction,
71
72 /// The result of getting a super instance function
73 superTearOff,
74 }
75
76 class FletchRegistry {
77 final FletchEnqueuer world;
78
79 FletchRegistry(FletchCompilerImplementation compiler)
80 : world = compiler.enqueuer.codegen;
81
82 void registerStaticUse(StaticUse staticUse) {
83 // TODO(ahe): Call a different method.
84 world.registerStaticUse(staticUse);
85 }
86
87 void registerInstantiatedClass(ClassElement element) {
88 world.registerInstantiatedType(element.rawType);
89 }
90
91 void registerDynamicUse(Selector selector) {
92 world.registerDynamicUse(new DynamicUse(selector, null));
93 }
94
95 void registerInstantiatedType(InterfaceType type) {
96 world.registerInstantiatedType(type);
97 }
98
99 void registerIsCheck(DartType type) {
100 world.registerIsCheck(type);
101 }
102
103 void registerLocalInvoke(LocalElement element, Selector selector) {
104 world.recordElementUsage(element, selector);
105 }
106
107 void registerClosurization(FunctionElement function, ClosureKind kind) {
108 switch (kind) {
109 case ClosureKind.superTearOff:
110 case ClosureKind.tearOff:
111 assert(function.memberContext == function);
112 break;
113
114 case ClosureKind.functionLike:
115 case ClosureKind.functionLikeTearOff:
116 assert(function.memberContext == function);
117 assert(function.isInstanceMember);
118 assert(function.name == "call");
119 break;
120
121 case ClosureKind.localFunction:
122 assert(function.memberContext != function);
123 }
124 world.dynamicCallEnqueuer.enqueueClosure(function, kind);
125 }
126 }
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/fletch_native_descriptor.dart ('k') | pkg/fletchc/lib/src/fletch_selector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698