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

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

Issue 1417103002: Add ElementKind for factory constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 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
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 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 // implementation/declaration distinction. 1138 // implementation/declaration distinction.
1139 Element get sourceElement => sourceElementStack.last; 1139 Element get sourceElement => sourceElementStack.last;
1140 1140
1141 bool get _checkOrTrustTypes => 1141 bool get _checkOrTrustTypes =>
1142 compiler.enableTypeAssertions || compiler.trustTypeAnnotations; 1142 compiler.enableTypeAssertions || compiler.trustTypeAnnotations;
1143 1143
1144 /// Build the graph for [target]. 1144 /// Build the graph for [target].
1145 HGraph build() { 1145 HGraph build() {
1146 assert(invariant(target, target.isImplementation)); 1146 assert(invariant(target, target.isImplementation));
1147 HInstruction.idCounter = 0; 1147 HInstruction.idCounter = 0;
1148 ElementKind kind = target.kind;
1149 // TODO(sigmund): remove `result` and return graph directly, need to ensure 1148 // TODO(sigmund): remove `result` and return graph directly, need to ensure
1150 // that it can never be null (see result in buildFactory for instance). 1149 // that it can never be null (see result in buildFactory for instance).
1151 var result; 1150 var result;
1152 if (kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 1151 if (target.isGenerativeConstructor) {
1153 result = buildFactory(target); 1152 result = buildFactory(target);
1154 } else if (kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY || 1153 } else if (target.isGenerativeConstructorBody ||
1155 kind == ElementKind.FUNCTION || 1154 target.isFactoryConstructor ||
1156 kind == ElementKind.GETTER || 1155 target.isFunction ||
1157 kind == ElementKind.SETTER) { 1156 target.isGetter ||
1157 target.isSetter) {
1158 result = buildMethod(target); 1158 result = buildMethod(target);
1159 } else if (kind == ElementKind.FIELD) { 1159 } else if (target.isField) {
1160 if (target.isInstanceMember) { 1160 if (target.isInstanceMember) {
1161 assert(compiler.enableTypeAssertions); 1161 assert(compiler.enableTypeAssertions);
1162 result = buildCheckedSetter(target); 1162 result = buildCheckedSetter(target);
1163 } else { 1163 } else {
1164 result = buildLazyInitializer(target); 1164 result = buildLazyInitializer(target);
1165 } 1165 }
1166 } else { 1166 } else {
1167 reporter.internalError(target, 'Unexpected element kind $kind.'); 1167 reporter.internalError(target, 'Unexpected element kind $target.');
1168 } 1168 }
1169 assert(result.isValid()); 1169 assert(result.isValid());
1170 return result; 1170 return result;
1171 } 1171 }
1172 1172
1173 1173
1174 HBasicBlock addNewBlock() { 1174 HBasicBlock addNewBlock() {
1175 HBasicBlock block = graph.addNewBlock(); 1175 HBasicBlock block = graph.addNewBlock();
1176 // If adding a new block during building of an expression, it is due to 1176 // If adding a new block during building of an expression, it is due to
1177 // conditional expressions or short-circuit logical operators. 1177 // conditional expressions or short-circuit logical operators.
(...skipping 7967 matching lines...) Expand 10 before | Expand all | Expand 10 after
9145 if (unaliased is TypedefType) throw 'unable to unalias $type'; 9145 if (unaliased is TypedefType) throw 'unable to unalias $type';
9146 unaliased.accept(this, builder); 9146 unaliased.accept(this, builder);
9147 } 9147 }
9148 9148
9149 void visitDynamicType(DynamicType type, SsaBuilder builder) { 9149 void visitDynamicType(DynamicType type, SsaBuilder builder) {
9150 JavaScriptBackend backend = builder.compiler.backend; 9150 JavaScriptBackend backend = builder.compiler.backend;
9151 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 9151 ClassElement cls = backend.findHelper('DynamicRuntimeType');
9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
9153 } 9153 }
9154 } 9154 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/modelz.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698