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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart

Issue 896763003: dart2js: emit noSuchMethod stubs in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot to save. Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class ClassStubGenerator { 7 class ClassStubGenerator {
8 final Namer namer; 8 final Namer namer;
9 final Compiler compiler; 9 final Compiler compiler;
10 final JavaScriptBackend backend; 10 final JavaScriptBackend backend;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 jsNames[jsName] = selector; 136 jsNames[jsName] = selector;
137 } 137 }
138 } 138 }
139 139
140 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); 140 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers);
141 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); 141 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers);
142 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); 142 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers);
143 return jsNames; 143 return jsNames;
144 } 144 }
145 145
146 jsAst.Expression generateStubForNoSuchMethod(Selector selector) { 146 StubMethod generateStubForNoSuchMethod(String name, Selector selector) {
147 // Values match JSInvocationMirror in js-helper library. 147 // Values match JSInvocationMirror in js-helper library.
148 int type = selector.invocationMirrorKind; 148 int type = selector.invocationMirrorKind;
149 List<String> parameterNames = 149 List<String> parameterNames =
150 new List.generate(selector.argumentCount, (i) => '\$$i'); 150 new List.generate(selector.argumentCount, (i) => '\$$i');
151 151
152 List<jsAst.Expression> argNames = 152 List<jsAst.Expression> argNames =
153 selector.getOrderedNamedArguments().map((String name) => 153 selector.getOrderedNamedArguments().map((String name) =>
154 js.string(name)).toList(); 154 js.string(name)).toList();
155 155
156 String methodName = selector.invocationMirrorMemberName; 156 String methodName = selector.invocationMirrorMemberName;
(...skipping 13 matching lines...) Expand all
170 backend.getCreateInvocationMirror()), 170 backend.getCreateInvocationMirror()),
171 'methodName': 171 'methodName':
172 js.string(compiler.enableMinification 172 js.string(compiler.enableMinification
173 ? internalName : methodName), 173 ? internalName : methodName),
174 'internalName': js.string(internalName), 174 'internalName': js.string(internalName),
175 'type': js.number(type), 175 'type': js.number(type),
176 'arguments': 176 'arguments':
177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), 177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
178 'namedArguments': new jsAst.ArrayInitializer(argNames)}); 178 'namedArguments': new jsAst.ArrayInitializer(argNames)});
179 179
180 jsAst.Expression function;
180 if (backend.isInterceptedName(selector.name)) { 181 if (backend.isInterceptedName(selector.name)) {
181 return js(r'function($receiver, #) { return # }', 182 function = js(r'function($receiver, #) { return # }',
182 [parameterNames, expression]); 183 [parameterNames, expression]);
183 } else { 184 } else {
184 return js(r'function(#) { return # }', [parameterNames, expression]); 185 function = js(r'function(#) { return # }', [parameterNames, expression]);
185 } 186 }
187 return new StubMethod(name, function);
186 } 188 }
187 } 189 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698