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

Side by Side Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 137863002: Issue 8742. Preserve leading line comments during java2dart translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test for block-style comment translation. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/element.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.constant; 8 library engine.constant;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 327 }
328 while (!_referenceGraph.isEmpty) { 328 while (!_referenceGraph.isEmpty) {
329 VariableElement element = _referenceGraph.removeSink(); 329 VariableElement element = _referenceGraph.removeSink();
330 while (element != null) { 330 while (element != null) {
331 computeValueFor(element); 331 computeValueFor(element);
332 element = _referenceGraph.removeSink(); 332 element = _referenceGraph.removeSink();
333 } 333 }
334 if (!_referenceGraph.isEmpty) { 334 if (!_referenceGraph.isEmpty) {
335 List<VariableElement> variablesInCycle = _referenceGraph.findCycle(); 335 List<VariableElement> variablesInCycle = _referenceGraph.findCycle();
336 if (variablesInCycle == null) { 336 if (variablesInCycle == null) {
337 //
338 // This should not happen. Either the graph should be empty, or there should be at least
339 // one sink, or there should be a cycle. If this does happen we exit t o prevent an
340 // infinite loop.
341 //
337 AnalysisEngine.instance.logger.logError("Exiting constant value comput er with ${_referenceGraph.nodeCount} variables that are neither sinks nor in a c ycle"); 342 AnalysisEngine.instance.logger.logError("Exiting constant value comput er with ${_referenceGraph.nodeCount} variables that are neither sinks nor in a c ycle");
338 return; 343 return;
339 } 344 }
340 for (VariableElement variable in variablesInCycle) { 345 for (VariableElement variable in variablesInCycle) {
341 generateCycleError(variablesInCycle, variable); 346 generateCycleError(variablesInCycle, variable);
342 } 347 }
343 _referenceGraph.removeAllNodes(variablesInCycle); 348 _referenceGraph.removeAllNodes(variablesInCycle);
344 } 349 }
345 } 350 }
346 } 351 }
347 352
348 /** 353 /**
349 * Compute a value for the given variable. 354 * Compute a value for the given variable.
350 * 355 *
351 * @param variable the variable for which a value is to be computed 356 * @param variable the variable for which a value is to be computed
352 */ 357 */
353 void computeValueFor(VariableElement variable) { 358 void computeValueFor(VariableElement variable) {
354 VariableDeclaration declaration = _declarationMap[variable]; 359 VariableDeclaration declaration = _declarationMap[variable];
355 if (declaration == null) { 360 if (declaration == null) {
361 //
362 // The declaration will be null when the variable was added to the graph a s a result of being
363 // referenced by another variable but is not defined in the compilation un its that were added
364 // to this computer. In such cases, the variable should already have a val ue associated with
365 // it, but we don't bother to check because there's nothing we can do abou t it at this point.
366 //
356 return; 367 return;
357 } 368 }
358 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis itor(_typeProvider)); 369 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis itor(_typeProvider));
359 (variable as VariableElementImpl).evaluationResult = result; 370 (variable as VariableElementImpl).evaluationResult = result;
360 if (result is ErrorResult) { 371 if (result is ErrorResult) {
361 List<AnalysisError> errors = new List<AnalysisError>(); 372 List<AnalysisError> errors = new List<AnalysisError>();
362 for (ErrorResult_ErrorData data in result.errorData) { 373 for (ErrorResult_ErrorData data in result.errorData) {
363 ASTNode node = data.node; 374 ASTNode node = data.node;
364 Source source = variable.getAncestor(CompilationUnitElement).source; 375 Source source = variable.getAncestor(CompilationUnitElement).source;
365 errors.add(new AnalysisError.con2(source, node.offset, node.length, data .errorCode, [])); 376 errors.add(new AnalysisError.con2(source, node.offset, node.length, data .errorCode, []));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 result = result.concatenate(_typeProvider, node, string.accept(this)); 464 result = result.concatenate(_typeProvider, node, string.accept(this));
454 } 465 }
455 } 466 }
456 return result; 467 return result;
457 } 468 }
458 469
459 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) { 470 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) {
460 EvaluationResultImpl leftResult = node.leftOperand.accept(this); 471 EvaluationResultImpl leftResult = node.leftOperand.accept(this);
461 EvaluationResultImpl rightResult = node.rightOperand.accept(this); 472 EvaluationResultImpl rightResult = node.rightOperand.accept(this);
462 TokenType operatorType = node.operator.type; 473 TokenType operatorType = node.operator.type;
474 // 'null' is almost never good operand
463 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) { 475 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) {
464 if (leftResult is ValidResult && leftResult.isNull || rightResult is Valid Result && rightResult.isNull) { 476 if (leftResult is ValidResult && leftResult.isNull || rightResult is Valid Result && rightResult.isNull) {
465 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); 477 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
466 } 478 }
467 } 479 }
480 // evaluate operator
468 while (true) { 481 while (true) {
469 if (operatorType == TokenType.AMPERSAND) { 482 if (operatorType == TokenType.AMPERSAND) {
470 return leftResult.bitAnd(_typeProvider, node, rightResult); 483 return leftResult.bitAnd(_typeProvider, node, rightResult);
471 } else if (operatorType == TokenType.AMPERSAND_AMPERSAND) { 484 } else if (operatorType == TokenType.AMPERSAND_AMPERSAND) {
472 return leftResult.logicalAnd(_typeProvider, node, rightResult); 485 return leftResult.logicalAnd(_typeProvider, node, rightResult);
473 } else if (operatorType == TokenType.BANG_EQ) { 486 } else if (operatorType == TokenType.BANG_EQ) {
474 return leftResult.notEqual(_typeProvider, node, rightResult); 487 return leftResult.notEqual(_typeProvider, node, rightResult);
475 } else if (operatorType == TokenType.BAR) { 488 } else if (operatorType == TokenType.BAR) {
476 return leftResult.bitOr(_typeProvider, node, rightResult); 489 return leftResult.bitOr(_typeProvider, node, rightResult);
477 } else if (operatorType == TokenType.BAR_BAR) { 490 } else if (operatorType == TokenType.BAR_BAR) {
(...skipping 22 matching lines...) Expand all
500 return leftResult.add(_typeProvider, node, rightResult); 513 return leftResult.add(_typeProvider, node, rightResult);
501 } else if (operatorType == TokenType.STAR) { 514 } else if (operatorType == TokenType.STAR) {
502 return leftResult.times(_typeProvider, node, rightResult); 515 return leftResult.times(_typeProvider, node, rightResult);
503 } else if (operatorType == TokenType.SLASH) { 516 } else if (operatorType == TokenType.SLASH) {
504 return leftResult.divide(_typeProvider, node, rightResult); 517 return leftResult.divide(_typeProvider, node, rightResult);
505 } else if (operatorType == TokenType.TILDE_SLASH) { 518 } else if (operatorType == TokenType.TILDE_SLASH) {
506 return leftResult.integerDivide(_typeProvider, node, rightResult); 519 return leftResult.integerDivide(_typeProvider, node, rightResult);
507 } 520 }
508 break; 521 break;
509 } 522 }
523 // TODO(brianwilkerson) Figure out which error to report.
510 return error(node, null); 524 return error(node, null);
511 } 525 }
512 526
513 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => valid2(_typeP rovider.boolType, BoolState.from(node.value)); 527 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => valid2(_typeP rovider.boolType, BoolState.from(node.value));
514 528
515 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) { 529 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) {
516 Expression condition = node.condition; 530 Expression condition = node.condition;
517 EvaluationResultImpl conditionResult = condition.accept(this); 531 EvaluationResultImpl conditionResult = condition.accept(this);
518 EvaluationResultImpl thenResult = node.thenExpression.accept(this); 532 EvaluationResultImpl thenResult = node.thenExpression.accept(this);
519 EvaluationResultImpl elseResult = node.elseExpression.accept(this); 533 EvaluationResultImpl elseResult = node.elseExpression.accept(this);
(...skipping 18 matching lines...) Expand all
538 } 552 }
539 InterfaceType thenType = (thenResult as ValidResult).value.type; 553 InterfaceType thenType = (thenResult as ValidResult).value.type;
540 InterfaceType elseType = (elseResult as ValidResult).value.type; 554 InterfaceType elseType = (elseResult as ValidResult).value.type;
541 return valid(thenType.getLeastUpperBound(elseType) as InterfaceType); 555 return valid(thenType.getLeastUpperBound(elseType) as InterfaceType);
542 } 556 }
543 557
544 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => valid2(_typePro vider.doubleType, new DoubleState(node.value)); 558 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => valid2(_typePro vider.doubleType, new DoubleState(node.value));
545 559
546 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio n node) { 560 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio n node) {
547 if (!node.isConst) { 561 if (!node.isConst) {
562 // TODO(brianwilkerson) Figure out which error to report.
548 return error(node, null); 563 return error(node, null);
549 } 564 }
550 ConstructorElement constructor = node.staticElement; 565 ConstructorElement constructor = node.staticElement;
551 if (constructor != null && constructor.isConst) { 566 if (constructor != null && constructor.isConst) {
552 NodeList<Expression> arguments = node.argumentList.arguments; 567 NodeList<Expression> arguments = node.argumentList.arguments;
553 int argumentCount = arguments.length; 568 int argumentCount = arguments.length;
554 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou nt); 569 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou nt);
555 Map<String, DartObjectImpl> namedArgumentValues = new Map<String, DartObje ctImpl>(); 570 Map<String, DartObjectImpl> namedArgumentValues = new Map<String, DartObje ctImpl>();
556 for (int i = 0; i < argumentCount; i++) { 571 for (int i = 0; i < argumentCount; i++) {
557 Expression argument = arguments[i]; 572 Expression argument = arguments[i];
(...skipping 26 matching lines...) Expand all
584 if (identical(parameter.parameterKind, ParameterKind.NAMED)) { 599 if (identical(parameter.parameterKind, ParameterKind.NAMED)) {
585 DartObjectImpl argumentValue = namedArgumentValues[parameter.name]; 600 DartObjectImpl argumentValue = namedArgumentValues[parameter.name];
586 if (argumentValue != null) { 601 if (argumentValue != null) {
587 fieldMap[fieldName] = argumentValue; 602 fieldMap[fieldName] = argumentValue;
588 } 603 }
589 } else if (i < argumentCount) { 604 } else if (i < argumentCount) {
590 fieldMap[fieldName] = argumentValues[i]; 605 fieldMap[fieldName] = argumentValues[i];
591 } 606 }
592 } 607 }
593 } 608 }
609 // TODO(brianwilkerson) This doesn't handle fields initialized in an initi alizer. We should be
610 // able to handle fields initialized by the superclass' constructor fairly easily, but other
611 // initializers will be harder.
594 return valid2(definingClass, new GenericState(fieldMap)); 612 return valid2(definingClass, new GenericState(fieldMap));
595 } 613 }
614 // TODO(brianwilkerson) Figure out which error to report.
596 return error(node, null); 615 return error(node, null);
597 } 616 }
598 617
599 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => valid2(_typeP rovider.intType, new IntState(node.value)); 618 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => valid2(_typeP rovider.intType, new IntState(node.value));
600 619
601 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node ) { 620 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node ) {
602 EvaluationResultImpl result = node.expression.accept(this); 621 EvaluationResultImpl result = node.expression.accept(this);
603 if (result is ValidResult && !result.isBoolNumStringOrNull) { 622 if (result is ValidResult && !result.isBoolNumStringOrNull) {
604 return error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); 623 return error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING);
605 } 624 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 LibraryElement library = enclosingElement.library; 679 LibraryElement library = enclosingElement.library;
661 if (library.isDartCore) { 680 if (library.isDartCore) {
662 EvaluationResultImpl leftArgument = arguments[0].accept(this); 681 EvaluationResultImpl leftArgument = arguments[0].accept(this);
663 EvaluationResultImpl rightArgument = arguments[1].accept(this); 682 EvaluationResultImpl rightArgument = arguments[1].accept(this);
664 return leftArgument.equalEqual(_typeProvider, node, rightArgument) ; 683 return leftArgument.equalEqual(_typeProvider, node, rightArgument) ;
665 } 684 }
666 } 685 }
667 } 686 }
668 } 687 }
669 } 688 }
689 // TODO(brianwilkerson) Figure out which error to report.
670 return error(node, null); 690 return error(node, null);
671 } 691 }
672 692
673 EvaluationResultImpl visitNamedExpression(NamedExpression node) => node.expres sion.accept(this); 693 EvaluationResultImpl visitNamedExpression(NamedExpression node) => node.expres sion.accept(this);
674 694
675 EvaluationResultImpl visitNode(ASTNode node) => error(node, null); 695 EvaluationResultImpl visitNode(ASTNode node) => error(node, null);
676 696
677 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul l2); 697 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul l2);
678 698
679 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node ) => node.expression.accept(this); 699 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node ) => node.expression.accept(this);
680 700
681 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) { 701 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) {
702 // validate prefix
682 SimpleIdentifier prefixNode = node.prefix; 703 SimpleIdentifier prefixNode = node.prefix;
683 Element prefixElement = prefixNode.staticElement; 704 Element prefixElement = prefixNode.staticElement;
684 if (prefixElement is! PrefixElement) { 705 if (prefixElement is! PrefixElement) {
685 EvaluationResultImpl prefixResult = prefixNode.accept(this); 706 EvaluationResultImpl prefixResult = prefixNode.accept(this);
686 if (prefixResult is! ValidResult) { 707 if (prefixResult is! ValidResult) {
687 return error(node, null); 708 return error(node, null);
688 } 709 }
689 } 710 }
711 // validate prefixed identifier
690 return getConstantValue(node, node.staticElement); 712 return getConstantValue(node, node.staticElement);
691 } 713 }
692 714
693 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { 715 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) {
694 EvaluationResultImpl operand = node.operand.accept(this); 716 EvaluationResultImpl operand = node.operand.accept(this);
695 if (operand is ValidResult && operand.isNull) { 717 if (operand is ValidResult && operand.isNull) {
696 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); 718 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
697 } 719 }
698 while (true) { 720 while (true) {
699 if (node.operator.type == TokenType.BANG) { 721 if (node.operator.type == TokenType.BANG) {
700 return operand.logicalNot(_typeProvider, node); 722 return operand.logicalNot(_typeProvider, node);
701 } else if (node.operator.type == TokenType.TILDE) { 723 } else if (node.operator.type == TokenType.TILDE) {
702 return operand.bitNot(_typeProvider, node); 724 return operand.bitNot(_typeProvider, node);
703 } else if (node.operator.type == TokenType.MINUS) { 725 } else if (node.operator.type == TokenType.MINUS) {
704 return operand.negated(_typeProvider, node); 726 return operand.negated(_typeProvider, node);
705 } 727 }
706 break; 728 break;
707 } 729 }
730 // TODO(brianwilkerson) Figure out which error to report.
708 return error(node, null); 731 return error(node, null);
709 } 732 }
710 733
711 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa lue(node, node.propertyName.staticElement); 734 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa lue(node, node.propertyName.staticElement);
712 735
713 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta ntValue(node, node.staticElement); 736 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta ntValue(node, node.staticElement);
714 737
715 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => val id2(_typeProvider.stringType, new StringState(node.value)); 738 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => val id2(_typeProvider.stringType, new StringState(node.value));
716 739
717 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { 740 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return value; 788 return value;
766 } 789 }
767 } else if (element is ExecutableElement) { 790 } else if (element is ExecutableElement) {
768 ExecutableElement function = element; 791 ExecutableElement function = element;
769 if (function.isStatic) { 792 if (function.isStatic) {
770 return valid2(_typeProvider.functionType, new FunctionState(function)); 793 return valid2(_typeProvider.functionType, new FunctionState(function));
771 } 794 }
772 } else if (element is ClassElement || element is FunctionTypeAliasElement) { 795 } else if (element is ClassElement || element is FunctionTypeAliasElement) {
773 return valid2(_typeProvider.typeType, new TypeState(element)); 796 return valid2(_typeProvider.typeType, new TypeState(element));
774 } 797 }
798 // TODO(brianwilkerson) Figure out which error to report.
775 return error(node, null); 799 return error(node, null);
776 } 800 }
777 801
778 /** 802 /**
779 * Return an object representing the value 'null'. 803 * Return an object representing the value 'null'.
780 * 804 *
781 * @return an object representing the value 'null' 805 * @return an object representing the value 'null'
782 */ 806 */
783 DartObjectImpl get null2 { 807 DartObjectImpl get null2 {
784 if (_nullObject == null) { 808 if (_nullObject == null) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 Map<N, Set<N>> _edges = new Map<N, Set<N>>(); 882 Map<N, Set<N>> _edges = new Map<N, Set<N>>();
859 883
860 /** 884 /**
861 * Add an edge from the given head node to the given tail node. Both nodes wil l be a part of the 885 * Add an edge from the given head node to the given tail node. Both nodes wil l be a part of the
862 * graph after this method is invoked, whether or not they were before. 886 * graph after this method is invoked, whether or not they were before.
863 * 887 *
864 * @param head the node at the head of the edge 888 * @param head the node at the head of the edge
865 * @param tail the node at the tail of the edge 889 * @param tail the node at the tail of the edge
866 */ 890 */
867 void addEdge(N head, N tail) { 891 void addEdge(N head, N tail) {
892 //
893 // First, ensure that the tail is a node known to the graph.
894 //
868 Set<N> tails = _edges[tail]; 895 Set<N> tails = _edges[tail];
869 if (tails == null) { 896 if (tails == null) {
870 _edges[tail] = new Set<N>(); 897 _edges[tail] = new Set<N>();
871 } 898 }
899 //
900 // Then create the edge.
901 //
872 tails = _edges[head]; 902 tails = _edges[head];
873 if (tails == null) { 903 if (tails == null) {
874 tails = new Set<N>(); 904 tails = new Set<N>();
875 _edges[head] = tails; 905 _edges[head] = tails;
876 } 906 }
877 tails.add(tail); 907 tails.add(tail);
878 } 908 }
879 909
880 /** 910 /**
881 * Add the given node to the set of nodes in the graph. 911 * Add the given node to the set of nodes in the graph.
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 */ 1928 */
1899 DartObjectImpl add(TypeProvider typeProvider, DartObjectImpl rightOperand) { 1929 DartObjectImpl add(TypeProvider typeProvider, DartObjectImpl rightOperand) {
1900 InstanceState result = _state.add(rightOperand._state); 1930 InstanceState result = _state.add(rightOperand._state);
1901 if (result is IntState) { 1931 if (result is IntState) {
1902 return new DartObjectImpl(typeProvider.intType, result); 1932 return new DartObjectImpl(typeProvider.intType, result);
1903 } else if (result is DoubleState) { 1933 } else if (result is DoubleState) {
1904 return new DartObjectImpl(typeProvider.doubleType, result); 1934 return new DartObjectImpl(typeProvider.doubleType, result);
1905 } else if (result is NumState) { 1935 } else if (result is NumState) {
1906 return new DartObjectImpl(typeProvider.numType, result); 1936 return new DartObjectImpl(typeProvider.numType, result);
1907 } 1937 }
1938 // We should never get here.
1908 throw new IllegalStateException("add returned a ${result.runtimeType.toStrin g()}"); 1939 throw new IllegalStateException("add returned a ${result.runtimeType.toStrin g()}");
1909 } 1940 }
1910 1941
1911 /** 1942 /**
1912 * Return the result of invoking the '&' operator on this object with the give n argument. 1943 * Return the result of invoking the '&' operator on this object with the give n argument.
1913 * 1944 *
1914 * @param typeProvider the type provider used to find known types 1945 * @param typeProvider the type provider used to find known types
1915 * @param rightOperand the right-hand operand of the operation 1946 * @param rightOperand the right-hand operand of the operation
1916 * @return the result of invoking the '&' operator on this object with the giv en argument 1947 * @return the result of invoking the '&' operator on this object with the giv en argument
1917 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind 1948 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 */ 2013 */
1983 DartObjectImpl divide(TypeProvider typeProvider, DartObjectImpl rightOperand) { 2014 DartObjectImpl divide(TypeProvider typeProvider, DartObjectImpl rightOperand) {
1984 InstanceState result = _state.divide(rightOperand._state); 2015 InstanceState result = _state.divide(rightOperand._state);
1985 if (result is IntState) { 2016 if (result is IntState) {
1986 return new DartObjectImpl(typeProvider.intType, result); 2017 return new DartObjectImpl(typeProvider.intType, result);
1987 } else if (result is DoubleState) { 2018 } else if (result is DoubleState) {
1988 return new DartObjectImpl(typeProvider.doubleType, result); 2019 return new DartObjectImpl(typeProvider.doubleType, result);
1989 } else if (result is NumState) { 2020 } else if (result is NumState) {
1990 return new DartObjectImpl(typeProvider.numType, result); 2021 return new DartObjectImpl(typeProvider.numType, result);
1991 } 2022 }
2023 // We should never get here.
1992 throw new IllegalStateException("divide returned a ${result.runtimeType.toSt ring()}"); 2024 throw new IllegalStateException("divide returned a ${result.runtimeType.toSt ring()}");
1993 } 2025 }
1994 2026
1995 /** 2027 /**
1996 * Return the result of invoking the '==' operator on this object with the giv en argument. 2028 * Return the result of invoking the '==' operator on this object with the giv en argument.
1997 * 2029 *
1998 * @param typeProvider the type provider used to find known types 2030 * @param typeProvider the type provider used to find known types
1999 * @param rightOperand the right-hand operand of the operation 2031 * @param rightOperand the right-hand operand of the operation
2000 * @return the result of invoking the '==' operator on this object with the gi ven argument 2032 * @return the result of invoking the '==' operator on this object with the gi ven argument
2001 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind 2033 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 */ 2201 */
2170 DartObjectImpl minus(TypeProvider typeProvider, DartObjectImpl rightOperand) { 2202 DartObjectImpl minus(TypeProvider typeProvider, DartObjectImpl rightOperand) {
2171 InstanceState result = _state.minus(rightOperand._state); 2203 InstanceState result = _state.minus(rightOperand._state);
2172 if (result is IntState) { 2204 if (result is IntState) {
2173 return new DartObjectImpl(typeProvider.intType, result); 2205 return new DartObjectImpl(typeProvider.intType, result);
2174 } else if (result is DoubleState) { 2206 } else if (result is DoubleState) {
2175 return new DartObjectImpl(typeProvider.doubleType, result); 2207 return new DartObjectImpl(typeProvider.doubleType, result);
2176 } else if (result is NumState) { 2208 } else if (result is NumState) {
2177 return new DartObjectImpl(typeProvider.numType, result); 2209 return new DartObjectImpl(typeProvider.numType, result);
2178 } 2210 }
2211 // We should never get here.
2179 throw new IllegalStateException("minus returned a ${result.runtimeType.toStr ing()}"); 2212 throw new IllegalStateException("minus returned a ${result.runtimeType.toStr ing()}");
2180 } 2213 }
2181 2214
2182 /** 2215 /**
2183 * Return the result of invoking the '-' operator on this object. 2216 * Return the result of invoking the '-' operator on this object.
2184 * 2217 *
2185 * @param typeProvider the type provider used to find known types 2218 * @param typeProvider the type provider used to find known types
2186 * @return the result of invoking the '-' operator on this object 2219 * @return the result of invoking the '-' operator on this object
2187 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind 2220 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind
2188 */ 2221 */
2189 DartObjectImpl negated(TypeProvider typeProvider) { 2222 DartObjectImpl negated(TypeProvider typeProvider) {
2190 InstanceState result = _state.negated(); 2223 InstanceState result = _state.negated();
2191 if (result is IntState) { 2224 if (result is IntState) {
2192 return new DartObjectImpl(typeProvider.intType, result); 2225 return new DartObjectImpl(typeProvider.intType, result);
2193 } else if (result is DoubleState) { 2226 } else if (result is DoubleState) {
2194 return new DartObjectImpl(typeProvider.doubleType, result); 2227 return new DartObjectImpl(typeProvider.doubleType, result);
2195 } else if (result is NumState) { 2228 } else if (result is NumState) {
2196 return new DartObjectImpl(typeProvider.numType, result); 2229 return new DartObjectImpl(typeProvider.numType, result);
2197 } 2230 }
2231 // We should never get here.
2198 throw new IllegalStateException("negated returned a ${result.runtimeType.toS tring()}"); 2232 throw new IllegalStateException("negated returned a ${result.runtimeType.toS tring()}");
2199 } 2233 }
2200 2234
2201 /** 2235 /**
2202 * Return the result of invoking the '!=' operator on this object with the giv en argument. 2236 * Return the result of invoking the '!=' operator on this object with the giv en argument.
2203 * 2237 *
2204 * @param typeProvider the type provider used to find known types 2238 * @param typeProvider the type provider used to find known types
2205 * @param rightOperand the right-hand operand of the operation 2239 * @param rightOperand the right-hand operand of the operation
2206 * @return the result of invoking the '!=' operator on this object with the gi ven argument 2240 * @return the result of invoking the '!=' operator on this object with the gi ven argument
2207 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind 2241 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 */ 2275 */
2242 DartObjectImpl remainder(TypeProvider typeProvider, DartObjectImpl rightOperan d) { 2276 DartObjectImpl remainder(TypeProvider typeProvider, DartObjectImpl rightOperan d) {
2243 InstanceState result = _state.remainder(rightOperand._state); 2277 InstanceState result = _state.remainder(rightOperand._state);
2244 if (result is IntState) { 2278 if (result is IntState) {
2245 return new DartObjectImpl(typeProvider.intType, result); 2279 return new DartObjectImpl(typeProvider.intType, result);
2246 } else if (result is DoubleState) { 2280 } else if (result is DoubleState) {
2247 return new DartObjectImpl(typeProvider.doubleType, result); 2281 return new DartObjectImpl(typeProvider.doubleType, result);
2248 } else if (result is NumState) { 2282 } else if (result is NumState) {
2249 return new DartObjectImpl(typeProvider.numType, result); 2283 return new DartObjectImpl(typeProvider.numType, result);
2250 } 2284 }
2285 // We should never get here.
2251 throw new IllegalStateException("remainder returned a ${result.runtimeType.t oString()}"); 2286 throw new IllegalStateException("remainder returned a ${result.runtimeType.t oString()}");
2252 } 2287 }
2253 2288
2254 /** 2289 /**
2255 * Return the result of invoking the '&lt;&lt;' operator on this object with t he given argument. 2290 * Return the result of invoking the '&lt;&lt;' operator on this object with t he given argument.
2256 * 2291 *
2257 * @param typeProvider the type provider used to find known types 2292 * @param typeProvider the type provider used to find known types
2258 * @param rightOperand the right-hand operand of the operation 2293 * @param rightOperand the right-hand operand of the operation
2259 * @return the result of invoking the '&lt;&lt;' operator on this object with the given argument 2294 * @return the result of invoking the '&lt;&lt;' operator on this object with the given argument
2260 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind 2295 * @throws EvaluationException if the operator is not appropriate for an objec t of this kind
(...skipping 20 matching lines...) Expand all
2281 */ 2316 */
2282 DartObjectImpl times(TypeProvider typeProvider, DartObjectImpl rightOperand) { 2317 DartObjectImpl times(TypeProvider typeProvider, DartObjectImpl rightOperand) {
2283 InstanceState result = _state.times(rightOperand._state); 2318 InstanceState result = _state.times(rightOperand._state);
2284 if (result is IntState) { 2319 if (result is IntState) {
2285 return new DartObjectImpl(typeProvider.intType, result); 2320 return new DartObjectImpl(typeProvider.intType, result);
2286 } else if (result is DoubleState) { 2321 } else if (result is DoubleState) {
2287 return new DartObjectImpl(typeProvider.doubleType, result); 2322 return new DartObjectImpl(typeProvider.doubleType, result);
2288 } else if (result is NumState) { 2323 } else if (result is NumState) {
2289 return new DartObjectImpl(typeProvider.numType, result); 2324 return new DartObjectImpl(typeProvider.numType, result);
2290 } 2325 }
2326 // We should never get here.
2291 throw new IllegalStateException("times returned a ${result.runtimeType.toStr ing()}"); 2327 throw new IllegalStateException("times returned a ${result.runtimeType.toStr ing()}");
2292 } 2328 }
2293 2329
2294 String toString() => "${type.displayName} (${_state.toString()})"; 2330 String toString() => "${type.displayName} (${_state.toString()})";
2295 } 2331 }
2296 2332
2297 /** 2333 /**
2298 * Instances of the class `DoubleState` represent the state of an object represe nting a 2334 * Instances of the class `DoubleState` represent the state of an object represe nting a
2299 * double. 2335 * double.
2300 */ 2336 */
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 } 4186 }
4151 return BoolState.FALSE_STATE; 4187 return BoolState.FALSE_STATE;
4152 } 4188 }
4153 4189
4154 String get typeName => "Type"; 4190 String get typeName => "Type";
4155 4191
4156 int get hashCode => _element == null ? 0 : _element.hashCode; 4192 int get hashCode => _element == null ? 0 : _element.hashCode;
4157 4193
4158 String toString() => _element == null ? "-unknown-" : _element.name; 4194 String toString() => _element == null ? "-unknown-" : _element.name;
4159 } 4195 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698