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

Side by Side Diff: pkg/fletchc/lib/src/fletch_backend.dart

Issue 1059573004: Compile tearoffs of static functions as constants. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: 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
OLDNEW
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.fletch_backend; 5 library fletchc.fletch_backend;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'package:compiler/src/dart2jslib.dart' show 10 import 'package:compiler/src/dart2jslib.dart' show
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 InvokeNative; 68 InvokeNative;
69 69
70 import 'package:compiler/src/resolution/resolution.dart' show 70 import 'package:compiler/src/resolution/resolution.dart' show
71 TreeElements; 71 TreeElements;
72 72
73 import 'package:compiler/src/library_loader.dart' show 73 import 'package:compiler/src/library_loader.dart' show
74 LibraryLoader; 74 LibraryLoader;
75 75
76 import 'fletch_constants.dart' show 76 import 'fletch_constants.dart' show
77 FletchClassConstant, 77 FletchClassConstant,
78 FletchFunctionConstant; 78 FletchFunctionConstant,
79 FletchClassInstanceConstant;
79 80
80 import 'compiled_function.dart' show 81 import 'compiled_function.dart' show
81 CompiledFunction; 82 CompiledFunction;
82 83
83 import 'fletch_context.dart'; 84 import 'fletch_context.dart';
84 85
85 import 'fletch_selector.dart'; 86 import 'fletch_selector.dart';
86 87
87 import 'function_codegen.dart'; 88 import 'function_codegen.dart';
88 89
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 ConstructedConstantValue value = constant; 916 ConstructedConstantValue value = constant;
916 ClassElement classElement = value.type.element; 917 ClassElement classElement = value.type.element;
917 CompiledClass compiledClass = compiledClasses[classElement]; 918 CompiledClass compiledClass = compiledClasses[classElement];
918 for (ConstantValue field in value.fields) { 919 for (ConstantValue field in value.fields) {
919 int fieldId = context.compiledConstants[field]; 920 int fieldId = context.compiledConstants[field];
920 commands.add(new PushFromMap(MapId.constants, fieldId)); 921 commands.add(new PushFromMap(MapId.constants, fieldId));
921 } 922 }
922 commands 923 commands
923 ..add(new PushFromMap(MapId.classes, compiledClass.id)) 924 ..add(new PushFromMap(MapId.classes, compiledClass.id))
924 ..add(const PushNewInstance()); 925 ..add(const PushNewInstance());
926 } else if (constant is FletchClassInstanceConstant) {
927 commands
928 ..add(new PushFromMap(MapId.classes, constant.classId))
929 ..add(const PushNewInstance());
925 } else { 930 } else {
926 throw "Unsupported constant: ${constant.toStructuredString()}"; 931 throw "Unsupported constant: ${constant.toStructuredString()}";
927 } 932 }
928 commands.add(new PopToMap(MapId.constants, id)); 933 commands.add(new PopToMap(MapId.constants, id));
929 }); 934 });
930 935
931 for (CompiledClass compiledClass in classes) { 936 for (CompiledClass compiledClass in classes) {
932 CompiledClass superclass = compiledClass.superclass; 937 CompiledClass superclass = compiledClass.superclass;
933 if (superclass == null) continue; 938 if (superclass == null) continue;
934 commands.add(new PushFromMap(MapId.classes, compiledClass.id)); 939 commands.add(new PushFromMap(MapId.classes, compiledClass.id));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 compiler.reportError( 1160 compiler.reportError(
1156 spannable, MessageKind.GENERIC, {'text': reason}); 1161 spannable, MessageKind.GENERIC, {'text': reason});
1157 var constString = constantSystem.createString( 1162 var constString = constantSystem.createString(
1158 new DartString.literal(reason)); 1163 new DartString.literal(reason));
1159 context.markConstantUsed(constString); 1164 context.markConstantUsed(constString);
1160 function 1165 function
1161 ..builder.loadConst(function.allocateConstant(constString)) 1166 ..builder.loadConst(function.allocateConstant(constString))
1162 ..builder.emitThrow(); 1167 ..builder.emitThrow();
1163 } 1168 }
1164 } 1169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698