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

Side by Side Diff: pkg/kernel/lib/analyzer/ast_from_analyzer.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/bin/dartk.dart ('k') | pkg/kernel/lib/analyzer/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) 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.ast_from_analyzer; 4 library kernel.analyzer.ast_from_analyzer;
5 5
6 import '../ast.dart' as ast; 6 import '../ast.dart' as ast;
7 import '../frontend/accessors.dart'; 7 import '../frontend/accessors.dart';
8 import '../frontend/super_initializers.dart'; 8 import '../frontend/super_initializers.dart';
9 import '../log.dart'; 9 import '../log.dart';
10 import '../type_algebra.dart'; 10 import '../type_algebra.dart';
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 465 }
466 } 466 }
467 var returnType = element is ConstructorElement 467 var returnType = element is ConstructorElement
468 ? const ast.VoidType() 468 ? const ast.VoidType()
469 : buildType(element.returnType); 469 : buildType(element.returnType);
470 return new ast.FunctionNode(null, 470 return new ast.FunctionNode(null,
471 typeParameters: typeParameters, 471 typeParameters: typeParameters,
472 positionalParameters: positional, 472 positionalParameters: positional,
473 namedParameters: named, 473 namedParameters: named,
474 requiredParameterCount: requiredParameterCount, 474 requiredParameterCount: requiredParameterCount,
475 returnType: returnType)..fileOffset = element.nameOffset; 475 returnType: returnType);
476 } 476 }
477 } 477 }
478 478
479 class ExpressionScope extends TypeScope { 479 class ExpressionScope extends TypeScope {
480 ast.Library currentLibrary; 480 ast.Library currentLibrary;
481 final Map<LocalElement, ast.VariableDeclaration> localVariables = 481 final Map<LocalElement, ast.VariableDeclaration> localVariables =
482 <LocalElement, ast.VariableDeclaration>{}; 482 <LocalElement, ast.VariableDeclaration>{};
483 483
484 ExpressionBuilder _expressionBuilder; 484 ExpressionBuilder _expressionBuilder;
485 StatementBuilder _statementBuilder; 485 StatementBuilder _statementBuilder;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 559
560 case ParameterKind.POSITIONAL: 560 case ParameterKind.POSITIONAL:
561 positional.add(declaration); 561 positional.add(declaration);
562 break; 562 break;
563 563
564 case ParameterKind.NAMED: 564 case ParameterKind.NAMED:
565 named.add(declaration); 565 named.add(declaration);
566 break; 566 break;
567 } 567 }
568 } 568 }
569 int offset = formalParameters?.offset ?? body.offset;
570 int endOffset = body.endToken.offset;
571 return new ast.FunctionNode(buildOptionalFunctionBody(body), 569 return new ast.FunctionNode(buildOptionalFunctionBody(body),
572 typeParameters: typeParameters, 570 typeParameters: typeParameters,
573 positionalParameters: positional, 571 positionalParameters: positional,
574 namedParameters: named, 572 namedParameters: named,
575 requiredParameterCount: requiredParameterCount, 573 requiredParameterCount: requiredParameterCount,
576 returnType: buildOptionalTypeAnnotation(returnType) ?? 574 returnType: buildOptionalTypeAnnotation(returnType) ??
577 inferredReturnType ?? 575 inferredReturnType ??
578 const ast.DynamicType(), 576 const ast.DynamicType(),
579 asyncMarker: getAsyncMarker( 577 asyncMarker: getAsyncMarker(
580 isAsync: body.isAsynchronous, isStar: body.isGenerator)) 578 isAsync: body.isAsynchronous, isStar: body.isGenerator));
581 ..fileOffset = offset
582 ..fileEndOffset = endOffset;
583 } 579 }
584 580
585 ast.Expression buildOptionalTopLevelExpression(Expression node) { 581 ast.Expression buildOptionalTopLevelExpression(Expression node) {
586 return node == null ? null : buildTopLevelExpression(node); 582 return node == null ? null : buildTopLevelExpression(node);
587 } 583 }
588 584
589 ast.Expression buildTopLevelExpression(Expression node) { 585 ast.Expression buildTopLevelExpression(Expression node) {
590 try { 586 try {
591 return _expressionBuilder.build(node); 587 return _expressionBuilder.build(node);
592 } on _CompilationError catch (e) { 588 } on _CompilationError catch (e) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 element is FunctionElement; 629 element is FunctionElement;
634 } 630 }
635 631
636 bool isConst(Element element) { 632 bool isConst(Element element) {
637 return element is VariableElement && element.isConst; 633 return element is VariableElement && element.isConst;
638 } 634 }
639 635
640 ast.VariableDeclaration getVariableReference(LocalElement element) { 636 ast.VariableDeclaration getVariableReference(LocalElement element) {
641 return localVariables.putIfAbsent(element, () { 637 return localVariables.putIfAbsent(element, () {
642 return new ast.VariableDeclaration(element.name, 638 return new ast.VariableDeclaration(element.name,
643 isFinal: isFinal(element), 639 isFinal: isFinal(element), isConst: isConst(element));
644 isConst: isConst(element))..fileOffset = element.nameOffset;
645 }); 640 });
646 } 641 }
647 642
648 ast.DartType getInferredVariableType(Element element) { 643 ast.DartType getInferredVariableType(Element element) {
649 if (!strongMode) return const ast.DynamicType(); 644 if (!strongMode) return const ast.DynamicType();
650 if (element is FunctionTypedElement) { 645 if (element is FunctionTypedElement) {
651 return buildType(element.type); 646 return buildType(element.type);
652 } else if (element is VariableElement) { 647 } else if (element is VariableElement) {
653 return buildType(element.type); 648 return buildType(element.type);
654 } else { 649 } else {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 LabelStack.many(this.labels, this.next); 893 LabelStack.many(this.labels, this.next);
899 } 894 }
900 895
901 class StatementBuilder extends GeneralizingAstVisitor<ast.Statement> { 896 class StatementBuilder extends GeneralizingAstVisitor<ast.Statement> {
902 final ExpressionScope scope; 897 final ExpressionScope scope;
903 LabelStack breakStack, continueStack; 898 LabelStack breakStack, continueStack;
904 899
905 StatementBuilder(this.scope, [this.breakStack, this.continueStack]); 900 StatementBuilder(this.scope, [this.breakStack, this.continueStack]);
906 901
907 ast.Statement build(Statement node) { 902 ast.Statement build(Statement node) {
908 ast.Statement result = node.accept(this); 903 return node.accept(this);
909 result.fileOffset = _getOffset(node);
910 return result;
911 } 904 }
912 905
913 ast.Statement buildOptional(Statement node) { 906 ast.Statement buildOptional(Statement node) {
914 ast.Statement result = node?.accept(this); 907 return node?.accept(this);
915 result?.fileOffset = _getOffset(node);
916 return result;
917 }
918
919 int _getOffset(AstNode node) {
920 return node.offset;
921 } 908 }
922 909
923 ast.Statement buildInScope( 910 ast.Statement buildInScope(
924 Statement node, LabelStack breakNode, LabelStack continueNode) { 911 Statement node, LabelStack breakNode, LabelStack continueNode) {
925 var oldBreak = this.breakStack; 912 var oldBreak = this.breakStack;
926 var oldContinue = this.continueStack; 913 var oldContinue = this.continueStack;
927 breakStack = breakNode; 914 breakStack = breakNode;
928 continueStack = continueNode; 915 continueStack = continueNode;
929 var result = build(node); 916 var result = build(node);
930 this.breakStack = oldBreak; 917 this.breakStack = oldBreak;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 var declaration = node.functionDeclaration; 1279 var declaration = node.functionDeclaration;
1293 var expression = declaration.functionExpression; 1280 var expression = declaration.functionExpression;
1294 LocalElement element = declaration.element as dynamic; // Cross cast. 1281 LocalElement element = declaration.element as dynamic; // Cross cast.
1295 // TODO: Set a function type on the variable. 1282 // TODO: Set a function type on the variable.
1296 return new ast.FunctionDeclaration( 1283 return new ast.FunctionDeclaration(
1297 scope.makeVariableDeclaration(element), 1284 scope.makeVariableDeclaration(element),
1298 scope.buildFunctionNode(expression.parameters, expression.body, 1285 scope.buildFunctionNode(expression.parameters, expression.body,
1299 typeParameters: scope.buildOptionalTypeParameterList( 1286 typeParameters: scope.buildOptionalTypeParameterList(
1300 expression.typeParameters, 1287 expression.typeParameters,
1301 strongModeOnly: true), 1288 strongModeOnly: true),
1302 returnType: declaration.returnType))..fileOffset = node.offset; 1289 returnType: declaration.returnType));
1303 } 1290 }
1304 1291
1305 @override 1292 @override
1306 visitStatement(Statement node) { 1293 visitStatement(Statement node) {
1307 return scope.internalError('Unhandled statement ${node.runtimeType}'); 1294 return scope.internalError('Unhandled statement ${node.runtimeType}');
1308 } 1295 }
1309 } 1296 }
1310 1297
1311 class ExpressionBuilder 1298 class ExpressionBuilder
1312 extends GeneralizingAstVisitor /* <ast.Expression | Accessor> */ { 1299 extends GeneralizingAstVisitor /* <ast.Expression | Accessor> */ {
(...skipping 13 matching lines...) Expand all
1326 if (node is MethodInvocation) { 1313 if (node is MethodInvocation) {
1327 return node.methodName.offset; 1314 return node.methodName.offset;
1328 } else if (node is InstanceCreationExpression) { 1315 } else if (node is InstanceCreationExpression) {
1329 return node.constructorName.offset; 1316 return node.constructorName.offset;
1330 } else if (node is BinaryExpression) { 1317 } else if (node is BinaryExpression) {
1331 return node.operator.offset; 1318 return node.operator.offset;
1332 } else if (node is PrefixedIdentifier) { 1319 } else if (node is PrefixedIdentifier) {
1333 return node.identifier.offset; 1320 return node.identifier.offset;
1334 } else if (node is AssignmentExpression) { 1321 } else if (node is AssignmentExpression) {
1335 return _getOffset(node.leftHandSide); 1322 return _getOffset(node.leftHandSide);
1336 } else if (node is PropertyAccess) {
1337 return node.propertyName.offset;
1338 } else if (node is IsExpression) {
1339 return node.isOperator.offset;
1340 } else if (node is StringLiteral) {
1341 // Use a catch-all for StringInterpolation and AdjacentStrings:
1342 // the debugger stops at the end.
1343 return node.end;
1344 } 1323 }
1345 return node.offset; 1324 return node.offset;
1346 } 1325 }
1347 1326
1348 Accessor buildLeftHandValue(Expression node) { 1327 Accessor buildLeftHandValue(Expression node) {
1349 var result = node.accept(this); 1328 var result = node.accept(this);
1350 if (result is Accessor) { 1329 if (result is Accessor) {
1351 return result; 1330 return result;
1352 } else { 1331 } else {
1353 return new ReadOnlyAccessor(result); 1332 return new ReadOnlyAccessor(result);
(...skipping 12 matching lines...) Expand all
1366 var rightHand = build(node.rightHandSide); 1345 var rightHand = build(node.rightHandSide);
1367 if (operator == '=') { 1346 if (operator == '=') {
1368 return leftHand.buildAssignment(rightHand, voidContext: voidContext); 1347 return leftHand.buildAssignment(rightHand, voidContext: voidContext);
1369 } else if (operator == '??=') { 1348 } else if (operator == '??=') {
1370 return leftHand.buildNullAwareAssignment( 1349 return leftHand.buildNullAwareAssignment(
1371 rightHand, scope.buildType(node.staticType), 1350 rightHand, scope.buildType(node.staticType),
1372 voidContext: voidContext); 1351 voidContext: voidContext);
1373 } else { 1352 } else {
1374 // Cut off the trailing '='. 1353 // Cut off the trailing '='.
1375 var name = new ast.Name(operator.substring(0, operator.length - 1)); 1354 var name = new ast.Name(operator.substring(0, operator.length - 1));
1376 return leftHand.buildCompoundAssignment(name, rightHand, node.offset, 1355 return leftHand.buildCompoundAssignment(name, rightHand,
1377 voidContext: voidContext, 1356 voidContext: voidContext,
1378 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); 1357 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
1379 } 1358 }
1380 } 1359 }
1381 1360
1382 ast.Expression visitAwaitExpression(AwaitExpression node) { 1361 ast.Expression visitAwaitExpression(AwaitExpression node) {
1383 return new ast.AwaitExpression(build(node.expression)); 1362 return new ast.AwaitExpression(build(node.expression));
1384 } 1363 }
1385 1364
1386 ast.Arguments buildSingleArgument(Expression node) { 1365 ast.Arguments buildSingleArgument(Expression node) {
1387 return new ast.Arguments(<ast.Expression>[build(node)]); 1366 return new ast.Arguments(<ast.Expression>[build(node)]);
1388 } 1367 }
1389 1368
1390 ast.Expression visitBinaryExpression(BinaryExpression node) { 1369 ast.Expression visitBinaryExpression(BinaryExpression node) {
1391 String operator = node.operator.value(); 1370 String operator = node.operator.value();
1392 if (operator == '&&' || operator == '||') { 1371 if (operator == '&&' || operator == '||') {
1393 return new ast.LogicalExpression( 1372 return new ast.LogicalExpression(
1394 build(node.leftOperand), operator, build(node.rightOperand)); 1373 build(node.leftOperand), operator, build(node.rightOperand));
1395 } 1374 }
1396 if (operator == '??') { 1375 if (operator == '??') {
1397 ast.Expression leftOperand = build(node.leftOperand); 1376 ast.Expression leftOperand = build(node.leftOperand);
1398 if (leftOperand is ast.VariableGet) { 1377 if (leftOperand is ast.VariableGet) {
1399 return new ast.ConditionalExpression( 1378 return new ast.ConditionalExpression(
1400 buildIsNull(leftOperand, offset: node.leftOperand.offset), 1379 buildIsNull(leftOperand),
1401 build(node.rightOperand), 1380 build(node.rightOperand),
1402 new ast.VariableGet(leftOperand.variable), 1381 new ast.VariableGet(leftOperand.variable),
1403 scope.getInferredType(node)); 1382 scope.getInferredType(node));
1404 } else { 1383 } else {
1405 var variable = new ast.VariableDeclaration.forValue(leftOperand); 1384 var variable = new ast.VariableDeclaration.forValue(leftOperand);
1406 return new ast.Let( 1385 return new ast.Let(
1407 variable, 1386 variable,
1408 new ast.ConditionalExpression( 1387 new ast.ConditionalExpression(
1409 buildIsNull(new ast.VariableGet(variable), 1388 buildIsNull(new ast.VariableGet(variable)),
1410 offset: leftOperand.fileOffset),
1411 build(node.rightOperand), 1389 build(node.rightOperand),
1412 new ast.VariableGet(variable), 1390 new ast.VariableGet(variable),
1413 scope.getInferredType(node))); 1391 scope.getInferredType(node)));
1414 } 1392 }
1415 } 1393 }
1416 bool isNegated = false; 1394 bool isNegated = false;
1417 if (operator == '!=') { 1395 if (operator == '!=') {
1418 isNegated = true; 1396 isNegated = true;
1419 operator = '=='; 1397 operator = '==';
1420 } 1398 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 var receiver = makeOrReuseVariable(build(target)); 1887 var receiver = makeOrReuseVariable(build(target));
1910 return makeLet( 1888 return makeLet(
1911 receiver, 1889 receiver,
1912 new ast.ConditionalExpression( 1890 new ast.ConditionalExpression(
1913 buildIsNull(new ast.VariableGet(receiver)), 1891 buildIsNull(new ast.VariableGet(receiver)),
1914 new ast.NullLiteral(), 1892 new ast.NullLiteral(),
1915 buildDecomposableMethodInvocation( 1893 buildDecomposableMethodInvocation(
1916 new ast.VariableGet(receiver), 1894 new ast.VariableGet(receiver),
1917 scope.buildName(node.methodName), 1895 scope.buildName(node.methodName),
1918 buildArgumentsForInvocation(node), 1896 buildArgumentsForInvocation(node),
1919 element)..fileOffset = node.methodName.offset, 1897 element),
1920 scope.buildType(node.staticType))); 1898 scope.buildType(node.staticType)));
1921 } else { 1899 } else {
1922 return buildDecomposableMethodInvocation( 1900 return buildDecomposableMethodInvocation(
1923 build(node.target), 1901 build(node.target),
1924 scope.buildName(node.methodName), 1902 scope.buildName(node.methodName),
1925 buildArgumentsForInvocation(node), 1903 buildArgumentsForInvocation(node),
1926 element); 1904 element);
1927 } 1905 }
1928 } 1906 }
1929 1907
(...skipping 13 matching lines...) Expand all
1943 parent is ExpressionFunctionBody && scope.bodyHasVoidReturn(parent); 1921 parent is ExpressionFunctionBody && scope.bodyHasVoidReturn(parent);
1944 } 1922 }
1945 1923
1946 ast.Expression visitPostfixExpression(PostfixExpression node) { 1924 ast.Expression visitPostfixExpression(PostfixExpression node) {
1947 String operator = node.operator.value(); 1925 String operator = node.operator.value();
1948 switch (operator) { 1926 switch (operator) {
1949 case '++': 1927 case '++':
1950 case '--': 1928 case '--':
1951 var leftHand = buildLeftHandValue(node.operand); 1929 var leftHand = buildLeftHandValue(node.operand);
1952 var binaryOperator = new ast.Name(operator[0]); 1930 var binaryOperator = new ast.Name(operator[0]);
1953 return leftHand.buildPostfixIncrement(binaryOperator, node.offset, 1931 return leftHand.buildPostfixIncrement(binaryOperator,
1954 voidContext: isInVoidContext(node), 1932 voidContext: isInVoidContext(node),
1955 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); 1933 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
1956 1934
1957 default: 1935 default:
1958 return scope.internalError('Invalid postfix operator $operator'); 1936 return scope.internalError('Invalid postfix operator $operator');
1959 } 1937 }
1960 } 1938 }
1961 1939
1962 ast.Expression visitPrefixExpression(PrefixExpression node) { 1940 ast.Expression visitPrefixExpression(PrefixExpression node) {
1963 String operator = node.operator.value(); 1941 String operator = node.operator.value();
(...skipping 12 matching lines...) Expand all
1976 new ast.Arguments.empty(), 1954 new ast.Arguments.empty(),
1977 scope.resolveInterfaceMethod(node.staticElement)); 1955 scope.resolveInterfaceMethod(node.staticElement));
1978 1956
1979 case '!': 1957 case '!':
1980 return new ast.Not(build(node.operand)); 1958 return new ast.Not(build(node.operand));
1981 1959
1982 case '++': 1960 case '++':
1983 case '--': 1961 case '--':
1984 var leftHand = buildLeftHandValue(node.operand); 1962 var leftHand = buildLeftHandValue(node.operand);
1985 var binaryOperator = new ast.Name(operator[0]); 1963 var binaryOperator = new ast.Name(operator[0]);
1986 return leftHand.buildPrefixIncrement(binaryOperator, node.offset, 1964 return leftHand.buildPrefixIncrement(binaryOperator,
1987 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); 1965 interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
1988 1966
1989 default: 1967 default:
1990 return scope.internalError('Invalid prefix operator $operator'); 1968 return scope.internalError('Invalid prefix operator $operator');
1991 } 1969 }
1992 } 1970 }
1993 1971
1994 visitPropertyAccess(PropertyAccess node) { 1972 visitPropertyAccess(PropertyAccess node) {
1995 Element element = node.propertyName.staticElement; 1973 Element element = node.propertyName.staticElement;
1996 Element auxiliary = node.propertyName.auxiliaryElements?.staticElement; 1974 Element auxiliary = node.propertyName.auxiliaryElements?.staticElement;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 node.accept(this); 2346 node.accept(this);
2369 } 2347 }
2370 2348
2371 /// Builds an empty class for broken classes that have no AST. 2349 /// Builds an empty class for broken classes that have no AST.
2372 /// 2350 ///
2373 /// This should only be used to recover from a compile-time error. 2351 /// This should only be used to recover from a compile-time error.
2374 void buildBrokenClass() { 2352 void buildBrokenClass() {
2375 currentClass.name = element.name; 2353 currentClass.name = element.name;
2376 currentClass.supertype = scope.getRootClassReference().asRawSupertype; 2354 currentClass.supertype = scope.getRootClassReference().asRawSupertype;
2377 currentClass.constructors.add( 2355 currentClass.constructors.add(
2378 new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())) 2356 new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())));
2379 ..fileOffset = element.nameOffset);
2380 } 2357 }
2381 2358
2382 void addAnnotations(List<Annotation> annotations) { 2359 void addAnnotations(List<Annotation> annotations) {
2383 // Class type parameters are not in scope in the annotation list. 2360 // Class type parameters are not in scope in the annotation list.
2384 for (var annotation in annotations) { 2361 for (var annotation in annotations) {
2385 currentClass.addAnnotation(annotationScope.buildAnnotation(annotation)); 2362 currentClass.addAnnotation(annotationScope.buildAnnotation(annotation));
2386 } 2363 }
2387 } 2364 }
2388 2365
2389 void _buildMemberBody(ast.Member member, Element element, AstNode node) { 2366 void _buildMemberBody(ast.Member member, Element element, AstNode node) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 var parameter = new ast.VariableDeclaration('index', type: intType); 2495 var parameter = new ast.VariableDeclaration('index', type: intType);
2519 var function = new ast.FunctionNode(new ast.EmptyStatement(), 2496 var function = new ast.FunctionNode(new ast.EmptyStatement(),
2520 positionalParameters: [parameter]); 2497 positionalParameters: [parameter]);
2521 var superConstructor = scope.loader.getRootClassConstructorReference(); 2498 var superConstructor = scope.loader.getRootClassConstructorReference();
2522 var constructor = new ast.Constructor(function, 2499 var constructor = new ast.Constructor(function,
2523 name: new ast.Name(''), 2500 name: new ast.Name(''),
2524 isConst: true, 2501 isConst: true,
2525 initializers: [ 2502 initializers: [
2526 new ast.FieldInitializer(indexField, new ast.VariableGet(parameter)), 2503 new ast.FieldInitializer(indexField, new ast.VariableGet(parameter)),
2527 new ast.SuperInitializer(superConstructor, new ast.Arguments.empty()) 2504 new ast.SuperInitializer(superConstructor, new ast.Arguments.empty())
2528 ])..fileOffset = element.nameOffset; 2505 ]);
2529 classNode.addMember(constructor); 2506 classNode.addMember(constructor);
2530 int index = 0; 2507 int index = 0;
2531 var enumConstantFields = <ast.Field>[]; 2508 var enumConstantFields = <ast.Field>[];
2532 for (var constant in node.constants) { 2509 for (var constant in node.constants) {
2533 ast.Field field = scope.getMemberReference(constant.element); 2510 ast.Field field = scope.getMemberReference(constant.element);
2534 field.initializer = new ast.ConstructorInvocation( 2511 field.initializer = new ast.ConstructorInvocation(
2535 constructor, new ast.Arguments([new ast.IntLiteral(index)]), 2512 constructor, new ast.Arguments([new ast.IntLiteral(index)]),
2536 isConst: true)..parent = field; 2513 isConst: true)..parent = field;
2537 field.type = classNode.rawType; 2514 field.type = classNode.rawType;
2538 classNode.addMember(field); 2515 classNode.addMember(field);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 final MemberScope scope; 2571 final MemberScope scope;
2595 final Element element; 2572 final Element element;
2596 ast.Member get currentMember => scope.currentMember; 2573 ast.Member get currentMember => scope.currentMember;
2597 2574
2598 MemberBodyBuilder( 2575 MemberBodyBuilder(
2599 ReferenceLevelLoader loader, ast.Member member, this.element) 2576 ReferenceLevelLoader loader, ast.Member member, this.element)
2600 : scope = new MemberScope(loader, member); 2577 : scope = new MemberScope(loader, member);
2601 2578
2602 void build(AstNode node) { 2579 void build(AstNode node) {
2603 if (node != null) { 2580 if (node != null) {
2604 currentMember.fileEndOffset = node.endToken.offset;
2605 node.accept(this); 2581 node.accept(this);
2606 } else { 2582 } else {
2607 buildBrokenMember(); 2583 buildBrokenMember();
2608 } 2584 }
2609 } 2585 }
2610 2586
2611 /// Builds an empty member. 2587 /// Builds an empty member.
2612 /// 2588 ///
2613 /// This should only be used to recover from a compile-time error. 2589 /// This should only be used to recover from a compile-time error.
2614 void buildBrokenMember() { 2590 void buildBrokenMember() {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 if (list[i - 1].compareTo(item) == 0) { 2865 if (list[i - 1].compareTo(item) == 0) {
2890 ++deleted; 2866 ++deleted;
2891 } else if (deleted > 0) { 2867 } else if (deleted > 0) {
2892 list[i - deleted] = item; 2868 list[i - deleted] = item;
2893 } 2869 }
2894 } 2870 }
2895 if (deleted > 0) { 2871 if (deleted > 0) {
2896 list.length -= deleted; 2872 list.length -= deleted;
2897 } 2873 }
2898 } 2874 }
OLDNEW
« no previous file with comments | « pkg/kernel/bin/dartk.dart ('k') | pkg/kernel/lib/analyzer/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698