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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 19599007: Implement reflection on native classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 years, 5 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 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 generateDefines(backend.jsInterceptorClass); 226 generateDefines(backend.jsInterceptorClass);
227 for (ClassElement classElement in classes) { 227 for (ClassElement classElement in classes) {
228 generateDefines(classElement); 228 generateDefines(classElement);
229 } 229 }
230 } 230 }
231 231
232 // Emit the native class interceptors that were actually used. 232 // Emit the native class interceptors that were actually used.
233 for (ClassElement classElement in classes) { 233 for (ClassElement classElement in classes) {
234 if (neededClasses.contains(classElement)) { 234 if (neededClasses.contains(classElement)) {
235 ClassBuilder builder = builders[classElement];
236 // Define interceptor class for [classElement]. 235 // Define interceptor class for [classElement].
237 String className = backend.namer.getName(classElement); 236 emitter.emitClassBuilderWithReflectionData(
238 jsAst.Expression init = 237 backend.namer.getName(classElement),
239 js(emitter.classesCollector)[className].assign( 238 classElement, builders[classElement],
240 builder.toObjectInitializer()); 239 emitter.bufferForElement(classElement, mainBuffer));
241 mainBuffer.write(jsAst.prettyPrint(init, compiler));
242 mainBuffer.write('$N$n');
243 emitter.needsDefineClass = true; 240 emitter.needsDefineClass = true;
244 } 241 }
245 } 242 }
246 } 243 }
247 244
248 ClassBuilder generateNativeClass(ClassElement classElement) { 245 ClassBuilder generateNativeClass(ClassElement classElement) {
249 assert(!classElement.hasBackendMembers); 246 assert(!classElement.hasBackendMembers);
250 nativeClasses.add(classElement); 247 nativeClasses.add(classElement);
251 248
252 ClassElement superclass = classElement.superclass; 249 ClassElement superclass = classElement.superclass;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (emitter.compiler.enableMinification) targetBuffer.add(';'); 444 if (emitter.compiler.enableMinification) targetBuffer.add(';');
448 targetBuffer.add(jsAst.prettyPrint( 445 targetBuffer.add(jsAst.prettyPrint(
449 new jsAst.ExpressionStatement(init), compiler)); 446 new jsAst.ExpressionStatement(init), compiler));
450 targetBuffer.add('\n'); 447 targetBuffer.add('\n');
451 } 448 }
452 449
453 targetBuffer.add(nativeBuffer); 450 targetBuffer.add(nativeBuffer);
454 targetBuffer.add('\n'); 451 targetBuffer.add('\n');
455 } 452 }
456 } 453 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | dart/tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698