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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/glue.dart

Issue 861093002: Support intercepted getters, setters and index operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_generator_dependencies; 5 library code_generator_dependencies;
6 6
7 import '../js_backend.dart'; 7 import '../js_backend.dart';
8 import '../../dart2jslib.dart'; 8 import '../../dart2jslib.dart';
9 import '../../js_emitter/js_emitter.dart'; 9 import '../../js_emitter/js_emitter.dart';
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
11 import '../../constants/values.dart'; 11 import '../../constants/values.dart';
12 import '../../elements/elements.dart'; 12 import '../../elements/elements.dart';
13 import '../../constants/expressions.dart'; 13 import '../../constants/expressions.dart';
14 import '../../closure.dart' show ClosureClassElement; 14 import '../../closure.dart' show ClosureClassElement;
15 import '../../universe/universe.dart' show SelectorKind;
16
17 /// A non-call selector translated to JavaScript call semantics.
18 ///
19 /// The name of the this selector is already the correct JavaScript target name
20 /// as translated by the namer.
21 class JsCallSelector extends Selector {
22 /// The selector from which this selector originated. This selector is used
23 /// to identify possible targets using Dart semantics.
24 final Selector source;
25 JsCallSelector(Selector source,
26 String name,
27 int arity,
28 List<String> namedArguments)
29 : this.source = source,
30 super.internal(SelectorKind.CALL, name, null, arity, namedArguments,
31 <String>[], source.hashCode * 13 + name.hashCode);
32 }
asgerf 2015/01/21 10:21:05 It seems to me the JsCallSelector is never created
15 33
16 /// Encapsulates the dependencies of the function-compiler to the compiler, 34 /// Encapsulates the dependencies of the function-compiler to the compiler,
17 /// backend and emitter. 35 /// backend and emitter.
18 // TODO(sigurdm): Should be refactored when we have a better feeling for the 36 // TODO(sigurdm): Should be refactored when we have a better feeling for the
19 // interface. 37 // interface.
20 class Glue { 38 class Glue {
21 final Compiler _compiler; 39 final Compiler _compiler;
22 40
23 JavaScriptBackend get _backend => _compiler.backend; 41 JavaScriptBackend get _backend => _compiler.backend;
24 42
(...skipping 28 matching lines...) Expand all
53 return _backend.mapLiteralConstructor; 71 return _backend.mapLiteralConstructor;
54 } 72 }
55 73
56 ConstructorElement get mapLiteralConstructorEmpty { 74 ConstructorElement get mapLiteralConstructorEmpty {
57 return _backend.mapLiteralConstructorEmpty; 75 return _backend.mapLiteralConstructorEmpty;
58 } 76 }
59 77
60 FunctionElement get identicalFunction => _compiler.identicalFunction; 78 FunctionElement get identicalFunction => _compiler.identicalFunction;
61 79
62 String invocationName(Selector selector) { 80 String invocationName(Selector selector) {
81 if (selector is JsCallSelector) {
82 return selector.name;
83 }
63 return _namer.invocationName(selector); 84 return _namer.invocationName(selector);
64 } 85 }
65 86
66 FunctionElement get getInterceptorMethod => _backend.getInterceptorMethod; 87 FunctionElement get getInterceptorMethod => _backend.getInterceptorMethod;
67 88
68 void registerUseInterceptorInCodegen() { 89 void registerUseInterceptorInCodegen() {
69 _backend.registerUseInterceptor(_compiler.enqueuer.codegen); 90 _backend.registerUseInterceptor(_compiler.enqueuer.codegen);
70 } 91 }
71 92
72 bool isInterceptedSelector(Selector selector) { 93 bool isInterceptedSelector(Selector selector) {
(...skipping 15 matching lines...) Expand all
88 String instanceFieldPropertyName(Element field) { 109 String instanceFieldPropertyName(Element field) {
89 return _namer.instanceFieldPropertyName(field); 110 return _namer.instanceFieldPropertyName(field);
90 } 111 }
91 112
92 js.Expression prototypeAccess(ClassElement e, 113 js.Expression prototypeAccess(ClassElement e,
93 {bool hasBeenInstantiated: false}) { 114 {bool hasBeenInstantiated: false}) {
94 return _emitter.prototypeAccess(e, 115 return _emitter.prototypeAccess(e,
95 hasBeenInstantiated: hasBeenInstantiated); 116 hasBeenInstantiated: hasBeenInstantiated);
96 } 117 }
97 118
119
120 String getInterceptorName(Set<ClassElement> interceptedClasses) {
121 return _backend.namer.getInterceptorName(
122 getInterceptorMethod,
123 interceptedClasses);
124 }
125
126 js.Expression getInterceptorLibrary() {
127 return new js.VariableUse(
128 _backend.namer.globalObjectFor(_backend.interceptorsLibrary));
129 }
98 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698