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

Side by Side Diff: lib/compiler/implementation/ssa/builder.dart

Issue 9873012: Move member-iterating code into ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 8 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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 909
910 final Map<FunctionElement, TreeElements> constructorElements = 910 final Map<FunctionElement, TreeElements> constructorElements =
911 compiler.resolver.constructorElements; 911 compiler.resolver.constructorElements;
912 List<FunctionElement> constructors = new List<FunctionElement>(); 912 List<FunctionElement> constructors = new List<FunctionElement>();
913 913
914 // Analyze the constructor and all referenced constructors and collect 914 // Analyze the constructor and all referenced constructors and collect
915 // initializers and constructor bodies. 915 // initializers and constructor bodies.
916 inlineInitializers(functionElement, constructors, fieldValues); 916 inlineInitializers(functionElement, constructors, fieldValues);
917 917
918 // Call the JavaScript constructor with the fields as argument. 918 // Call the JavaScript constructor with the fields as argument.
919 // TODO(floitsch,karlklose): move this code to ClassElement and share with
920 // the emitter.
921 List<HInstruction> constructorArguments = <HInstruction>[]; 919 List<HInstruction> constructorArguments = <HInstruction>[];
922 ClassElement element = classElement; 920 classElement.forEachInstanceField(
923 while (element != null) { 921 includeBackendMembers: true,
924 for (Element member in element.members) { 922 includeSuperMembers: true,
925 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { 923 f: (ClassElement enclosingClass, Element member) {
926 HInstruction value = fieldValues[member]; 924 HInstruction value = fieldValues[member];
927 if (value === null) { 925 if (value === null) {
928 // The field has no value in the initializer list. Initialize it 926 // The field has no value in the initializer list. Initialize it
929 // with the declaration-site constant (if any). 927 // with the declaration-site constant (if any).
930 Constant fieldValue = 928 Constant fieldValue = compiler.constantHandler.compileVariable(member);
931 compiler.constantHandler.compileVariable(member); 929 value = graph.addConstant(fieldValue);
932 value = graph.addConstant(fieldValue);
933 }
934 constructorArguments.add(value);
935 }
936 } 930 }
937 element = element.superclass; 931 constructorArguments.add(value);
938 } 932 });
933
939 HForeignNew newObject = new HForeignNew(classElement, constructorArguments); 934 HForeignNew newObject = new HForeignNew(classElement, constructorArguments);
940 add(newObject); 935 add(newObject);
941 // Generate calls to the constructor bodies. 936 // Generate calls to the constructor bodies.
942 for (int index = constructors.length - 1; index >= 0; index--) { 937 for (int index = constructors.length - 1; index >= 0; index--) {
943 FunctionElement constructor = constructors[index]; 938 FunctionElement constructor = constructors[index];
944 // TODO(floitsch): find better way to detect that constructor body is 939 // TODO(floitsch): find better way to detect that constructor body is
945 // empty. 940 // empty.
946 if (constructor is SynthesizedConstructorElement) continue; 941 if (constructor is SynthesizedConstructorElement) continue;
947 ConstructorBodyElement body = getConstructorBody(classElement, 942 ConstructorBodyElement body = getConstructorBody(classElement,
948 constructor); 943 constructor);
(...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 false, 2970 false,
2976 <HInstruction>[target, input])); 2971 <HInstruction>[target, input]));
2977 return builder.pop(); 2972 return builder.pop();
2978 } 2973 }
2979 2974
2980 HInstruction result() { 2975 HInstruction result() {
2981 flushLiterals(); 2976 flushLiterals();
2982 return prefix; 2977 return prefix;
2983 } 2978 }
2984 } 2979 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698