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

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

Issue 779593002: Move elementAccess() from namer to emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 final Map<Element, ClassBuilder> cachedBuilders; 9 final Map<Element, ClassBuilder> cachedBuilders;
10 10
(...skipping 23 matching lines...) Expand all
34 directSubtypes = new Map<ClassElement, List<ClassElement>>(), 34 directSubtypes = new Map<ClassElement, List<ClassElement>>(),
35 nativeMethods = new Set<FunctionElement>(), 35 nativeMethods = new Set<FunctionElement>(),
36 nativeBuffer = new CodeBuffer(), 36 nativeBuffer = new CodeBuffer(),
37 cachedBuilders = emitterTask.compiler.cacheStrategy.newMap(); 37 cachedBuilders = emitterTask.compiler.cacheStrategy.newMap();
38 38
39 Compiler get compiler => emitterTask.compiler; 39 Compiler get compiler => emitterTask.compiler;
40 JavaScriptBackend get backend => compiler.backend; 40 JavaScriptBackend get backend => compiler.backend;
41 41
42 jsAst.Expression get defPropFunction { 42 jsAst.Expression get defPropFunction {
43 Element element = backend.findHelper('defineProperty'); 43 Element element = backend.findHelper('defineProperty');
44 return backend.namer.elementAccess(element); 44 return emitterTask.globalPropertyAccess(element);
floitsch 2014/12/03 17:02:24 staticFunction
zarah 2014/12/05 08:22:50 Done.
45 } 45 }
46 46
47 /** 47 /**
48 * Writes the class definitions for the interceptors to [mainBuffer]. 48 * Writes the class definitions for the interceptors to [mainBuffer].
49 * Writes code to associate dispatch tags with interceptors to [nativeBuffer]. 49 * Writes code to associate dispatch tags with interceptors to [nativeBuffer].
50 * 50 *
51 * The interceptors are filtered to avoid emitting trivial interceptors. For 51 * The interceptors are filtered to avoid emitting trivial interceptors. For
52 * example, if the program contains no code that can distinguish between the 52 * example, if the program contains no code that can distinguish between the
53 * numerous subclasses of `Element` then we can pretend that `Element` is a 53 * numerous subclasses of `Element` then we can pretend that `Element` is a
54 * leaf class, and all instances of subclasses of `Element` are instances of 54 * leaf class, and all instances of subclasses of `Element` are instances of
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // `Object.prototype` to avoid checking in `getInterceptor` and 329 // `Object.prototype` to avoid checking in `getInterceptor` and
330 // specializations. 330 // specializations.
331 } 331 }
332 332
333 void potentiallyConvertDartClosuresToJs( 333 void potentiallyConvertDartClosuresToJs(
334 List<jsAst.Statement> statements, 334 List<jsAst.Statement> statements,
335 FunctionElement member, 335 FunctionElement member,
336 List<jsAst.Parameter> stubParameters) { 336 List<jsAst.Parameter> stubParameters) {
337 FunctionSignature parameters = member.functionSignature; 337 FunctionSignature parameters = member.functionSignature;
338 Element converter = backend.findHelper('convertDartClosureToJS'); 338 Element converter = backend.findHelper('convertDartClosureToJS');
339 jsAst.Expression closureConverter = backend.namer.elementAccess(converter); 339 jsAst.Expression closureConverter =
340 emitterTask.globalPropertyAccess(converter);
floitsch 2014/12/03 17:02:24 staticFunction
zarah 2014/12/05 08:22:49 Done.
340 parameters.forEachParameter((ParameterElement parameter) { 341 parameters.forEachParameter((ParameterElement parameter) {
341 String name = parameter.name; 342 String name = parameter.name;
342 // If [name] is not in [stubParameters], then the parameter is an optional 343 // If [name] is not in [stubParameters], then the parameter is an optional
343 // parameter that was not provided for this stub. 344 // parameter that was not provided for this stub.
344 for (jsAst.Parameter stubParameter in stubParameters) { 345 for (jsAst.Parameter stubParameter in stubParameters) {
345 if (stubParameter.name == name) { 346 if (stubParameter.name == name) {
346 DartType type = parameter.type.unalias(compiler); 347 DartType type = parameter.type.unalias(compiler);
347 if (type is FunctionType) { 348 if (type is FunctionType) {
348 // The parameter type is a function type either directly or through 349 // The parameter type is a function type either directly or through
349 // typedef(s). 350 // typedef(s).
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (emitterTask.compiler.enableMinification) targetBuffer.add(';'); 472 if (emitterTask.compiler.enableMinification) targetBuffer.add(';');
472 targetBuffer.add(jsAst.prettyPrint( 473 targetBuffer.add(jsAst.prettyPrint(
473 new jsAst.ExpressionStatement(init), compiler)); 474 new jsAst.ExpressionStatement(init), compiler));
474 targetBuffer.add('\n'); 475 targetBuffer.add('\n');
475 } 476 }
476 477
477 targetBuffer.add(nativeBuffer); 478 targetBuffer.add(nativeBuffer);
478 targetBuffer.add('\n'); 479 targetBuffer.add('\n');
479 } 480 }
480 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698