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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1135883004: Make typedefs lazy again (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dev_compiler.src.codegen.js_codegen; 5 library dev_compiler.src.codegen.js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap; 7 import 'dart:collection' show HashSet, HashMap;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return null; 275 return null;
276 } 276 }
277 277
278 @override 278 @override
279 visitFunctionTypeAlias(FunctionTypeAlias node) { 279 visitFunctionTypeAlias(FunctionTypeAlias node) {
280 // If we've already emitted this class, skip it. 280 // If we've already emitted this class, skip it.
281 var element = node.element; 281 var element = node.element;
282 var type = element.type; 282 var type = element.type;
283 var name = element.name; 283 var name = element.name;
284 284
285 _loader.startTopLevel(element); 285 var fnType = js.statement('let # = dart.typedef(#, () => #);', [
286 var fnType = js.statement('let # = dart.typedef(#, #);', [
287 name, 286 name,
288 js.string(name, "'"), 287 js.string(name, "'"),
289 _emitTypeName(type, lowerTypedef: true) 288 _emitTypeName(type, lowerTypedef: true)
290 ]); 289 ]);
291 _loader.finishTopLevel(element);
292 290
293 return _finishClassDef(type, fnType); 291 return _finishClassDef(type, fnType);
294 } 292 }
295 293
296 @override 294 @override
297 JS.Expression visitTypeName(TypeName node) => _emitTypeName(node.type); 295 JS.Expression visitTypeName(TypeName node) => _emitTypeName(node.type);
298 296
299 @override 297 @override
300 JS.Statement visitClassTypeAlias(ClassTypeAlias node) { 298 JS.Statement visitClassTypeAlias(ClassTypeAlias node) {
301 // If we've already emitted this class, skip it. 299 // If we've already emitted this class, skip it.
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 2475
2478 /// A special kind of element created by the compiler, signifying a temporary 2476 /// A special kind of element created by the compiler, signifying a temporary
2479 /// variable. These objects use instance equality, and should be shared 2477 /// variable. These objects use instance equality, and should be shared
2480 /// everywhere in the tree where they are treated as the same variable. 2478 /// everywhere in the tree where they are treated as the same variable.
2481 class TemporaryVariableElement extends LocalVariableElementImpl { 2479 class TemporaryVariableElement extends LocalVariableElementImpl {
2482 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 2480 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
2483 2481
2484 int get hashCode => identityHashCode(this); 2482 int get hashCode => identityHashCode(this);
2485 bool operator ==(Object other) => identical(this, other); 2483 bool operator ==(Object other) => identical(this, other);
2486 } 2484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698