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

Side by Side Diff: pkg/kernel/lib/analyzer/loader.dart

Issue 2614663007: Revert "Non-format-changing kernel offset changes" (Closed)
Patch Set: Created 3 years, 11 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/kernel/lib/analyzer/ast_from_analyzer.dart ('k') | pkg/kernel/lib/ast.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.analyzer.loader; 4 library kernel.analyzer.loader;
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 /// Returns the IR for a class, at a temporary loading level. 261 /// Returns the IR for a class, at a temporary loading level.
262 /// 262 ///
263 /// The returned class has the correct name, flags, type parameter arity, 263 /// The returned class has the correct name, flags, type parameter arity,
264 /// and enclosing library. 264 /// and enclosing library.
265 ast.Class getClassReference(ClassElement element) { 265 ast.Class getClassReference(ClassElement element) {
266 var classNode = _classes[element]; 266 var classNode = _classes[element];
267 if (classNode != null) return classNode; 267 if (classNode != null) return classNode;
268 _classes[element] = classNode = new ast.Class( 268 _classes[element] = classNode = new ast.Class(
269 name: element.name, 269 name: element.name,
270 isAbstract: element.isAbstract, 270 isAbstract: element.isAbstract,
271 fileUri: '${element.source.uri}')..fileOffset = element.nameOffset; 271 fileUri: '${element.source.uri}');
272 classNode.level = ast.ClassLevel.Temporary; 272 classNode.level = ast.ClassLevel.Temporary;
273 var library = getLibraryReference(element.library); 273 var library = getLibraryReference(element.library);
274 library.addClass(classNode); 274 library.addClass(classNode);
275 // Initialize type parameter list without bounds. 275 // Initialize type parameter list without bounds.
276 for (var parameter in element.typeParameters) { 276 for (var parameter in element.typeParameters) {
277 var parameterNode = new ast.TypeParameter(parameter.name); 277 var parameterNode = new ast.TypeParameter(parameter.name);
278 _classTypeParameters[parameter] = parameterNode; 278 _classTypeParameters[parameter] = parameterNode;
279 classNode.typeParameters.add(parameterNode); 279 classNode.typeParameters.add(parameterNode);
280 parameterNode.parent = classNode; 280 parameterNode.parent = classNode;
281 } 281 }
(...skipping 29 matching lines...) Expand all
311 if (element.supertype != null) { 311 if (element.supertype != null) {
312 ast.Supertype supertype = scope.buildSupertype(element.supertype); 312 ast.Supertype supertype = scope.buildSupertype(element.supertype);
313 bool useSharedMixin = true; 313 bool useSharedMixin = true;
314 for (var mixin in mixins) { 314 for (var mixin in mixins) {
315 var mixinType = scope.buildSupertype(mixin); 315 var mixinType = scope.buildSupertype(mixin);
316 if (useSharedMixin && 316 if (useSharedMixin &&
317 areDistinctUnboundTypeVariables(supertype, mixinType)) { 317 areDistinctUnboundTypeVariables(supertype, mixinType)) {
318 // Use a shared mixin application class for this library. 318 // Use a shared mixin application class for this library.
319 var mixinClass = getSharedMixinApplicationClass( 319 var mixinClass = getSharedMixinApplicationClass(
320 scope.currentLibrary, supertype.classNode, mixinType.classNode); 320 scope.currentLibrary, supertype.classNode, mixinType.classNode);
321 if (mixinClass.fileOffset < 0) {
322 mixinClass.fileOffset = element.nameOffset;
323 }
324 supertype = new ast.Supertype( 321 supertype = new ast.Supertype(
325 mixinClass, 322 mixinClass,
326 supertype.typeArguments.length > mixinType.typeArguments.length 323 supertype.typeArguments.length > mixinType.typeArguments.length
327 ? supertype.typeArguments 324 ? supertype.typeArguments
328 : mixinType.typeArguments); 325 : mixinType.typeArguments);
329 } else { 326 } else {
330 // Generate a new class specific for this mixin application. 327 // Generate a new class specific for this mixin application.
331 var freshParameters = 328 var freshParameters =
332 getFreshTypeParameters(classNode.typeParameters); 329 getFreshTypeParameters(classNode.typeParameters);
333 var mixinClass = new ast.Class( 330 var mixinClass = new ast.Class(
334 name: '${classNode.name}^${mixinType.classNode.name}', 331 name: '${classNode.name}^${mixinType.classNode.name}',
335 isAbstract: true, 332 isAbstract: true,
336 typeParameters: freshParameters.freshTypeParameters, 333 typeParameters: freshParameters.freshTypeParameters,
337 supertype: freshParameters.substituteSuper(supertype), 334 supertype: freshParameters.substituteSuper(supertype),
338 mixedInType: freshParameters.substituteSuper(mixinType), 335 mixedInType: freshParameters.substituteSuper(mixinType),
339 fileUri: classNode.fileUri)..fileOffset = element.nameOffset; 336 fileUri: classNode.fileUri);
340 mixinClass.level = ast.ClassLevel.Type; 337 mixinClass.level = ast.ClassLevel.Type;
341 supertype = new ast.Supertype(mixinClass, 338 supertype = new ast.Supertype(mixinClass,
342 classNode.typeParameters.map(makeTypeParameterType).toList()); 339 classNode.typeParameters.map(makeTypeParameterType).toList());
343 addMixinClassToLibrary(mixinClass, classNode.enclosingLibrary); 340 addMixinClassToLibrary(mixinClass, classNode.enclosingLibrary);
344 // This class cannot be used from anywhere else, so don't try to 341 // This class cannot be used from anywhere else, so don't try to
345 // generate shared mixin applications using it. 342 // generate shared mixin applications using it.
346 useSharedMixin = false; 343 useSharedMixin = false;
347 } 344 }
348 } 345 }
349 classNode.supertype = supertype; 346 classNode.supertype = supertype;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 ConstructorElement constructor = element; 439 ConstructorElement constructor = element;
443 if (constructor.isFactory) { 440 if (constructor.isFactory) {
444 return new ast.Procedure( 441 return new ast.Procedure(
445 _nameOfMember(constructor), 442 _nameOfMember(constructor),
446 ast.ProcedureKind.Factory, 443 ast.ProcedureKind.Factory,
447 scope.buildFunctionInterface(constructor), 444 scope.buildFunctionInterface(constructor),
448 isAbstract: false, 445 isAbstract: false,
449 isStatic: true, 446 isStatic: true,
450 isExternal: constructor.isExternal, 447 isExternal: constructor.isExternal,
451 isConst: constructor.isConst, 448 isConst: constructor.isConst,
452 fileUri: '${element.source.uri}') 449 fileUri: '${element.source.uri}');
453 ..fileOffset = element.nameOffset;
454 } 450 }
455 return new ast.Constructor(scope.buildFunctionInterface(constructor), 451 return new ast.Constructor(scope.buildFunctionInterface(constructor),
456 name: _nameOfMember(element), 452 name: _nameOfMember(element),
457 isConst: constructor.isConst, 453 isConst: constructor.isConst,
458 isExternal: constructor.isExternal) 454 isExternal: constructor.isExternal);
459 ..fileOffset = element.nameOffset;
460 455
461 case ElementKind.FIELD: 456 case ElementKind.FIELD:
462 case ElementKind.TOP_LEVEL_VARIABLE: 457 case ElementKind.TOP_LEVEL_VARIABLE:
463 VariableElement variable = element; 458 VariableElement variable = element;
464 return new ast.Field(_nameOfMember(variable), 459 return new ast.Field(_nameOfMember(variable),
465 isStatic: variable.isStatic, 460 isStatic: variable.isStatic,
466 isFinal: variable.isFinal, 461 isFinal: variable.isFinal,
467 isConst: variable.isConst, 462 isConst: variable.isConst,
468 type: scope.buildType(variable.type), 463 type: scope.buildType(variable.type),
469 fileUri: '${element.source.uri}')..fileOffset = element.nameOffset; 464 fileUri: '${element.source.uri}')..fileOffset = element.nameOffset;
470 465
471 case ElementKind.METHOD: 466 case ElementKind.METHOD:
472 case ElementKind.GETTER: 467 case ElementKind.GETTER:
473 case ElementKind.SETTER: 468 case ElementKind.SETTER:
474 case ElementKind.FUNCTION: 469 case ElementKind.FUNCTION:
475 if (element is FunctionElement && 470 if (element is FunctionElement &&
476 element.enclosingElement is! CompilationUnitElement) { 471 element.enclosingElement is! CompilationUnitElement) {
477 throw 'Function $element is nested in ${element.enclosingElement} ' 472 throw 'Function $element is nested in ${element.enclosingElement} '
478 'and hence is not a member'; 473 'and hence is not a member';
479 } 474 }
480 ExecutableElement executable = element; 475 ExecutableElement executable = element;
481 return new ast.Procedure( 476 return new ast.Procedure(
482 _nameOfMember(element), 477 _nameOfMember(element),
483 _procedureKindOf(executable), 478 _procedureKindOf(executable),
484 scope.buildFunctionInterface(executable), 479 scope.buildFunctionInterface(executable),
485 isAbstract: executable.isAbstract, 480 isAbstract: executable.isAbstract,
486 isStatic: executable.isStatic, 481 isStatic: executable.isStatic,
487 isExternal: executable.isExternal, 482 isExternal: executable.isExternal,
488 fileUri: '${element.source.uri}')..fileOffset = element.nameOffset; 483 fileUri: '${element.source.uri}');
489 484
490 default: 485 default:
491 throw 'Unexpected member kind: $element'; 486 throw 'Unexpected member kind: $element';
492 } 487 }
493 } 488 }
494 489
495 ast.ProcedureKind _procedureKindOf(ExecutableElement element) { 490 ast.ProcedureKind _procedureKindOf(ExecutableElement element) {
496 if (element is PropertyAccessorElement) { 491 if (element is PropertyAccessorElement) {
497 return element.isGetter 492 return element.isGetter
498 ? ast.ProcedureKind.Getter 493 ? ast.ProcedureKind.Getter
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() 862 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext()
868 ..sourceFactory = new SourceFactory(resolvers) 863 ..sourceFactory = new SourceFactory(resolvers)
869 ..analysisOptions = createAnalysisOptions(options.strongMode); 864 ..analysisOptions = createAnalysisOptions(options.strongMode);
870 865
871 options.declaredVariables.forEach((String name, String value) { 866 options.declaredVariables.forEach((String name, String value) {
872 context.declaredVariables.define(name, value); 867 context.declaredVariables.define(name, value);
873 }); 868 });
874 869
875 return context; 870 return context;
876 } 871 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/analyzer/ast_from_analyzer.dart ('k') | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698