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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/task.dart

Issue 861093002: Support intercepted getters, setters and index operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Only reject instance members that need interceptors and disable a test that we do not support yet. Created 5 years, 10 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Generate code using the cps-based IR pipeline. 5 /// Generate code using the cps-based IR pipeline.
6 library code_generator_task; 6 library code_generator_task;
7 7
8 import 'glue.dart'; 8 import 'glue.dart';
9 import 'codegen.dart'; 9 import 'codegen.dart';
10 import 'unsugar.dart'; 10 import 'unsugar.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 String get name => 'CPS Ir pipeline'; 55 String get name => 'CPS Ir pipeline';
56 56
57 /// Generates JavaScript code for `work.element`. First tries to use the 57 /// Generates JavaScript code for `work.element`. First tries to use the
58 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language 58 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language
59 /// features not implemented it will fall back to the ssa pipeline (for 59 /// features not implemented it will fall back to the ssa pipeline (for
60 /// platform code) or will cancel compilation (for user code). 60 /// platform code) or will cancel compilation (for user code).
61 js.Fun compile(CodegenWorkItem work) { 61 js.Fun compile(CodegenWorkItem work) {
62 types = new TypeMaskSystem(compiler); 62 types = new TypeMaskSystem(compiler);
63 AstElement element = work.element; 63 AstElement element = work.element;
64 JavaScriptBackend backend = compiler.backend;
64 return compiler.withCurrentElement(element, () { 65 return compiler.withCurrentElement(element, () {
65 if (element.library.isPlatformLibrary) { 66 if (element.library.isPlatformLibrary ||
67 element.library == backend.interceptorsLibrary) {
66 compiler.log('Using SSA compiler for platform element $element'); 68 compiler.log('Using SSA compiler for platform element $element');
67 return fallbackCompiler.compile(work); 69 return fallbackCompiler.compile(work);
68 } 70 }
69 try { 71 try {
70 if (tracer != null) { 72 if (tracer != null) {
71 tracer.traceCompilation(element.name, null); 73 tracer.traceCompilation(element.name, null);
72 } 74 }
73 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); 75 cps.FunctionDefinition cpsFunction = compileToCpsIR(element);
74 cpsFunction = optimizeCpsIR(cpsFunction); 76 cpsFunction = optimizeCpsIR(cpsFunction);
75 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); 77 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction);
(...skipping 21 matching lines...) Expand all
97 // TODO(sigurdm): Support these constructs. 99 // TODO(sigurdm): Support these constructs.
98 if (element.isNative || 100 if (element.isNative ||
99 element.isField) { 101 element.isField) {
100 giveUp('unsupported element kind: ${element.name}:${element.kind}'); 102 giveUp('unsupported element kind: ${element.name}:${element.kind}');
101 } 103 }
102 104
103 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element); 105 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element);
104 if (cpsNode == null) { 106 if (cpsNode == null) {
105 giveUp('unable to build cps definition of $element'); 107 giveUp('unable to build cps definition of $element');
106 } 108 }
109 if (element.isInstanceMember && !element.isGenerativeConstructorBody) {
110 Selector selector = new Selector.fromElement(cpsNode.element);
111 if (glue.isInterceptedSelector(selector)) {
112 giveUp('cannot compile methods that need interceptor calling '
113 'convention.');
114 }
115 }
107 traceGraph("IR Builder", cpsNode); 116 traceGraph("IR Builder", cpsNode);
108 new UnsugarVisitor(glue).rewrite(cpsNode); 117 new UnsugarVisitor(glue).rewrite(cpsNode);
109 traceGraph("Unsugaring", cpsNode); 118 traceGraph("Unsugaring", cpsNode);
110 return cpsNode; 119 return cpsNode;
111 } 120 }
112 121
113 static const Pattern PRINT_TYPED_IR_FILTER = null; 122 static const Pattern PRINT_TYPED_IR_FILTER = null;
114 123
115 String formatTypeMask(TypeMask type) { 124 String formatTypeMask(TypeMask type) {
116 if (type is UnionTypeMask) { 125 if (type is UnionTypeMask) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 endSourcePosition = 233 endSourcePosition =
225 new TokenSourceFileLocation(sourceFile, endToken, name); 234 new TokenSourceFileLocation(sourceFile, endToken, name);
226 } 235 }
227 return node.withPosition(sourcePosition, endSourcePosition); 236 return node.withPosition(sourcePosition, endSourcePosition);
228 } 237 }
229 238
230 SourceFile sourceFileOfElement(Element element) { 239 SourceFile sourceFileOfElement(Element element) {
231 return element.implementation.compilationUnit.script.file; 240 return element.implementation.compilationUnit.script.file;
232 } 241 }
233 } 242 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/unsugar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698