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

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

Issue 2830503002: Run formatter on dev_compiler. (Closed)
Patch Set: Run formatter on dev_compiler. Created 3 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
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/global_compile.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 null, 247 null,
248 sdk is SummaryBasedDartSdk 248 sdk is SummaryBasedDartSdk
249 ? sdk.bundle 249 ? sdk.bundle
250 : (sdk as FolderBasedDartSdk).getSummarySdkBundle(true)); 250 : (sdk as FolderBasedDartSdk).getSummarySdkBundle(true));
251 } 251 }
252 252
253 var assembler = new PackageBundleAssembler(); 253 var assembler = new PackageBundleAssembler();
254 assembler.recordDependencies(summaryData); 254 assembler.recordDependencies(summaryData);
255 255
256 var uriToUnit = new Map<String, UnlinkedUnit>.fromIterable(units, 256 var uriToUnit = new Map<String, UnlinkedUnit>.fromIterable(units,
257 key: (u) => u.element.source.uri.toString(), value: (unit) { 257 key: (u) => u.element.source.uri.toString(),
258 var unlinked = serializeAstUnlinked(unit); 258 value: (unit) {
259 assembler.addUnlinkedUnit(unit.element.source, unlinked); 259 var unlinked = serializeAstUnlinked(unit);
260 return unlinked; 260 assembler.addUnlinkedUnit(unit.element.source, unlinked);
261 }); 261 return unlinked;
262 });
262 263
263 summary_link 264 summary_link
264 .link( 265 .link(
265 uriToUnit.keys.toSet(), 266 uriToUnit.keys.toSet(),
266 (uri) => summaryData.linkedMap[uri], 267 (uri) => summaryData.linkedMap[uri],
267 (uri) => summaryData.unlinkedMap[uri] ?? uriToUnit[uri], 268 (uri) => summaryData.unlinkedMap[uri] ?? uriToUnit[uri],
268 context.declaredVariables.get, 269 context.declaredVariables.get,
269 true) 270 true)
270 .forEach(assembler.addLinkedLibrary); 271 .forEach(assembler.addLinkedLibrary);
271 272
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 [jsParams, _constructorName(parentCtor), jsParams]) as JS.Fun; 813 [jsParams, _constructorName(parentCtor), jsParams]) as JS.Fun;
813 methods.add(new JS.Method(_constructorName(ctor), fun)); 814 methods.add(new JS.Method(_constructorName(ctor), fun));
814 } 815 }
815 } 816 }
816 817
817 var typeFormals = element.typeParameters; 818 var typeFormals = element.typeParameters;
818 var isGeneric = typeFormals.isNotEmpty; 819 var isGeneric = typeFormals.isNotEmpty;
819 var className = isGeneric ? element.name : _emitTopLevelName(element); 820 var className = isGeneric ? element.name : _emitTopLevelName(element);
820 JS.Statement declareInterfaces(JS.Statement decl) { 821 JS.Statement declareInterfaces(JS.Statement decl) {
821 if (element.interfaces.isNotEmpty) { 822 if (element.interfaces.isNotEmpty) {
822 var body = [decl] 823 var body = [decl]..add(js.statement('#[#.implements] = () => #;', [
823 ..add(js.statement('#[#.implements] = () => #;', [
824 className, 824 className,
825 _runtimeModule, 825 _runtimeModule,
826 new JS.ArrayInitializer( 826 new JS.ArrayInitializer(
827 new List<JS.Expression>.from(element.interfaces.map(_emitType))) 827 new List<JS.Expression>.from(element.interfaces.map(_emitType)))
828 ])); 828 ]));
829 decl = _statement(body); 829 decl = _statement(body);
830 } 830 }
831 return decl; 831 return decl;
832 } 832 }
833 833
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 if (JS.Return.foundIn(fn)) { 2470 if (JS.Return.foundIn(fn)) {
2471 // If a return is inside body, transform `(params) { body }` to 2471 // If a return is inside body, transform `(params) { body }` to
2472 // `(params) { (() => { body })(); return value; }`. 2472 // `(params) { (() => { body })(); return value; }`.
2473 // TODO(jmesserly): we could instead generate the return differently, 2473 // TODO(jmesserly): we could instead generate the return differently,
2474 // and avoid the immediately invoked function. 2474 // and avoid the immediately invoked function.
2475 body = new JS.Call(new JS.ArrowFun([], fn.body), []).toStatement(); 2475 body = new JS.Call(new JS.ArrowFun([], fn.body), []).toStatement();
2476 } 2476 }
2477 // Rewrite the function to include the return. 2477 // Rewrite the function to include the return.
2478 return new JS.Fun( 2478 return new JS.Fun(
2479 fn.params, new JS.Block([body, new JS.Return(fn.params.last)]), 2479 fn.params, new JS.Block([body, new JS.Return(fn.params.last)]),
2480 typeParams: fn.typeParams, 2480 typeParams: fn.typeParams, returnType: fn.returnType)
2481 returnType: fn.returnType)..sourceInformation = fn.sourceInformation; 2481 ..sourceInformation = fn.sourceInformation;
2482 } 2482 }
2483 2483
2484 @override 2484 @override
2485 JS.Statement visitFunctionDeclaration(FunctionDeclaration node) { 2485 JS.Statement visitFunctionDeclaration(FunctionDeclaration node) {
2486 assert(node.parent is CompilationUnit); 2486 assert(node.parent is CompilationUnit);
2487 2487
2488 if (_externalOrNative(node)) return null; 2488 if (_externalOrNative(node)) return null;
2489 2489
2490 if (node.isGetter || node.isSetter) { 2490 if (node.isGetter || node.isSetter) {
2491 PropertyAccessorElement element = node.element; 2491 PropertyAccessorElement element = node.element;
(...skipping 3626 matching lines...) Expand 10 before | Expand all | Expand 10 after
6118 if (targetIdentifier.staticElement is! PrefixElement) return false; 6118 if (targetIdentifier.staticElement is! PrefixElement) return false;
6119 var prefix = targetIdentifier.staticElement as PrefixElement; 6119 var prefix = targetIdentifier.staticElement as PrefixElement;
6120 6120
6121 // The library the prefix is referring to must come from a deferred import. 6121 // The library the prefix is referring to must come from a deferred import.
6122 var containingLibrary = resolutionMap 6122 var containingLibrary = resolutionMap
6123 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 6123 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
6124 .library; 6124 .library;
6125 var imports = containingLibrary.getImportsWithPrefix(prefix); 6125 var imports = containingLibrary.getImportsWithPrefix(prefix);
6126 return imports.length == 1 && imports[0].isDeferred; 6126 return imports.length == 1 && imports[0].isDeferred;
6127 } 6127 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/global_compile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698