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

Side by Side Diff: lib/compiler/implementation/native_handler.dart

Issue 10911007: Rename Type to DartType to avoid conflicts with the class Type in the core library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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('native'); 5 #library('native');
6 #import('dart:uri'); 6 #import('dart:uri');
7 #import('leg.dart'); 7 #import('leg.dart');
8 #import('elements/elements.dart'); 8 #import('elements/elements.dart');
9 #import('js_backend/js_backend.dart'); 9 #import('js_backend/js_backend.dart');
10 #import('scanner/scannerlib.dart'); 10 #import('scanner/scannerlib.dart');
11 #import('ssa/ssa.dart'); 11 #import('ssa/ssa.dart');
12 #import('tree/tree.dart'); 12 #import('tree/tree.dart');
13 #import('util/util.dart'); 13 #import('util/util.dart');
14 14
15 void processNativeClasses(Enqueuer world, 15 void processNativeClasses(Enqueuer world,
16 CodeEmitterTask emitter, 16 CodeEmitterTask emitter,
17 Collection<LibraryElement> libraries) { 17 Collection<LibraryElement> libraries) {
18 for (LibraryElement library in libraries) { 18 for (LibraryElement library in libraries) {
19 processNativeClassesInLibrary(world, emitter, library); 19 processNativeClassesInLibrary(world, emitter, library);
20 } 20 }
21 } 21 }
22 22
23 void addSubtypes(ClassElement cls, 23 void addSubtypes(ClassElement cls,
24 NativeEmitter emitter) { 24 NativeEmitter emitter) {
25 for (Type type in cls.allSupertypes) { 25 for (DartType type in cls.allSupertypes) {
26 List<Element> subtypes = emitter.subtypes.putIfAbsent( 26 List<Element> subtypes = emitter.subtypes.putIfAbsent(
27 type.element, 27 type.element,
28 () => <ClassElement>[]); 28 () => <ClassElement>[]);
29 subtypes.add(cls); 29 subtypes.add(cls);
30 } 30 }
31 31
32 List<Element> directSubtypes = emitter.directSubtypes.putIfAbsent( 32 List<Element> directSubtypes = emitter.directSubtypes.putIfAbsent(
33 cls.superclass, 33 cls.superclass,
34 () => <ClassElement>[]); 34 () => <ClassElement>[]);
35 directSubtypes.add(cls); 35 directSubtypes.add(cls);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 FunctionSignature parameters = element.computeSignature(builder.compiler); 231 FunctionSignature parameters = element.computeSignature(builder.compiler);
232 if (!hasBody) { 232 if (!hasBody) {
233 List<String> arguments = <String>[]; 233 List<String> arguments = <String>[];
234 List<HInstruction> inputs = <HInstruction>[]; 234 List<HInstruction> inputs = <HInstruction>[];
235 String receiver = ''; 235 String receiver = '';
236 if (element.isInstanceMember()) { 236 if (element.isInstanceMember()) {
237 receiver = '#.'; 237 receiver = '#.';
238 inputs.add(builder.localsHandler.readThis()); 238 inputs.add(builder.localsHandler.readThis());
239 } 239 }
240 parameters.forEachParameter((Element parameter) { 240 parameters.forEachParameter((Element parameter) {
241 Type type = parameter.computeType(compiler).unalias(compiler); 241 DartType type = parameter.computeType(compiler).unalias(compiler);
242 HInstruction input = builder.localsHandler.readLocal(parameter); 242 HInstruction input = builder.localsHandler.readLocal(parameter);
243 if (type is FunctionType) { 243 if (type is FunctionType) {
244 // The parameter type is a function type either directly or through 244 // The parameter type is a function type either directly or through
245 // typedef(s). 245 // typedef(s).
246 input = convertDartClosure(parameter, type); 246 input = convertDartClosure(parameter, type);
247 } 247 }
248 inputs.add(input); 248 inputs.add(input);
249 arguments.add('#'); 249 arguments.add('#');
250 }); 250 });
251 251
(...skipping 15 matching lines...) Expand all
267 new HForeign(jsCode, const LiteralDartString('Object'), inputs)); 267 new HForeign(jsCode, const LiteralDartString('Object'), inputs));
268 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit); 268 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit);
269 } else { 269 } else {
270 // This is JS code written in a Dart file with the construct 270 // This is JS code written in a Dart file with the construct
271 // native """ ... """;. It does not work well with mangling, 271 // native """ ... """;. It does not work well with mangling,
272 // but there should currently be no clash between leg mangling 272 // but there should currently be no clash between leg mangling
273 // and the library where this construct is being used. This 273 // and the library where this construct is being used. This
274 // mangling problem will go away once we switch these libraries 274 // mangling problem will go away once we switch these libraries
275 // to use Leg's 'JS' function. 275 // to use Leg's 'JS' function.
276 parameters.forEachParameter((Element parameter) { 276 parameters.forEachParameter((Element parameter) {
277 Type type = parameter.computeType(compiler).unalias(compiler); 277 DartType type = parameter.computeType(compiler).unalias(compiler);
278 if (type is FunctionType) { 278 if (type is FunctionType) {
279 // The parameter type is a function type either directly or through 279 // The parameter type is a function type either directly or through
280 // typedef(s). 280 // typedef(s).
281 HInstruction jsClosure = convertDartClosure(parameter, type); 281 HInstruction jsClosure = convertDartClosure(parameter, type);
282 // Because the JS code references the argument name directly, 282 // Because the JS code references the argument name directly,
283 // we must keep the name and assign the JS closure to it. 283 // we must keep the name and assign the JS closure to it.
284 builder.add(new HForeign( 284 builder.add(new HForeign(
285 new DartString.literal('${parameter.name.slowToString()} = #'), 285 new DartString.literal('${parameter.name.slowToString()} = #'),
286 const LiteralDartString('void'), 286 const LiteralDartString('void'),
287 <HInstruction>[jsClosure])); 287 <HInstruction>[jsClosure]));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 String parameters) { 329 String parameters) {
330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
331 buffer.add("('$methodName')) {\n"); 331 buffer.add("('$methodName')) {\n");
332 buffer.add(" $code"); 332 buffer.add(" $code");
333 buffer.add(" } else {\n"); 333 buffer.add(" } else {\n");
334 buffer.add(" return Object.prototype.$methodName.call(this"); 334 buffer.add(" return Object.prototype.$methodName.call(this");
335 buffer.add(parameters == '' ? '' : ', $parameters'); 335 buffer.add(parameters == '' ? '' : ', $parameters');
336 buffer.add(");\n"); 336 buffer.add(");\n");
337 buffer.add(" }\n"); 337 buffer.add(" }\n");
338 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698