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

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

Issue 2537303004: Disallow `null` in spanFromSpannable. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/library_loader.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 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'cache_strategy.dart' show CacheStrategy; 10 import 'cache_strategy.dart' show CacheStrategy;
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 1785
1786 SourceSpan spanFromHInstruction(HInstruction instruction) { 1786 SourceSpan spanFromHInstruction(HInstruction instruction) {
1787 Element element = _elementFromHInstruction(instruction); 1787 Element element = _elementFromHInstruction(instruction);
1788 if (element == null) element = currentElement; 1788 if (element == null) element = currentElement;
1789 SourceInformation position = instruction.sourceInformation; 1789 SourceInformation position = instruction.sourceInformation;
1790 if (position == null) return spanFromElement(element); 1790 if (position == null) return spanFromElement(element);
1791 return position.sourceSpan; 1791 return position.sourceSpan;
1792 } 1792 }
1793 1793
1794 SourceSpan spanFromSpannable(Spannable node) { 1794 SourceSpan spanFromSpannable(Spannable node) {
1795 // TODO(johnniwinther): Disallow `node == null` ?
1796 if (node == null) return null;
1797 if (node == CURRENT_ELEMENT_SPANNABLE) { 1795 if (node == CURRENT_ELEMENT_SPANNABLE) {
1798 node = currentElement; 1796 node = currentElement;
1799 } else if (node == NO_LOCATION_SPANNABLE) { 1797 } else if (node == NO_LOCATION_SPANNABLE) {
1800 if (currentElement == null) return null; 1798 if (currentElement == null) return null;
1801 node = currentElement; 1799 node = currentElement;
1802 } 1800 }
1803 if (node is SourceSpan) { 1801 if (node is SourceSpan) {
1804 return node; 1802 return node;
1805 } else if (node is Node) { 1803 } else if (node is Node) {
1806 return spanFromNode(node); 1804 return spanFromNode(node);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 _ElementScanner(this.scanner); 2248 _ElementScanner(this.scanner);
2251 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2249 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2252 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2250 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2253 } 2251 }
2254 2252
2255 class _EmptyEnvironment implements Environment { 2253 class _EmptyEnvironment implements Environment {
2256 const _EmptyEnvironment(); 2254 const _EmptyEnvironment();
2257 2255
2258 String valueOf(String key) => null; 2256 String valueOf(String key) => null;
2259 } 2257 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/library_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698