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

Side by Side Diff: dart/frog/leg/ssa/builder.dart

Issue 9539009: Generate code that throws an exception on unimplemented features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 /** 324 /**
325 * Returns an [HInstruction] for the given element. If the element is 325 * Returns an [HInstruction] for the given element. If the element is
326 * boxed or stored in a closure then the method generates code to retrieve 326 * boxed or stored in a closure then the method generates code to retrieve
327 * the value. 327 * the value.
328 */ 328 */
329 HInstruction readLocal(Element element) { 329 HInstruction readLocal(Element element) {
330 if (isAccessedDirectly(element)) { 330 if (isAccessedDirectly(element)) {
331 if (directLocals[element] == null) { 331 if (directLocals[element] == null) {
332 builder.compiler.internalError("Cannot find value", element: element); 332 builder.compiler.internalError("Cannot find value $element",
333 element: element);
333 } 334 }
334 return directLocals[element]; 335 return directLocals[element];
335 } else if (isStoredInClosureField(element)) { 336 } else if (isStoredInClosureField(element)) {
336 Element redirect = redirectionMapping[element]; 337 Element redirect = redirectionMapping[element];
337 // We must not use the [LocalsHandler.readThis()] since that could 338 // We must not use the [LocalsHandler.readThis()] since that could
338 // point to a captured this which would be stored in a closure-field 339 // point to a captured this which would be stored in a closure-field
339 // itself. 340 // itself.
340 HInstruction receiver = new HThis(); 341 HInstruction receiver = new HThis();
341 builder.add(receiver); 342 builder.add(receiver);
342 HInstruction fieldGet = new HFieldGet(redirect, receiver); 343 HInstruction fieldGet = new HFieldGet(redirect, receiver);
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 } else { 2062 } else {
2062 breakInstruction = new HBreak(node.target.source); 2063 breakInstruction = new HBreak(node.target.source);
2063 } 2064 }
2064 close(breakInstruction); 2065 close(breakInstruction);
2065 handler.addBreak(breakInstruction, savedLocals); 2066 handler.addBreak(breakInstruction, savedLocals);
2066 } 2067 }
2067 2068
2068 visitContinueStatement(ContinueStatement node) { 2069 visitContinueStatement(ContinueStatement node) {
2069 // TODO(lrn): Replace this with a real implementation of continue. 2070 // TODO(lrn): Replace this with a real implementation of continue.
2070 compiler.reportWarning(node, 'continue not implemented'); 2071 compiler.reportWarning(node, 'continue not implemented');
2071 DartString string = new DartString.literal('continue not implemented'); 2072 generateUnimplemented('continue not implemented');
2072 HInstruction message = graph.addNewLiteralString(string);
2073 close(new HThrow(message));
2074 } 2073 }
2075 2074
2076 BreakHandler getLoopBreakHandler(Loop node) { 2075 BreakHandler getLoopBreakHandler(Loop node) {
2077 StatementElement element = elements[node]; 2076 StatementElement element = elements[node];
2078 BreakHandler handler; 2077 BreakHandler handler;
2079 if (loopBreakHandler === null) { 2078 if (loopBreakHandler === null) {
2080 if (element === null) return const NullBreakHandler(); 2079 if (element === null) return const NullBreakHandler();
2081 handler = new BreakHandler(this, element); 2080 handler = new BreakHandler(this, element);
2082 } else { 2081 } else {
2083 handler = loopBreakHandler; 2082 handler = loopBreakHandler;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 // Mark both entry and exit with the information. You can 2211 // Mark both entry and exit with the information. You can
2213 // tell which one is which by comparing with blockInfo.start/end. 2212 // tell which one is which by comparing with blockInfo.start/end.
2214 // It doesn't matter which merge block we use, they won't be generating 2213 // It doesn't matter which merge block we use, they won't be generating
2215 // any code, so put the end-marker on the last join block. 2214 // any code, so put the end-marker on the last join block.
2216 entryBlock.labeledBlockInformation = blockInfo; 2215 entryBlock.labeledBlockInformation = blockInfo;
2217 current.labeledBlockInformation = blockInfo; 2216 current.labeledBlockInformation = blockInfo;
2218 } 2217 }
2219 } 2218 }
2220 2219
2221 visitLiteralMap(LiteralMap node) { 2220 visitLiteralMap(LiteralMap node) {
2222 compiler.unimplemented('SsaBuilder.visitLiteralMap', node: node); 2221 generateUnimplemented('literal map not implemented', isExpression: true);
2223 } 2222 }
2224 2223
2225 visitLiteralMapEntry(LiteralMapEntry node) { 2224 visitLiteralMapEntry(LiteralMapEntry node) {
2226 compiler.unimplemented('SsaBuilder.visitLiteralMapEntry', node: node); 2225 compiler.unimplemented('SsaBuilder.visitLiteralMapEntry', node: node);
2227 } 2226 }
2228 2227
2229 visitNamedArgument(NamedArgument node) { 2228 visitNamedArgument(NamedArgument node) {
2230 visit(node.expression); 2229 visit(node.expression);
2231 } 2230 }
2232 2231
2233 visitSwitchStatement(SwitchStatement node) { 2232 visitSwitchStatement(SwitchStatement node) {
2234 compiler.unimplemented('SsaBuilder.visitSwitchStatement', node: node); 2233 generateUnimplemented('switch statement not implemented');
2235 } 2234 }
2236 2235
2237 visitTryStatement(TryStatement node) { 2236 visitTryStatement(TryStatement node) {
2238 work.allowSpeculativeOptimization = false; 2237 work.allowSpeculativeOptimization = false;
2239 assert(!work.isBailoutVersion()); 2238 assert(!work.isBailoutVersion());
2240 HBasicBlock enterBlock = graph.addNewBlock(); 2239 HBasicBlock enterBlock = graph.addNewBlock();
2241 close(new HGoto()).addSuccessor(enterBlock); 2240 close(new HGoto()).addSuccessor(enterBlock);
2242 open(enterBlock); 2241 open(enterBlock);
2243 HTry tryInstruction = new HTry(); 2242 HTry tryInstruction = new HTry();
2244 List<HBasicBlock> blocks = <HBasicBlock>[]; 2243 List<HBasicBlock> blocks = <HBasicBlock>[];
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 compiler.unimplemented('SsaBuilder.visitScriptTag', node: node); 2333 compiler.unimplemented('SsaBuilder.visitScriptTag', node: node);
2335 } 2334 }
2336 2335
2337 visitCatchBlock(CatchBlock node) { 2336 visitCatchBlock(CatchBlock node) {
2338 visit(node.block); 2337 visit(node.block);
2339 } 2338 }
2340 2339
2341 visitTypedef(Typedef node) { 2340 visitTypedef(Typedef node) {
2342 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); 2341 compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
2343 } 2342 }
2343
2344 generateUnimplemented(String reason, [bool isExpression = false]) {
2345 DartString string = new DartString.literal(reason);
2346 HInstruction message = graph.addNewLiteralString(string);
2347
2348 // Normally, we would call [close] here. However, then we hit
2349 // another unimplemented feature: aborting loop body. Simply
2350 // calling [add] does not work as it asserts that the instruction
2351 // isn't a control flow instruction. So we inline parts of [add].
2352 current.addAfter(current.last, new HThrow(message));
2353 if (isExpression) {
2354 stack.add(graph.addNewLiteralNull());
2355 }
2356 }
2344 } 2357 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698