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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart

Issue 25675002: Generative constructor factories for native objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /** 7 /**
8 * Generates the code for all used classes in the program. Static fields (even 8 * Generates the code for all used classes in the program. Static fields (even
9 * in classes) are ignored, since they can be treated as non-class elements. 9 * in classes) are ignored, since they can be treated as non-class elements.
10 * 10 *
(...skipping 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 ConstantHandler handler = compiler.constantHandler; 2960 ConstantHandler handler = compiler.constantHandler;
2961 List<Constant> constants = handler.getConstantsForEmission(); 2961 List<Constant> constants = handler.getConstantsForEmission();
2962 for (Constant constant in constants) { 2962 for (Constant constant in constants) {
2963 if (constant is TypeConstant) { 2963 if (constant is TypeConstant) {
2964 TypeConstant typeConstant = constant; 2964 TypeConstant typeConstant = constant;
2965 Element element = typeConstant.representedType.element; 2965 Element element = typeConstant.representedType.element;
2966 if (element is ClassElement) { 2966 if (element is ClassElement) {
2967 ClassElement classElement = element; 2967 ClassElement classElement = element;
2968 elements.add(backend.emitter.constantReference(constant)); 2968 elements.add(backend.emitter.constantReference(constant));
2969 elements.add(js(namer.isolateAccess(classElement))); 2969 elements.add(js(namer.isolateAccess(classElement)));
2970
2971 // Create JavaScript Object map for by-name lookup of generative
2972 // constructors.
2973 var properties = [];
2974 classElement.forEachMember(
2975 (ClassElement enclosingClass, Element member) {
2976 if (member.isGenerativeConstructor()) {
2977 properties.add(
2978 new jsAst.Property(
2979 js.string(member.name.slowToString()),
2980 new jsAst.VariableUse(
2981 backend.namer.isolateAccess(member))));
2982 }
2983 },
2984 includeBackendMembers: false,
2985 includeSuperAndInjectedMembers: false);
2986
2987 var map = new jsAst.ObjectInitializer(properties);
2988 elements.add(map);
2970 } 2989 }
2971 } 2990 }
2972 } 2991 }
2973 2992
2974 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); 2993 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements);
2975 String name = 2994 String name =
2976 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor); 2995 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor);
2977 jsAst.Expression assignment = js('$isolateProperties.$name = #', array); 2996 jsAst.Expression assignment = js('$isolateProperties.$name = #', array);
2978 2997
2979 buffer.write(jsAst.prettyPrint(assignment, compiler)); 2998 buffer.write(jsAst.prettyPrint(assignment, compiler));
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
3598 } 3617 }
3599 3618
3600 bool isDeferred(Element element) { 3619 bool isDeferred(Element element) {
3601 return compiler.deferredLoadTask.isDeferred(element); 3620 return compiler.deferredLoadTask.isDeferred(element);
3602 } 3621 }
3603 3622
3604 bool get areAnyElementsDeferred { 3623 bool get areAnyElementsDeferred {
3605 return compiler.deferredLoadTask.areAnyElementsDeferred; 3624 return compiler.deferredLoadTask.areAnyElementsDeferred;
3606 } 3625 }
3607 } 3626 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698