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

Side by Side Diff: lib/src/utils.dart

Issue 1142713004: fixes #184, type literals now use emitTypeName (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: another case 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
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/misc.js » ('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 // 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 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 library dev_compiler.src.utils; 6 library dev_compiler.src.utils;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 /// value of that field. 368 /// value of that field.
369 /// 369 ///
370 /// If the field is missing or is not [expectedType], returns null. 370 /// If the field is missing or is not [expectedType], returns null.
371 Object getConstantField( 371 Object getConstantField(
372 DartObjectImpl value, String fieldName, DartType expectedType) { 372 DartObjectImpl value, String fieldName, DartType expectedType) {
373 if (value == null) return null; 373 if (value == null) return null;
374 var f = value.fields[fieldName]; 374 var f = value.fields[fieldName];
375 return (f == null || f.type != expectedType) ? null : f.value; 375 return (f == null || f.type != expectedType) ? null : f.value;
376 } 376 }
377 377
378 ParameterizedType fillDynamicTypeArgs(ParameterizedType t, TypeProvider types) { 378 DartType fillDynamicTypeArgs(DartType t, TypeProvider types) {
379 var dyn = new List.filled(t.typeArguments.length, types.dynamicType); 379 if (t is ParameterizedType) {
380 return t.substitute2(dyn, t.typeArguments); 380 var dyn = new List.filled(t.typeArguments.length, types.dynamicType);
381 return t.substitute2(dyn, t.typeArguments);
382 }
383 return t;
381 } 384 }
382 385
383 /// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and 386 /// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and
384 /// inDeclarationContext, this method returns true if [node] is used in an 387 /// inDeclarationContext, this method returns true if [node] is used in an
385 /// invocation context such as a MethodInvocation. 388 /// invocation context such as a MethodInvocation.
386 bool inInvocationContext(SimpleIdentifier node) { 389 bool inInvocationContext(SimpleIdentifier node) {
387 var parent = node.parent; 390 var parent = node.parent;
388 return parent is MethodInvocation && parent.methodName == node; 391 return parent is MethodInvocation && parent.methodName == node;
389 } 392 }
390 393
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 int lineEnd = endLoc.offset; 453 int lineEnd = endLoc.offset;
451 int unitEnd = unit.endToken.end; 454 int unitEnd = unit.endToken.end;
452 int lineNum = lineInfo.getLocation(lineEnd).lineNumber; 455 int lineNum = lineInfo.getLocation(lineEnd).lineNumber;
453 while (lineEnd < unitEnd && 456 while (lineEnd < unitEnd &&
454 lineInfo.getLocation(++lineEnd).lineNumber == lineNum); 457 lineInfo.getLocation(++lineEnd).lineNumber == lineNum);
455 458
456 var text = content.substring(start, end); 459 var text = content.substring(start, end);
457 var lineText = content.substring(lineStart, lineEnd); 460 var lineText = content.substring(lineStart, lineEnd);
458 return new SourceSpanWithContext(startLoc, endLoc, text, lineText); 461 return new SourceSpanWithContext(startLoc, endLoc, text, lineText);
459 } 462 }
OLDNEW
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/misc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698