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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1093363002: Refactor DartTypeVisitor and ElementVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 5 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 part of ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 SsaCodeGeneratorTask generator; 8 SsaCodeGeneratorTask generator;
9 SsaBuilderTask builder; 9 SsaBuilderTask builder;
10 SsaOptimizerTask optimizer; 10 SsaOptimizerTask optimizer;
(...skipping 6876 matching lines...) Expand 10 before | Expand all | Expand 10 after
6887 assert(branch is HIf); 6887 assert(branch is HIf);
6888 branch.blockInformation = conditionStartBlock.blockFlow; 6888 branch.blockInformation = conditionStartBlock.blockFlow;
6889 } 6889 }
6890 } 6890 }
6891 6891
6892 class TypeBuilder implements DartTypeVisitor<dynamic, SsaBuilder> { 6892 class TypeBuilder implements DartTypeVisitor<dynamic, SsaBuilder> {
6893 final ClassWorld classWorld; 6893 final ClassWorld classWorld;
6894 6894
6895 TypeBuilder(this.classWorld); 6895 TypeBuilder(this.classWorld);
6896 6896
6897 void visitType(DartType type, _) { 6897 void visit(DartType type, SsaBuilder builder) => type.accept(this, builder);
6898 throw 'Internal error $type';
6899 }
6900 6898
6901 void visitVoidType(VoidType type, SsaBuilder builder) { 6899 void visitVoidType(VoidType type, SsaBuilder builder) {
6902 ClassElement cls = builder.backend.findHelper('VoidRuntimeType'); 6900 ClassElement cls = builder.backend.findHelper('VoidRuntimeType');
6903 builder.push(new HVoidType(type, new TypeMask.exact(cls, classWorld))); 6901 builder.push(new HVoidType(type, new TypeMask.exact(cls, classWorld)));
6904 } 6902 }
6905 6903
6906 void visitTypeVariableType(TypeVariableType type, 6904 void visitTypeVariableType(TypeVariableType type,
6907 SsaBuilder builder) { 6905 SsaBuilder builder) {
6908 ClassElement cls = builder.backend.findHelper('RuntimeType'); 6906 ClassElement cls = builder.backend.findHelper('RuntimeType');
6909 TypeMask instructionType = new TypeMask.subclass(cls, classWorld); 6907 TypeMask instructionType = new TypeMask.subclass(cls, classWorld);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6949 } 6947 }
6950 6948
6951 void visitMalformedType(MalformedType type, SsaBuilder builder) { 6949 void visitMalformedType(MalformedType type, SsaBuilder builder) {
6952 visitDynamicType(const DynamicType(), builder); 6950 visitDynamicType(const DynamicType(), builder);
6953 } 6951 }
6954 6952
6955 void visitStatementType(StatementType type, SsaBuilder builder) { 6953 void visitStatementType(StatementType type, SsaBuilder builder) {
6956 throw 'not implemented visitStatementType($type)'; 6954 throw 'not implemented visitStatementType($type)';
6957 } 6955 }
6958 6956
6959 void visitGenericType(GenericType type, SsaBuilder builder) {
6960 throw 'not implemented visitGenericType($type)';
6961 }
6962
6963 void visitInterfaceType(InterfaceType type, SsaBuilder builder) { 6957 void visitInterfaceType(InterfaceType type, SsaBuilder builder) {
6964 List<HInstruction> inputs = <HInstruction>[]; 6958 List<HInstruction> inputs = <HInstruction>[];
6965 for (DartType typeArgument in type.typeArguments) { 6959 for (DartType typeArgument in type.typeArguments) {
6966 typeArgument.accept(this, builder); 6960 typeArgument.accept(this, builder);
6967 inputs.add(builder.pop()); 6961 inputs.add(builder.pop());
6968 } 6962 }
6969 ClassElement cls; 6963 ClassElement cls;
6970 if (type.typeArguments.isEmpty) { 6964 if (type.typeArguments.isEmpty) {
6971 cls = builder.backend.findHelper('RuntimeTypePlain'); 6965 cls = builder.backend.findHelper('RuntimeTypePlain');
6972 } else { 6966 } else {
6973 cls = builder.backend.findHelper('RuntimeTypeGeneric'); 6967 cls = builder.backend.findHelper('RuntimeTypeGeneric');
6974 } 6968 }
6975 builder.push(new HInterfaceType(inputs, type, 6969 builder.push(new HInterfaceType(inputs, type,
6976 new TypeMask.exact(cls, classWorld))); 6970 new TypeMask.exact(cls, classWorld)));
6977 } 6971 }
6978 6972
6979 void visitTypedefType(TypedefType type, SsaBuilder builder) { 6973 void visitTypedefType(TypedefType type, SsaBuilder builder) {
6980 DartType unaliased = type.unalias(builder.compiler); 6974 DartType unaliased = type.unalias(builder.compiler);
6981 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6975 if (unaliased is TypedefType) throw 'unable to unalias $type';
6982 unaliased.accept(this, builder); 6976 unaliased.accept(this, builder);
6983 } 6977 }
6984 6978
6985 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6979 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6986 JavaScriptBackend backend = builder.compiler.backend; 6980 JavaScriptBackend backend = builder.compiler.backend;
6987 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 6981 ClassElement cls = backend.findHelper('DynamicRuntimeType');
6988 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 6982 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
6989 } 6983 }
6990 } 6984 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/scanner/class_element_parser.dart ('k') | pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698