| OLD | NEW |
| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of | 244 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of |
| 245 * the compilation units being resolved and build a table mapping constant varia
ble elements to the | 245 * the compilation units being resolved and build a table mapping constant varia
ble elements to the |
| 246 * declarations of those variables. | 246 * declarations of those variables. |
| 247 */ | 247 */ |
| 248 class ConstantFinder extends RecursiveAstVisitor<Object> { | 248 class ConstantFinder extends RecursiveAstVisitor<Object> { |
| 249 /** | 249 /** |
| 250 * A table mapping constant variable elements to the declarations of those var
iables. | 250 * A table mapping constant variable elements to the declarations of those var
iables. |
| 251 */ | 251 */ |
| 252 final Map<VariableElement, VariableDeclaration> variableMap = new Map<Variable
Element, VariableDeclaration>(); | 252 final Map<VariableElement, VariableDeclaration> variableMap = new Map<Variable
Element, VariableDeclaration>(); |
| 253 | 253 |
| 254 @override |
| 254 Object visitVariableDeclaration(VariableDeclaration node) { | 255 Object visitVariableDeclaration(VariableDeclaration node) { |
| 255 super.visitVariableDeclaration(node); | 256 super.visitVariableDeclaration(node); |
| 256 Expression initializer = node.initializer; | 257 Expression initializer = node.initializer; |
| 257 if (initializer != null && node.isConst) { | 258 if (initializer != null && node.isConst) { |
| 258 VariableElement element = node.element; | 259 VariableElement element = node.element; |
| 259 if (element != null) { | 260 if (element != null) { |
| 260 variableMap[element] = node; | 261 variableMap[element] = node; |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 return null; | 264 return null; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 445 |
| 445 /** | 446 /** |
| 446 * Initialize a newly created constant visitor. | 447 * Initialize a newly created constant visitor. |
| 447 * | 448 * |
| 448 * @param typeProvider the type provider used to access known types | 449 * @param typeProvider the type provider used to access known types |
| 449 */ | 450 */ |
| 450 ConstantVisitor(TypeProvider typeProvider) { | 451 ConstantVisitor(TypeProvider typeProvider) { |
| 451 this._typeProvider = typeProvider; | 452 this._typeProvider = typeProvider; |
| 452 } | 453 } |
| 453 | 454 |
| 455 @override |
| 454 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) { | 456 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) { |
| 455 EvaluationResultImpl result = null; | 457 EvaluationResultImpl result = null; |
| 456 for (StringLiteral string in node.strings) { | 458 for (StringLiteral string in node.strings) { |
| 457 if (result == null) { | 459 if (result == null) { |
| 458 result = string.accept(this); | 460 result = string.accept(this); |
| 459 } else { | 461 } else { |
| 460 result = result.concatenate(_typeProvider, node, string.accept(this)); | 462 result = result.concatenate(_typeProvider, node, string.accept(this)); |
| 461 } | 463 } |
| 462 } | 464 } |
| 463 return result; | 465 return result; |
| 464 } | 466 } |
| 465 | 467 |
| 468 @override |
| 466 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) { | 469 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) { |
| 467 EvaluationResultImpl leftResult = node.leftOperand.accept(this); | 470 EvaluationResultImpl leftResult = node.leftOperand.accept(this); |
| 468 EvaluationResultImpl rightResult = node.rightOperand.accept(this); | 471 EvaluationResultImpl rightResult = node.rightOperand.accept(this); |
| 469 TokenType operatorType = node.operator.type; | 472 TokenType operatorType = node.operator.type; |
| 470 // 'null' is almost never good operand | 473 // 'null' is almost never good operand |
| 471 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) { | 474 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) { |
| 472 if (leftResult is ValidResult && leftResult.isNull || rightResult is Valid
Result && rightResult.isNull) { | 475 if (leftResult is ValidResult && leftResult.isNull || rightResult is Valid
Result && rightResult.isNull) { |
| 473 return _error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); | 476 return _error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); |
| 474 } | 477 } |
| 475 } | 478 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } else if (operatorType == TokenType.TILDE_SLASH) { | 517 } else if (operatorType == TokenType.TILDE_SLASH) { |
| 515 return leftResult.integerDivide(_typeProvider, node, rightResult); | 518 return leftResult.integerDivide(_typeProvider, node, rightResult); |
| 516 } else { | 519 } else { |
| 517 // TODO(brianwilkerson) Figure out which error to report. | 520 // TODO(brianwilkerson) Figure out which error to report. |
| 518 return _error(node, null); | 521 return _error(node, null); |
| 519 } | 522 } |
| 520 break; | 523 break; |
| 521 } | 524 } |
| 522 } | 525 } |
| 523 | 526 |
| 527 @override |
| 524 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => _valid(_typeP
rovider.boolType, BoolState.from(node.value)); | 528 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => _valid(_typeP
rovider.boolType, BoolState.from(node.value)); |
| 525 | 529 |
| 530 @override |
| 526 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) { | 531 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) { |
| 527 Expression condition = node.condition; | 532 Expression condition = node.condition; |
| 528 EvaluationResultImpl conditionResult = condition.accept(this); | 533 EvaluationResultImpl conditionResult = condition.accept(this); |
| 529 EvaluationResultImpl thenResult = node.thenExpression.accept(this); | 534 EvaluationResultImpl thenResult = node.thenExpression.accept(this); |
| 530 EvaluationResultImpl elseResult = node.elseExpression.accept(this); | 535 EvaluationResultImpl elseResult = node.elseExpression.accept(this); |
| 531 if (conditionResult is ErrorResult) { | 536 if (conditionResult is ErrorResult) { |
| 532 return _union(_union(conditionResult as ErrorResult, thenResult), elseResu
lt); | 537 return _union(_union(conditionResult as ErrorResult, thenResult), elseResu
lt); |
| 533 } else if (!(conditionResult as ValidResult).isBool) { | 538 } else if (!(conditionResult as ValidResult).isBool) { |
| 534 return new ErrorResult.con1(condition, CompileTimeErrorCode.CONST_EVAL_TYP
E_BOOL); | 539 return new ErrorResult.con1(condition, CompileTimeErrorCode.CONST_EVAL_TYP
E_BOOL); |
| 535 } else if (thenResult is ErrorResult) { | 540 } else if (thenResult is ErrorResult) { |
| 536 return _union(thenResult, elseResult); | 541 return _union(thenResult, elseResult); |
| 537 } else if (elseResult is ErrorResult) { | 542 } else if (elseResult is ErrorResult) { |
| 538 return elseResult; | 543 return elseResult; |
| 539 } | 544 } |
| 540 conditionResult = conditionResult.applyBooleanConversion(_typeProvider, cond
ition); | 545 conditionResult = conditionResult.applyBooleanConversion(_typeProvider, cond
ition); |
| 541 if (conditionResult is ErrorResult) { | 546 if (conditionResult is ErrorResult) { |
| 542 return conditionResult; | 547 return conditionResult; |
| 543 } | 548 } |
| 544 ValidResult validResult = conditionResult as ValidResult; | 549 ValidResult validResult = conditionResult as ValidResult; |
| 545 if (validResult.isTrue) { | 550 if (validResult.isTrue) { |
| 546 return thenResult; | 551 return thenResult; |
| 547 } else if (validResult.isFalse) { | 552 } else if (validResult.isFalse) { |
| 548 return elseResult; | 553 return elseResult; |
| 549 } | 554 } |
| 550 InterfaceType thenType = (thenResult as ValidResult).value.type; | 555 InterfaceType thenType = (thenResult as ValidResult).value.type; |
| 551 InterfaceType elseType = (elseResult as ValidResult).value.type; | 556 InterfaceType elseType = (elseResult as ValidResult).value.type; |
| 552 return _validWithUnknownValue(thenType.getLeastUpperBound(elseType) as Inter
faceType); | 557 return _validWithUnknownValue(thenType.getLeastUpperBound(elseType) as Inter
faceType); |
| 553 } | 558 } |
| 554 | 559 |
| 560 @override |
| 555 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => _valid(_typePro
vider.doubleType, new DoubleState(node.value)); | 561 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => _valid(_typePro
vider.doubleType, new DoubleState(node.value)); |
| 556 | 562 |
| 563 @override |
| 557 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { | 564 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { |
| 558 if (!node.isConst) { | 565 if (!node.isConst) { |
| 559 // TODO(brianwilkerson) Figure out which error to report. | 566 // TODO(brianwilkerson) Figure out which error to report. |
| 560 return _error(node, null); | 567 return _error(node, null); |
| 561 } | 568 } |
| 562 ConstructorElement constructor = node.staticElement; | 569 ConstructorElement constructor = node.staticElement; |
| 563 if (constructor != null && constructor.isConst) { | 570 if (constructor != null && constructor.isConst) { |
| 564 NodeList<Expression> arguments = node.argumentList.arguments; | 571 NodeList<Expression> arguments = node.argumentList.arguments; |
| 565 int argumentCount = arguments.length; | 572 int argumentCount = arguments.length; |
| 566 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou
nt); | 573 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou
nt); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } | 612 } |
| 606 // TODO(brianwilkerson) This doesn't handle fields initialized in an initi
alizer. We should be | 613 // TODO(brianwilkerson) This doesn't handle fields initialized in an initi
alizer. We should be |
| 607 // able to handle fields initialized by the superclass' constructor fairly
easily, but other | 614 // able to handle fields initialized by the superclass' constructor fairly
easily, but other |
| 608 // initializers will be harder. | 615 // initializers will be harder. |
| 609 return _valid(definingClass, new GenericState(fieldMap)); | 616 return _valid(definingClass, new GenericState(fieldMap)); |
| 610 } | 617 } |
| 611 // TODO(brianwilkerson) Figure out which error to report. | 618 // TODO(brianwilkerson) Figure out which error to report. |
| 612 return _error(node, null); | 619 return _error(node, null); |
| 613 } | 620 } |
| 614 | 621 |
| 622 @override |
| 615 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => _valid(_typeP
rovider.intType, new IntState(node.value)); | 623 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => _valid(_typeP
rovider.intType, new IntState(node.value)); |
| 616 | 624 |
| 625 @override |
| 617 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { | 626 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { |
| 618 EvaluationResultImpl result = node.expression.accept(this); | 627 EvaluationResultImpl result = node.expression.accept(this); |
| 619 if (result is ValidResult && !result.isBoolNumStringOrNull) { | 628 if (result is ValidResult && !result.isBoolNumStringOrNull) { |
| 620 return _error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); | 629 return _error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); |
| 621 } | 630 } |
| 622 return result.performToString(_typeProvider, node); | 631 return result.performToString(_typeProvider, node); |
| 623 } | 632 } |
| 624 | 633 |
| 634 @override |
| 625 EvaluationResultImpl visitInterpolationString(InterpolationString node) => _va
lid(_typeProvider.stringType, new StringState(node.value)); | 635 EvaluationResultImpl visitInterpolationString(InterpolationString node) => _va
lid(_typeProvider.stringType, new StringState(node.value)); |
| 626 | 636 |
| 637 @override |
| 627 EvaluationResultImpl visitListLiteral(ListLiteral node) { | 638 EvaluationResultImpl visitListLiteral(ListLiteral node) { |
| 628 if (node.constKeyword == null) { | 639 if (node.constKeyword == null) { |
| 629 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_LI
ST_LITERAL); | 640 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_LI
ST_LITERAL); |
| 630 } | 641 } |
| 631 ErrorResult result = null; | 642 ErrorResult result = null; |
| 632 List<DartObjectImpl> elements = new List<DartObjectImpl>(); | 643 List<DartObjectImpl> elements = new List<DartObjectImpl>(); |
| 633 for (Expression element in node.elements) { | 644 for (Expression element in node.elements) { |
| 634 EvaluationResultImpl elementResult = element.accept(this); | 645 EvaluationResultImpl elementResult = element.accept(this); |
| 635 result = _union(result, elementResult); | 646 result = _union(result, elementResult); |
| 636 if (elementResult is ValidResult) { | 647 if (elementResult is ValidResult) { |
| 637 elements.add(elementResult.value); | 648 elements.add(elementResult.value); |
| 638 } | 649 } |
| 639 } | 650 } |
| 640 if (result != null) { | 651 if (result != null) { |
| 641 return result; | 652 return result; |
| 642 } | 653 } |
| 643 return _valid(_typeProvider.listType, new ListState(new List.from(elements))
); | 654 return _valid(_typeProvider.listType, new ListState(new List.from(elements))
); |
| 644 } | 655 } |
| 645 | 656 |
| 657 @override |
| 646 EvaluationResultImpl visitMapLiteral(MapLiteral node) { | 658 EvaluationResultImpl visitMapLiteral(MapLiteral node) { |
| 647 if (node.constKeyword == null) { | 659 if (node.constKeyword == null) { |
| 648 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); | 660 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); |
| 649 } | 661 } |
| 650 ErrorResult result = null; | 662 ErrorResult result = null; |
| 651 Map<DartObjectImpl, DartObjectImpl> map = new Map<DartObjectImpl, DartObject
Impl>(); | 663 Map<DartObjectImpl, DartObjectImpl> map = new Map<DartObjectImpl, DartObject
Impl>(); |
| 652 for (MapLiteralEntry entry in node.entries) { | 664 for (MapLiteralEntry entry in node.entries) { |
| 653 EvaluationResultImpl keyResult = entry.key.accept(this); | 665 EvaluationResultImpl keyResult = entry.key.accept(this); |
| 654 EvaluationResultImpl valueResult = entry.value.accept(this); | 666 EvaluationResultImpl valueResult = entry.value.accept(this); |
| 655 result = _union(result, keyResult); | 667 result = _union(result, keyResult); |
| 656 result = _union(result, valueResult); | 668 result = _union(result, valueResult); |
| 657 if (keyResult is ValidResult && valueResult is ValidResult) { | 669 if (keyResult is ValidResult && valueResult is ValidResult) { |
| 658 map[keyResult.value] = valueResult.value; | 670 map[keyResult.value] = valueResult.value; |
| 659 } | 671 } |
| 660 } | 672 } |
| 661 if (result != null) { | 673 if (result != null) { |
| 662 return result; | 674 return result; |
| 663 } | 675 } |
| 664 return _valid(_typeProvider.mapType, new MapState(map)); | 676 return _valid(_typeProvider.mapType, new MapState(map)); |
| 665 } | 677 } |
| 666 | 678 |
| 679 @override |
| 667 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { | 680 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { |
| 668 Element element = node.methodName.staticElement; | 681 Element element = node.methodName.staticElement; |
| 669 if (element is FunctionElement) { | 682 if (element is FunctionElement) { |
| 670 FunctionElement function = element; | 683 FunctionElement function = element; |
| 671 if (function.name == "identical") { | 684 if (function.name == "identical") { |
| 672 NodeList<Expression> arguments = node.argumentList.arguments; | 685 NodeList<Expression> arguments = node.argumentList.arguments; |
| 673 if (arguments.length == 2) { | 686 if (arguments.length == 2) { |
| 674 Element enclosingElement = function.enclosingElement; | 687 Element enclosingElement = function.enclosingElement; |
| 675 if (enclosingElement is CompilationUnitElement) { | 688 if (enclosingElement is CompilationUnitElement) { |
| 676 LibraryElement library = enclosingElement.library; | 689 LibraryElement library = enclosingElement.library; |
| 677 if (library.isDartCore) { | 690 if (library.isDartCore) { |
| 678 EvaluationResultImpl leftArgument = arguments[0].accept(this); | 691 EvaluationResultImpl leftArgument = arguments[0].accept(this); |
| 679 EvaluationResultImpl rightArgument = arguments[1].accept(this); | 692 EvaluationResultImpl rightArgument = arguments[1].accept(this); |
| 680 return leftArgument.equalEqual(_typeProvider, node, rightArgument)
; | 693 return leftArgument.equalEqual(_typeProvider, node, rightArgument)
; |
| 681 } | 694 } |
| 682 } | 695 } |
| 683 } | 696 } |
| 684 } | 697 } |
| 685 } | 698 } |
| 686 // TODO(brianwilkerson) Figure out which error to report. | 699 // TODO(brianwilkerson) Figure out which error to report. |
| 687 return _error(node, null); | 700 return _error(node, null); |
| 688 } | 701 } |
| 689 | 702 |
| 703 @override |
| 690 EvaluationResultImpl visitNamedExpression(NamedExpression node) => node.expres
sion.accept(this); | 704 EvaluationResultImpl visitNamedExpression(NamedExpression node) => node.expres
sion.accept(this); |
| 691 | 705 |
| 706 @override |
| 692 EvaluationResultImpl visitNode(AstNode node) => _error(node, null); | 707 EvaluationResultImpl visitNode(AstNode node) => _error(node, null); |
| 693 | 708 |
| 709 @override |
| 694 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul
l2); | 710 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul
l2); |
| 695 | 711 |
| 712 @override |
| 696 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); | 713 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); |
| 697 | 714 |
| 715 @override |
| 698 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) { | 716 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 699 // validate prefix | 717 // validate prefix |
| 700 SimpleIdentifier prefixNode = node.prefix; | 718 SimpleIdentifier prefixNode = node.prefix; |
| 701 Element prefixElement = prefixNode.staticElement; | 719 Element prefixElement = prefixNode.staticElement; |
| 702 if (prefixElement is! PrefixElement) { | 720 if (prefixElement is! PrefixElement) { |
| 703 EvaluationResultImpl prefixResult = prefixNode.accept(this); | 721 EvaluationResultImpl prefixResult = prefixNode.accept(this); |
| 704 if (prefixResult is! ValidResult) { | 722 if (prefixResult is! ValidResult) { |
| 705 return _error(node, null); | 723 return _error(node, null); |
| 706 } | 724 } |
| 707 } | 725 } |
| 708 // validate prefixed identifier | 726 // validate prefixed identifier |
| 709 return _getConstantValue(node, node.staticElement); | 727 return _getConstantValue(node, node.staticElement); |
| 710 } | 728 } |
| 711 | 729 |
| 730 @override |
| 712 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { | 731 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { |
| 713 EvaluationResultImpl operand = node.operand.accept(this); | 732 EvaluationResultImpl operand = node.operand.accept(this); |
| 714 if (operand is ValidResult && operand.isNull) { | 733 if (operand is ValidResult && operand.isNull) { |
| 715 return _error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); | 734 return _error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); |
| 716 } | 735 } |
| 717 while (true) { | 736 while (true) { |
| 718 if (node.operator.type == TokenType.BANG) { | 737 if (node.operator.type == TokenType.BANG) { |
| 719 return operand.logicalNot(_typeProvider, node); | 738 return operand.logicalNot(_typeProvider, node); |
| 720 } else if (node.operator.type == TokenType.TILDE) { | 739 } else if (node.operator.type == TokenType.TILDE) { |
| 721 return operand.bitNot(_typeProvider, node); | 740 return operand.bitNot(_typeProvider, node); |
| 722 } else if (node.operator.type == TokenType.MINUS) { | 741 } else if (node.operator.type == TokenType.MINUS) { |
| 723 return operand.negated(_typeProvider, node); | 742 return operand.negated(_typeProvider, node); |
| 724 } else { | 743 } else { |
| 725 // TODO(brianwilkerson) Figure out which error to report. | 744 // TODO(brianwilkerson) Figure out which error to report. |
| 726 return _error(node, null); | 745 return _error(node, null); |
| 727 } | 746 } |
| 728 break; | 747 break; |
| 729 } | 748 } |
| 730 } | 749 } |
| 731 | 750 |
| 751 @override |
| 732 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => _getConstantV
alue(node, node.propertyName.staticElement); | 752 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => _getConstantV
alue(node, node.propertyName.staticElement); |
| 733 | 753 |
| 754 @override |
| 734 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => _getConst
antValue(node, node.staticElement); | 755 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => _getConst
antValue(node, node.staticElement); |
| 735 | 756 |
| 757 @override |
| 736 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => _va
lid(_typeProvider.stringType, new StringState(node.value)); | 758 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => _va
lid(_typeProvider.stringType, new StringState(node.value)); |
| 737 | 759 |
| 760 @override |
| 738 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { | 761 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { |
| 739 EvaluationResultImpl result = null; | 762 EvaluationResultImpl result = null; |
| 740 for (InterpolationElement element in node.elements) { | 763 for (InterpolationElement element in node.elements) { |
| 741 if (result == null) { | 764 if (result == null) { |
| 742 result = element.accept(this); | 765 result = element.accept(this); |
| 743 } else { | 766 } else { |
| 744 result = result.concatenate(_typeProvider, node, element.accept(this)); | 767 result = result.concatenate(_typeProvider, node, element.accept(this)); |
| 745 } | 768 } |
| 746 } | 769 } |
| 747 return result; | 770 return result; |
| 748 } | 771 } |
| 749 | 772 |
| 773 @override |
| 750 EvaluationResultImpl visitSymbolLiteral(SymbolLiteral node) { | 774 EvaluationResultImpl visitSymbolLiteral(SymbolLiteral node) { |
| 751 JavaStringBuilder builder = new JavaStringBuilder(); | 775 JavaStringBuilder builder = new JavaStringBuilder(); |
| 752 List<Token> components = node.components; | 776 List<Token> components = node.components; |
| 753 for (int i = 0; i < components.length; i++) { | 777 for (int i = 0; i < components.length; i++) { |
| 754 if (i > 0) { | 778 if (i > 0) { |
| 755 builder.appendChar(0x2E); | 779 builder.appendChar(0x2E); |
| 756 } | 780 } |
| 757 builder.append(components[i].lexeme); | 781 builder.append(components[i].lexeme); |
| 758 } | 782 } |
| 759 return _valid(_typeProvider.symbolType, new SymbolState(builder.toString()))
; | 783 return _valid(_typeProvider.symbolType, new SymbolState(builder.toString()))
; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 * objects. | 1077 * objects. |
| 1054 * | 1078 * |
| 1055 * @param firstResult the first set of results being merged | 1079 * @param firstResult the first set of results being merged |
| 1056 * @param secondResult the second set of results being merged | 1080 * @param secondResult the second set of results being merged |
| 1057 */ | 1081 */ |
| 1058 ErrorResult.con2(ErrorResult firstResult, ErrorResult secondResult) { | 1082 ErrorResult.con2(ErrorResult firstResult, ErrorResult secondResult) { |
| 1059 _errors.addAll(firstResult._errors); | 1083 _errors.addAll(firstResult._errors); |
| 1060 _errors.addAll(secondResult._errors); | 1084 _errors.addAll(secondResult._errors); |
| 1061 } | 1085 } |
| 1062 | 1086 |
| 1087 @override |
| 1063 EvaluationResultImpl add(TypeProvider typeProvider, BinaryExpression node, Eva
luationResultImpl rightOperand) => rightOperand.addToError(node, this); | 1088 EvaluationResultImpl add(TypeProvider typeProvider, BinaryExpression node, Eva
luationResultImpl rightOperand) => rightOperand.addToError(node, this); |
| 1064 | 1089 |
| 1090 @override |
| 1065 EvaluationResultImpl applyBooleanConversion(TypeProvider typeProvider, AstNode
node) => this; | 1091 EvaluationResultImpl applyBooleanConversion(TypeProvider typeProvider, AstNode
node) => this; |
| 1066 | 1092 |
| 1093 @override |
| 1067 EvaluationResultImpl bitAnd(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitAndError(node, this); | 1094 EvaluationResultImpl bitAnd(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitAndError(node, this); |
| 1068 | 1095 |
| 1096 @override |
| 1069 EvaluationResultImpl bitNot(TypeProvider typeProvider, Expression node) => thi
s; | 1097 EvaluationResultImpl bitNot(TypeProvider typeProvider, Expression node) => thi
s; |
| 1070 | 1098 |
| 1099 @override |
| 1071 EvaluationResultImpl bitOr(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.bitOrError(node, this); | 1100 EvaluationResultImpl bitOr(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.bitOrError(node, this); |
| 1072 | 1101 |
| 1102 @override |
| 1073 EvaluationResultImpl bitXor(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitXorError(node, this); | 1103 EvaluationResultImpl bitXor(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitXorError(node, this); |
| 1074 | 1104 |
| 1105 @override |
| 1075 EvaluationResultImpl concatenate(TypeProvider typeProvider, Expression node, E
valuationResultImpl rightOperand) => rightOperand.concatenateError(node, this); | 1106 EvaluationResultImpl concatenate(TypeProvider typeProvider, Expression node, E
valuationResultImpl rightOperand) => rightOperand.concatenateError(node, this); |
| 1076 | 1107 |
| 1108 @override |
| 1077 EvaluationResultImpl divide(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.divideError(node, this); | 1109 EvaluationResultImpl divide(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.divideError(node, this); |
| 1078 | 1110 |
| 1111 @override |
| 1079 EvaluationResultImpl equalEqual(TypeProvider typeProvider, Expression node, Ev
aluationResultImpl rightOperand) => rightOperand.equalEqualError(node, this); | 1112 EvaluationResultImpl equalEqual(TypeProvider typeProvider, Expression node, Ev
aluationResultImpl rightOperand) => rightOperand.equalEqualError(node, this); |
| 1080 | 1113 |
| 1114 @override |
| 1081 bool equalValues(TypeProvider typeProvider, EvaluationResultImpl result) => fa
lse; | 1115 bool equalValues(TypeProvider typeProvider, EvaluationResultImpl result) => fa
lse; |
| 1082 | 1116 |
| 1083 List<ErrorResult_ErrorData> get errorData => _errors; | 1117 List<ErrorResult_ErrorData> get errorData => _errors; |
| 1084 | 1118 |
| 1119 @override |
| 1085 EvaluationResultImpl greaterThan(TypeProvider typeProvider, BinaryExpression n
ode, EvaluationResultImpl rightOperand) => rightOperand.greaterThanError(node, t
his); | 1120 EvaluationResultImpl greaterThan(TypeProvider typeProvider, BinaryExpression n
ode, EvaluationResultImpl rightOperand) => rightOperand.greaterThanError(node, t
his); |
| 1086 | 1121 |
| 1122 @override |
| 1087 EvaluationResultImpl greaterThanOrEqual(TypeProvider typeProvider, BinaryExpre
ssion node, EvaluationResultImpl rightOperand) => rightOperand.greaterThanOrEqua
lError(node, this); | 1123 EvaluationResultImpl greaterThanOrEqual(TypeProvider typeProvider, BinaryExpre
ssion node, EvaluationResultImpl rightOperand) => rightOperand.greaterThanOrEqua
lError(node, this); |
| 1088 | 1124 |
| 1125 @override |
| 1089 EvaluationResultImpl integerDivide(TypeProvider typeProvider, BinaryExpression
node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideError(nod
e, this); | 1126 EvaluationResultImpl integerDivide(TypeProvider typeProvider, BinaryExpression
node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideError(nod
e, this); |
| 1090 | 1127 |
| 1128 @override |
| 1091 EvaluationResultImpl integerDivideValid(TypeProvider typeProvider, BinaryExpre
ssion node, ValidResult leftOperand) => this; | 1129 EvaluationResultImpl integerDivideValid(TypeProvider typeProvider, BinaryExpre
ssion node, ValidResult leftOperand) => this; |
| 1092 | 1130 |
| 1131 @override |
| 1093 EvaluationResultImpl lessThan(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.lessThanError(node, this); | 1132 EvaluationResultImpl lessThan(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.lessThanError(node, this); |
| 1094 | 1133 |
| 1134 @override |
| 1095 EvaluationResultImpl lessThanOrEqual(TypeProvider typeProvider, BinaryExpressi
on node, EvaluationResultImpl rightOperand) => rightOperand.lessThanOrEqualError
(node, this); | 1135 EvaluationResultImpl lessThanOrEqual(TypeProvider typeProvider, BinaryExpressi
on node, EvaluationResultImpl rightOperand) => rightOperand.lessThanOrEqualError
(node, this); |
| 1096 | 1136 |
| 1137 @override |
| 1097 EvaluationResultImpl logicalAnd(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.logicalAndError(node, thi
s); | 1138 EvaluationResultImpl logicalAnd(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.logicalAndError(node, thi
s); |
| 1098 | 1139 |
| 1140 @override |
| 1099 EvaluationResultImpl logicalNot(TypeProvider typeProvider, Expression node) =>
this; | 1141 EvaluationResultImpl logicalNot(TypeProvider typeProvider, Expression node) =>
this; |
| 1100 | 1142 |
| 1143 @override |
| 1101 EvaluationResultImpl logicalOr(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.logicalOrError(node, this)
; | 1144 EvaluationResultImpl logicalOr(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.logicalOrError(node, this)
; |
| 1102 | 1145 |
| 1146 @override |
| 1103 EvaluationResultImpl minus(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.minusError(node, this); | 1147 EvaluationResultImpl minus(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.minusError(node, this); |
| 1104 | 1148 |
| 1149 @override |
| 1105 EvaluationResultImpl negated(TypeProvider typeProvider, Expression node) => th
is; | 1150 EvaluationResultImpl negated(TypeProvider typeProvider, Expression node) => th
is; |
| 1106 | 1151 |
| 1152 @override |
| 1107 EvaluationResultImpl notEqual(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.notEqualError(node, this); | 1153 EvaluationResultImpl notEqual(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.notEqualError(node, this); |
| 1108 | 1154 |
| 1155 @override |
| 1109 EvaluationResultImpl performToString(TypeProvider typeProvider, AstNode node)
=> this; | 1156 EvaluationResultImpl performToString(TypeProvider typeProvider, AstNode node)
=> this; |
| 1110 | 1157 |
| 1158 @override |
| 1111 EvaluationResultImpl remainder(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.remainderError(node, this)
; | 1159 EvaluationResultImpl remainder(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.remainderError(node, this)
; |
| 1112 | 1160 |
| 1161 @override |
| 1113 EvaluationResultImpl shiftLeft(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.shiftLeftError(node, this)
; | 1162 EvaluationResultImpl shiftLeft(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.shiftLeftError(node, this)
; |
| 1114 | 1163 |
| 1164 @override |
| 1115 EvaluationResultImpl shiftRight(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.shiftRightError(node, thi
s); | 1165 EvaluationResultImpl shiftRight(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.shiftRightError(node, thi
s); |
| 1116 | 1166 |
| 1167 @override |
| 1117 EvaluationResultImpl times(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.timesError(node, this); | 1168 EvaluationResultImpl times(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.timesError(node, this); |
| 1118 | 1169 |
| 1170 @override |
| 1119 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 1171 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
| 1120 | 1172 |
| 1173 @override |
| 1121 EvaluationResultImpl addToValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; | 1174 EvaluationResultImpl addToValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; |
| 1122 | 1175 |
| 1176 @override |
| 1123 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); | 1177 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); |
| 1124 | 1178 |
| 1179 @override |
| 1125 EvaluationResultImpl bitAndValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; | 1180 EvaluationResultImpl bitAndValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; |
| 1126 | 1181 |
| 1182 @override |
| 1127 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 1183 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
| 1128 | 1184 |
| 1185 @override |
| 1129 EvaluationResultImpl bitOrValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; | 1186 EvaluationResultImpl bitOrValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; |
| 1130 | 1187 |
| 1188 @override |
| 1131 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); | 1189 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); |
| 1132 | 1190 |
| 1191 @override |
| 1133 EvaluationResultImpl bitXorValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; | 1192 EvaluationResultImpl bitXorValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; |
| 1134 | 1193 |
| 1194 @override |
| 1135 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 1195 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
| 1136 | 1196 |
| 1197 @override |
| 1137 EvaluationResultImpl concatenateValid(TypeProvider typeProvider, Expression no
de, ValidResult leftOperand) => this; | 1198 EvaluationResultImpl concatenateValid(TypeProvider typeProvider, Expression no
de, ValidResult leftOperand) => this; |
| 1138 | 1199 |
| 1200 @override |
| 1139 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); | 1201 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => new ErrorResult.con2(this, leftOperand); |
| 1140 | 1202 |
| 1203 @override |
| 1141 EvaluationResultImpl divideValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; | 1204 EvaluationResultImpl divideValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) => this; |
| 1142 | 1205 |
| 1206 @override |
| 1143 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> new ErrorResult.con2(this, leftOperand); | 1207 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> new ErrorResult.con2(this, leftOperand); |
| 1144 | 1208 |
| 1209 @override |
| 1145 EvaluationResultImpl equalEqualValid(TypeProvider typeProvider, Expression nod
e, ValidResult leftOperand) => this; | 1210 EvaluationResultImpl equalEqualValid(TypeProvider typeProvider, Expression nod
e, ValidResult leftOperand) => this; |
| 1146 | 1211 |
| 1212 @override |
| 1147 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => new ErrorResult.con2(this, leftOperand); | 1213 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => new ErrorResult.con2(this, leftOperand); |
| 1148 | 1214 |
| 1215 @override |
| 1149 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => new ErrorResult.con2(this, leftOperand); | 1216 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => new ErrorResult.con2(this, leftOperand); |
| 1150 | 1217 |
| 1218 @override |
| 1151 EvaluationResultImpl greaterThanOrEqualValid(TypeProvider typeProvider, Binary
Expression node, ValidResult leftOperand) => this; | 1219 EvaluationResultImpl greaterThanOrEqualValid(TypeProvider typeProvider, Binary
Expression node, ValidResult leftOperand) => this; |
| 1152 | 1220 |
| 1221 @override |
| 1153 EvaluationResultImpl greaterThanValid(TypeProvider typeProvider, BinaryExpress
ion node, ValidResult leftOperand) => this; | 1222 EvaluationResultImpl greaterThanValid(TypeProvider typeProvider, BinaryExpress
ion node, ValidResult leftOperand) => this; |
| 1154 | 1223 |
| 1224 @override |
| 1155 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => new ErrorResult.con2(this, leftOperand); | 1225 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => new ErrorResult.con2(this, leftOperand); |
| 1156 | 1226 |
| 1227 @override |
| 1157 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => new ErrorResult.con2(this, leftOperand); | 1228 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => new ErrorResult.con2(this, leftOperand); |
| 1158 | 1229 |
| 1230 @override |
| 1159 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => new ErrorResult.con2(this, leftOperand); | 1231 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => new ErrorResult.con2(this, leftOperand); |
| 1160 | 1232 |
| 1233 @override |
| 1161 EvaluationResultImpl lessThanOrEqualValid(TypeProvider typeProvider, BinaryExp
ression node, ValidResult leftOperand) => this; | 1234 EvaluationResultImpl lessThanOrEqualValid(TypeProvider typeProvider, BinaryExp
ression node, ValidResult leftOperand) => this; |
| 1162 | 1235 |
| 1236 @override |
| 1163 EvaluationResultImpl lessThanValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) => this; | 1237 EvaluationResultImpl lessThanValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) => this; |
| 1164 | 1238 |
| 1239 @override |
| 1165 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); | 1240 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); |
| 1166 | 1241 |
| 1242 @override |
| 1167 EvaluationResultImpl logicalAndValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) => this; | 1243 EvaluationResultImpl logicalAndValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) => this; |
| 1168 | 1244 |
| 1245 @override |
| 1169 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); | 1246 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); |
| 1170 | 1247 |
| 1248 @override |
| 1171 EvaluationResultImpl logicalOrValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; | 1249 EvaluationResultImpl logicalOrValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; |
| 1172 | 1250 |
| 1251 @override |
| 1173 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 1252 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
| 1174 | 1253 |
| 1254 @override |
| 1175 EvaluationResultImpl minusValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; | 1255 EvaluationResultImpl minusValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; |
| 1176 | 1256 |
| 1257 @override |
| 1177 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => new ErrorResult.con2(this, leftOperand); | 1258 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => new ErrorResult.con2(this, leftOperand); |
| 1178 | 1259 |
| 1260 @override |
| 1179 EvaluationResultImpl notEqualValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) => this; | 1261 EvaluationResultImpl notEqualValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) => this; |
| 1180 | 1262 |
| 1263 @override |
| 1181 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); | 1264 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); |
| 1182 | 1265 |
| 1266 @override |
| 1183 EvaluationResultImpl remainderValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; | 1267 EvaluationResultImpl remainderValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; |
| 1184 | 1268 |
| 1269 @override |
| 1185 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); | 1270 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => new ErrorResult.con2(this, leftOperand); |
| 1186 | 1271 |
| 1272 @override |
| 1187 EvaluationResultImpl shiftLeftValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; | 1273 EvaluationResultImpl shiftLeftValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) => this; |
| 1188 | 1274 |
| 1275 @override |
| 1189 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); | 1276 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); |
| 1190 | 1277 |
| 1278 @override |
| 1191 EvaluationResultImpl shiftRightValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) => this; | 1279 EvaluationResultImpl shiftRightValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) => this; |
| 1192 | 1280 |
| 1281 @override |
| 1193 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 1282 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
| 1194 | 1283 |
| 1284 @override |
| 1195 EvaluationResultImpl timesValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; | 1285 EvaluationResultImpl timesValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) => this; |
| 1196 } | 1286 } |
| 1197 | 1287 |
| 1198 class ErrorResult_ErrorData { | 1288 class ErrorResult_ErrorData { |
| 1199 /** | 1289 /** |
| 1200 * The node against which the error should be reported. | 1290 * The node against which the error should be reported. |
| 1201 */ | 1291 */ |
| 1202 final AstNode node; | 1292 final AstNode node; |
| 1203 | 1293 |
| 1204 /** | 1294 /** |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 * | 1473 * |
| 1384 * @param source the element representing the variable whose initializer will
be visited | 1474 * @param source the element representing the variable whose initializer will
be visited |
| 1385 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables | 1475 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables |
| 1386 * (tails) in their initializers | 1476 * (tails) in their initializers |
| 1387 */ | 1477 */ |
| 1388 ReferenceFinder(VariableElement source, DirectedGraph<VariableElement> referen
ceGraph) { | 1478 ReferenceFinder(VariableElement source, DirectedGraph<VariableElement> referen
ceGraph) { |
| 1389 this._source = source; | 1479 this._source = source; |
| 1390 this._referenceGraph = referenceGraph; | 1480 this._referenceGraph = referenceGraph; |
| 1391 } | 1481 } |
| 1392 | 1482 |
| 1483 @override |
| 1393 Object visitSimpleIdentifier(SimpleIdentifier node) { | 1484 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 1394 Element element = node.staticElement; | 1485 Element element = node.staticElement; |
| 1395 if (element is PropertyAccessorElement) { | 1486 if (element is PropertyAccessorElement) { |
| 1396 element = (element as PropertyAccessorElement).variable; | 1487 element = (element as PropertyAccessorElement).variable; |
| 1397 } | 1488 } |
| 1398 if (element is VariableElement) { | 1489 if (element is VariableElement) { |
| 1399 VariableElement variable = element as VariableElement; | 1490 VariableElement variable = element as VariableElement; |
| 1400 if (variable.isConst) { | 1491 if (variable.isConst) { |
| 1401 _referenceGraph.addEdge(_source, variable); | 1492 _referenceGraph.addEdge(_source, variable); |
| 1402 } | 1493 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1415 */ | 1506 */ |
| 1416 final DartObjectImpl value; | 1507 final DartObjectImpl value; |
| 1417 | 1508 |
| 1418 /** | 1509 /** |
| 1419 * Initialize a newly created result to represent the given value. | 1510 * Initialize a newly created result to represent the given value. |
| 1420 * | 1511 * |
| 1421 * @param value the value of the expression | 1512 * @param value the value of the expression |
| 1422 */ | 1513 */ |
| 1423 ValidResult(this.value); | 1514 ValidResult(this.value); |
| 1424 | 1515 |
| 1516 @override |
| 1425 EvaluationResultImpl add(TypeProvider typeProvider, BinaryExpression node, Eva
luationResultImpl rightOperand) => rightOperand.addToValid(typeProvider, node, t
his); | 1517 EvaluationResultImpl add(TypeProvider typeProvider, BinaryExpression node, Eva
luationResultImpl rightOperand) => rightOperand.addToValid(typeProvider, node, t
his); |
| 1426 | 1518 |
| 1427 /** | 1519 /** |
| 1428 * Return the result of applying boolean conversion to this result. | 1520 * Return the result of applying boolean conversion to this result. |
| 1429 * | 1521 * |
| 1430 * @param node the node against which errors should be reported | 1522 * @param node the node against which errors should be reported |
| 1431 * @return the result of applying boolean conversion to the given value | 1523 * @return the result of applying boolean conversion to the given value |
| 1432 */ | 1524 */ |
| 1525 @override |
| 1433 EvaluationResultImpl applyBooleanConversion(TypeProvider typeProvider, AstNode
node) { | 1526 EvaluationResultImpl applyBooleanConversion(TypeProvider typeProvider, AstNode
node) { |
| 1434 try { | 1527 try { |
| 1435 return _valueOf(value.convertToBool(typeProvider)); | 1528 return _valueOf(value.convertToBool(typeProvider)); |
| 1436 } on EvaluationException catch (exception) { | 1529 } on EvaluationException catch (exception) { |
| 1437 return _error(node, exception.errorCode); | 1530 return _error(node, exception.errorCode); |
| 1438 } | 1531 } |
| 1439 } | 1532 } |
| 1440 | 1533 |
| 1534 @override |
| 1441 EvaluationResultImpl bitAnd(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitAndValid(typeProvider, nod
e, this); | 1535 EvaluationResultImpl bitAnd(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitAndValid(typeProvider, nod
e, this); |
| 1442 | 1536 |
| 1537 @override |
| 1443 EvaluationResultImpl bitNot(TypeProvider typeProvider, Expression node) { | 1538 EvaluationResultImpl bitNot(TypeProvider typeProvider, Expression node) { |
| 1444 try { | 1539 try { |
| 1445 return _valueOf(value.bitNot(typeProvider)); | 1540 return _valueOf(value.bitNot(typeProvider)); |
| 1446 } on EvaluationException catch (exception) { | 1541 } on EvaluationException catch (exception) { |
| 1447 return _error(node, exception.errorCode); | 1542 return _error(node, exception.errorCode); |
| 1448 } | 1543 } |
| 1449 } | 1544 } |
| 1450 | 1545 |
| 1546 @override |
| 1451 EvaluationResultImpl bitOr(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.bitOrValid(typeProvider, node,
this); | 1547 EvaluationResultImpl bitOr(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.bitOrValid(typeProvider, node,
this); |
| 1452 | 1548 |
| 1549 @override |
| 1453 EvaluationResultImpl bitXor(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitXorValid(typeProvider, nod
e, this); | 1550 EvaluationResultImpl bitXor(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.bitXorValid(typeProvider, nod
e, this); |
| 1454 | 1551 |
| 1552 @override |
| 1455 EvaluationResultImpl concatenate(TypeProvider typeProvider, Expression node, E
valuationResultImpl rightOperand) => rightOperand.concatenateValid(typeProvider,
node, this); | 1553 EvaluationResultImpl concatenate(TypeProvider typeProvider, Expression node, E
valuationResultImpl rightOperand) => rightOperand.concatenateValid(typeProvider,
node, this); |
| 1456 | 1554 |
| 1555 @override |
| 1457 EvaluationResultImpl divide(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.divideValid(typeProvider, nod
e, this); | 1556 EvaluationResultImpl divide(TypeProvider typeProvider, BinaryExpression node,
EvaluationResultImpl rightOperand) => rightOperand.divideValid(typeProvider, nod
e, this); |
| 1458 | 1557 |
| 1558 @override |
| 1459 EvaluationResultImpl equalEqual(TypeProvider typeProvider, Expression node, Ev
aluationResultImpl rightOperand) => rightOperand.equalEqualValid(typeProvider, n
ode, this); | 1559 EvaluationResultImpl equalEqual(TypeProvider typeProvider, Expression node, Ev
aluationResultImpl rightOperand) => rightOperand.equalEqualValid(typeProvider, n
ode, this); |
| 1460 | 1560 |
| 1561 @override |
| 1461 bool equalValues(TypeProvider typeProvider, EvaluationResultImpl result) { | 1562 bool equalValues(TypeProvider typeProvider, EvaluationResultImpl result) { |
| 1462 if (result is! ValidResult) { | 1563 if (result is! ValidResult) { |
| 1463 return false; | 1564 return false; |
| 1464 } | 1565 } |
| 1465 return value == (result as ValidResult).value; | 1566 return value == (result as ValidResult).value; |
| 1466 } | 1567 } |
| 1467 | 1568 |
| 1569 @override |
| 1468 EvaluationResultImpl greaterThan(TypeProvider typeProvider, BinaryExpression n
ode, EvaluationResultImpl rightOperand) => rightOperand.greaterThanValid(typePro
vider, node, this); | 1570 EvaluationResultImpl greaterThan(TypeProvider typeProvider, BinaryExpression n
ode, EvaluationResultImpl rightOperand) => rightOperand.greaterThanValid(typePro
vider, node, this); |
| 1469 | 1571 |
| 1572 @override |
| 1470 EvaluationResultImpl greaterThanOrEqual(TypeProvider typeProvider, BinaryExpre
ssion node, EvaluationResultImpl rightOperand) => rightOperand.greaterThanOrEqua
lValid(typeProvider, node, this); | 1573 EvaluationResultImpl greaterThanOrEqual(TypeProvider typeProvider, BinaryExpre
ssion node, EvaluationResultImpl rightOperand) => rightOperand.greaterThanOrEqua
lValid(typeProvider, node, this); |
| 1471 | 1574 |
| 1575 @override |
| 1472 EvaluationResultImpl integerDivide(TypeProvider typeProvider, BinaryExpression
node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideValid(typ
eProvider, node, this); | 1576 EvaluationResultImpl integerDivide(TypeProvider typeProvider, BinaryExpression
node, EvaluationResultImpl rightOperand) => rightOperand.integerDivideValid(typ
eProvider, node, this); |
| 1473 | 1577 |
| 1474 /** | 1578 /** |
| 1475 * Return `true` if this object represents an object whose type is 'bool'. | 1579 * Return `true` if this object represents an object whose type is 'bool'. |
| 1476 * | 1580 * |
| 1477 * @return `true` if this object represents a boolean value | 1581 * @return `true` if this object represents a boolean value |
| 1478 */ | 1582 */ |
| 1479 bool get isBool => value.isBool; | 1583 bool get isBool => value.isBool; |
| 1480 | 1584 |
| 1481 /** | 1585 /** |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1507 */ | 1611 */ |
| 1508 bool get isTrue => value.isTrue; | 1612 bool get isTrue => value.isTrue; |
| 1509 | 1613 |
| 1510 /** | 1614 /** |
| 1511 * Return `true` if this object represents an instance of a user-defined class
. | 1615 * Return `true` if this object represents an instance of a user-defined class
. |
| 1512 * | 1616 * |
| 1513 * @return `true` if this object represents an instance of a user-defined clas
s | 1617 * @return `true` if this object represents an instance of a user-defined clas
s |
| 1514 */ | 1618 */ |
| 1515 bool get isUserDefinedObject => value.isUserDefinedObject; | 1619 bool get isUserDefinedObject => value.isUserDefinedObject; |
| 1516 | 1620 |
| 1621 @override |
| 1517 EvaluationResultImpl lessThan(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.lessThanValid(typeProvider,
node, this); | 1622 EvaluationResultImpl lessThan(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.lessThanValid(typeProvider,
node, this); |
| 1518 | 1623 |
| 1624 @override |
| 1519 EvaluationResultImpl lessThanOrEqual(TypeProvider typeProvider, BinaryExpressi
on node, EvaluationResultImpl rightOperand) => rightOperand.lessThanOrEqualValid
(typeProvider, node, this); | 1625 EvaluationResultImpl lessThanOrEqual(TypeProvider typeProvider, BinaryExpressi
on node, EvaluationResultImpl rightOperand) => rightOperand.lessThanOrEqualValid
(typeProvider, node, this); |
| 1520 | 1626 |
| 1627 @override |
| 1521 EvaluationResultImpl logicalAnd(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.logicalAndValid(typeProvi
der, node, this); | 1628 EvaluationResultImpl logicalAnd(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.logicalAndValid(typeProvi
der, node, this); |
| 1522 | 1629 |
| 1630 @override |
| 1523 EvaluationResultImpl logicalNot(TypeProvider typeProvider, Expression node) { | 1631 EvaluationResultImpl logicalNot(TypeProvider typeProvider, Expression node) { |
| 1524 try { | 1632 try { |
| 1525 return _valueOf(value.logicalNot(typeProvider)); | 1633 return _valueOf(value.logicalNot(typeProvider)); |
| 1526 } on EvaluationException catch (exception) { | 1634 } on EvaluationException catch (exception) { |
| 1527 return _error(node, exception.errorCode); | 1635 return _error(node, exception.errorCode); |
| 1528 } | 1636 } |
| 1529 } | 1637 } |
| 1530 | 1638 |
| 1639 @override |
| 1531 EvaluationResultImpl logicalOr(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.logicalOrValid(typeProvide
r, node, this); | 1640 EvaluationResultImpl logicalOr(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.logicalOrValid(typeProvide
r, node, this); |
| 1532 | 1641 |
| 1642 @override |
| 1533 EvaluationResultImpl minus(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.minusValid(typeProvider, node,
this); | 1643 EvaluationResultImpl minus(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.minusValid(typeProvider, node,
this); |
| 1534 | 1644 |
| 1645 @override |
| 1535 EvaluationResultImpl negated(TypeProvider typeProvider, Expression node) { | 1646 EvaluationResultImpl negated(TypeProvider typeProvider, Expression node) { |
| 1536 try { | 1647 try { |
| 1537 return _valueOf(value.negated(typeProvider)); | 1648 return _valueOf(value.negated(typeProvider)); |
| 1538 } on EvaluationException catch (exception) { | 1649 } on EvaluationException catch (exception) { |
| 1539 return _error(node, exception.errorCode); | 1650 return _error(node, exception.errorCode); |
| 1540 } | 1651 } |
| 1541 } | 1652 } |
| 1542 | 1653 |
| 1654 @override |
| 1543 EvaluationResultImpl notEqual(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.notEqualValid(typeProvider,
node, this); | 1655 EvaluationResultImpl notEqual(TypeProvider typeProvider, BinaryExpression node
, EvaluationResultImpl rightOperand) => rightOperand.notEqualValid(typeProvider,
node, this); |
| 1544 | 1656 |
| 1657 @override |
| 1545 EvaluationResultImpl performToString(TypeProvider typeProvider, AstNode node)
{ | 1658 EvaluationResultImpl performToString(TypeProvider typeProvider, AstNode node)
{ |
| 1546 try { | 1659 try { |
| 1547 return _valueOf(value.performToString(typeProvider)); | 1660 return _valueOf(value.performToString(typeProvider)); |
| 1548 } on EvaluationException catch (exception) { | 1661 } on EvaluationException catch (exception) { |
| 1549 return _error(node, exception.errorCode); | 1662 return _error(node, exception.errorCode); |
| 1550 } | 1663 } |
| 1551 } | 1664 } |
| 1552 | 1665 |
| 1666 @override |
| 1553 EvaluationResultImpl remainder(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.remainderValid(typeProvide
r, node, this); | 1667 EvaluationResultImpl remainder(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.remainderValid(typeProvide
r, node, this); |
| 1554 | 1668 |
| 1669 @override |
| 1555 EvaluationResultImpl shiftLeft(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.shiftLeftValid(typeProvide
r, node, this); | 1670 EvaluationResultImpl shiftLeft(TypeProvider typeProvider, BinaryExpression nod
e, EvaluationResultImpl rightOperand) => rightOperand.shiftLeftValid(typeProvide
r, node, this); |
| 1556 | 1671 |
| 1672 @override |
| 1557 EvaluationResultImpl shiftRight(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.shiftRightValid(typeProvi
der, node, this); | 1673 EvaluationResultImpl shiftRight(TypeProvider typeProvider, BinaryExpression no
de, EvaluationResultImpl rightOperand) => rightOperand.shiftRightValid(typeProvi
der, node, this); |
| 1558 | 1674 |
| 1675 @override |
| 1559 EvaluationResultImpl times(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.timesValid(typeProvider, node,
this); | 1676 EvaluationResultImpl times(TypeProvider typeProvider, BinaryExpression node, E
valuationResultImpl rightOperand) => rightOperand.timesValid(typeProvider, node,
this); |
| 1560 | 1677 |
| 1678 @override |
| 1561 String toString() { | 1679 String toString() { |
| 1562 if (value == null) { | 1680 if (value == null) { |
| 1563 return "null"; | 1681 return "null"; |
| 1564 } | 1682 } |
| 1565 return value.toString(); | 1683 return value.toString(); |
| 1566 } | 1684 } |
| 1567 | 1685 |
| 1686 @override |
| 1568 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1687 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1569 | 1688 |
| 1689 @override |
| 1570 EvaluationResultImpl addToValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { | 1690 EvaluationResultImpl addToValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { |
| 1571 try { | 1691 try { |
| 1572 return _valueOf(leftOperand.value.add(typeProvider, value)); | 1692 return _valueOf(leftOperand.value.add(typeProvider, value)); |
| 1573 } on EvaluationException catch (exception) { | 1693 } on EvaluationException catch (exception) { |
| 1574 return _error(node, exception.errorCode); | 1694 return _error(node, exception.errorCode); |
| 1575 } | 1695 } |
| 1576 } | 1696 } |
| 1577 | 1697 |
| 1698 @override |
| 1578 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1699 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1579 | 1700 |
| 1701 @override |
| 1580 EvaluationResultImpl bitAndValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { | 1702 EvaluationResultImpl bitAndValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { |
| 1581 try { | 1703 try { |
| 1582 return _valueOf(leftOperand.value.bitAnd(typeProvider, value)); | 1704 return _valueOf(leftOperand.value.bitAnd(typeProvider, value)); |
| 1583 } on EvaluationException catch (exception) { | 1705 } on EvaluationException catch (exception) { |
| 1584 return _error(node, exception.errorCode); | 1706 return _error(node, exception.errorCode); |
| 1585 } | 1707 } |
| 1586 } | 1708 } |
| 1587 | 1709 |
| 1710 @override |
| 1588 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1711 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1589 | 1712 |
| 1713 @override |
| 1590 EvaluationResultImpl bitOrValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { | 1714 EvaluationResultImpl bitOrValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { |
| 1591 try { | 1715 try { |
| 1592 return _valueOf(leftOperand.value.bitOr(typeProvider, value)); | 1716 return _valueOf(leftOperand.value.bitOr(typeProvider, value)); |
| 1593 } on EvaluationException catch (exception) { | 1717 } on EvaluationException catch (exception) { |
| 1594 return _error(node, exception.errorCode); | 1718 return _error(node, exception.errorCode); |
| 1595 } | 1719 } |
| 1596 } | 1720 } |
| 1597 | 1721 |
| 1722 @override |
| 1598 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1723 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1599 | 1724 |
| 1725 @override |
| 1600 EvaluationResultImpl bitXorValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { | 1726 EvaluationResultImpl bitXorValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { |
| 1601 try { | 1727 try { |
| 1602 return _valueOf(leftOperand.value.bitXor(typeProvider, value)); | 1728 return _valueOf(leftOperand.value.bitXor(typeProvider, value)); |
| 1603 } on EvaluationException catch (exception) { | 1729 } on EvaluationException catch (exception) { |
| 1604 return _error(node, exception.errorCode); | 1730 return _error(node, exception.errorCode); |
| 1605 } | 1731 } |
| 1606 } | 1732 } |
| 1607 | 1733 |
| 1734 @override |
| 1608 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; | 1735 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; |
| 1609 | 1736 |
| 1737 @override |
| 1610 EvaluationResultImpl concatenateValid(TypeProvider typeProvider, Expression no
de, ValidResult leftOperand) { | 1738 EvaluationResultImpl concatenateValid(TypeProvider typeProvider, Expression no
de, ValidResult leftOperand) { |
| 1611 try { | 1739 try { |
| 1612 return _valueOf(leftOperand.value.concatenate(typeProvider, value)); | 1740 return _valueOf(leftOperand.value.concatenate(typeProvider, value)); |
| 1613 } on EvaluationException catch (exception) { | 1741 } on EvaluationException catch (exception) { |
| 1614 return _error(node, exception.errorCode); | 1742 return _error(node, exception.errorCode); |
| 1615 } | 1743 } |
| 1616 } | 1744 } |
| 1617 | 1745 |
| 1746 @override |
| 1618 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1747 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1619 | 1748 |
| 1749 @override |
| 1620 EvaluationResultImpl divideValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { | 1750 EvaluationResultImpl divideValid(TypeProvider typeProvider, BinaryExpression n
ode, ValidResult leftOperand) { |
| 1621 try { | 1751 try { |
| 1622 return _valueOf(leftOperand.value.divide(typeProvider, value)); | 1752 return _valueOf(leftOperand.value.divide(typeProvider, value)); |
| 1623 } on EvaluationException catch (exception) { | 1753 } on EvaluationException catch (exception) { |
| 1624 return _error(node, exception.errorCode); | 1754 return _error(node, exception.errorCode); |
| 1625 } | 1755 } |
| 1626 } | 1756 } |
| 1627 | 1757 |
| 1758 @override |
| 1628 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; | 1759 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; |
| 1629 | 1760 |
| 1761 @override |
| 1630 EvaluationResultImpl equalEqualValid(TypeProvider typeProvider, Expression nod
e, ValidResult leftOperand) { | 1762 EvaluationResultImpl equalEqualValid(TypeProvider typeProvider, Expression nod
e, ValidResult leftOperand) { |
| 1631 try { | 1763 try { |
| 1632 return _valueOf(leftOperand.value.equalEqual(typeProvider, value)); | 1764 return _valueOf(leftOperand.value.equalEqual(typeProvider, value)); |
| 1633 } on EvaluationException catch (exception) { | 1765 } on EvaluationException catch (exception) { |
| 1634 return _error(node, exception.errorCode); | 1766 return _error(node, exception.errorCode); |
| 1635 } | 1767 } |
| 1636 } | 1768 } |
| 1637 | 1769 |
| 1770 @override |
| 1638 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; | 1771 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; |
| 1639 | 1772 |
| 1773 @override |
| 1640 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; | 1774 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; |
| 1641 | 1775 |
| 1776 @override |
| 1642 EvaluationResultImpl greaterThanOrEqualValid(TypeProvider typeProvider, Binary
Expression node, ValidResult leftOperand) { | 1777 EvaluationResultImpl greaterThanOrEqualValid(TypeProvider typeProvider, Binary
Expression node, ValidResult leftOperand) { |
| 1643 try { | 1778 try { |
| 1644 return _valueOf(leftOperand.value.greaterThanOrEqual(typeProvider, value))
; | 1779 return _valueOf(leftOperand.value.greaterThanOrEqual(typeProvider, value))
; |
| 1645 } on EvaluationException catch (exception) { | 1780 } on EvaluationException catch (exception) { |
| 1646 return _error(node, exception.errorCode); | 1781 return _error(node, exception.errorCode); |
| 1647 } | 1782 } |
| 1648 } | 1783 } |
| 1649 | 1784 |
| 1785 @override |
| 1650 EvaluationResultImpl greaterThanValid(TypeProvider typeProvider, BinaryExpress
ion node, ValidResult leftOperand) { | 1786 EvaluationResultImpl greaterThanValid(TypeProvider typeProvider, BinaryExpress
ion node, ValidResult leftOperand) { |
| 1651 try { | 1787 try { |
| 1652 return _valueOf(leftOperand.value.greaterThan(typeProvider, value)); | 1788 return _valueOf(leftOperand.value.greaterThan(typeProvider, value)); |
| 1653 } on EvaluationException catch (exception) { | 1789 } on EvaluationException catch (exception) { |
| 1654 return _error(node, exception.errorCode); | 1790 return _error(node, exception.errorCode); |
| 1655 } | 1791 } |
| 1656 } | 1792 } |
| 1657 | 1793 |
| 1794 @override |
| 1658 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; | 1795 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; |
| 1659 | 1796 |
| 1797 @override |
| 1660 EvaluationResultImpl integerDivideValid(TypeProvider typeProvider, BinaryExpre
ssion node, ValidResult leftOperand) { | 1798 EvaluationResultImpl integerDivideValid(TypeProvider typeProvider, BinaryExpre
ssion node, ValidResult leftOperand) { |
| 1661 try { | 1799 try { |
| 1662 return _valueOf(leftOperand.value.integerDivide(typeProvider, value)); | 1800 return _valueOf(leftOperand.value.integerDivide(typeProvider, value)); |
| 1663 } on EvaluationException catch (exception) { | 1801 } on EvaluationException catch (exception) { |
| 1664 return _error(node, exception.errorCode); | 1802 return _error(node, exception.errorCode); |
| 1665 } | 1803 } |
| 1666 } | 1804 } |
| 1667 | 1805 |
| 1806 @override |
| 1668 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1807 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
| 1669 | 1808 |
| 1809 @override |
| 1670 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; | 1810 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; |
| 1671 | 1811 |
| 1812 @override |
| 1672 EvaluationResultImpl lessThanOrEqualValid(TypeProvider typeProvider, BinaryExp
ression node, ValidResult leftOperand) { | 1813 EvaluationResultImpl lessThanOrEqualValid(TypeProvider typeProvider, BinaryExp
ression node, ValidResult leftOperand) { |
| 1673 try { | 1814 try { |
| 1674 return _valueOf(leftOperand.value.lessThanOrEqual(typeProvider, value)); | 1815 return _valueOf(leftOperand.value.lessThanOrEqual(typeProvider, value)); |
| 1675 } on EvaluationException catch (exception) { | 1816 } on EvaluationException catch (exception) { |
| 1676 return _error(node, exception.errorCode); | 1817 return _error(node, exception.errorCode); |
| 1677 } | 1818 } |
| 1678 } | 1819 } |
| 1679 | 1820 |
| 1821 @override |
| 1680 EvaluationResultImpl lessThanValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) { | 1822 EvaluationResultImpl lessThanValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) { |
| 1681 try { | 1823 try { |
| 1682 return _valueOf(leftOperand.value.lessThan(typeProvider, value)); | 1824 return _valueOf(leftOperand.value.lessThan(typeProvider, value)); |
| 1683 } on EvaluationException catch (exception) { | 1825 } on EvaluationException catch (exception) { |
| 1684 return _error(node, exception.errorCode); | 1826 return _error(node, exception.errorCode); |
| 1685 } | 1827 } |
| 1686 } | 1828 } |
| 1687 | 1829 |
| 1830 @override |
| 1688 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1831 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
| 1689 | 1832 |
| 1833 @override |
| 1690 EvaluationResultImpl logicalAndValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) { | 1834 EvaluationResultImpl logicalAndValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) { |
| 1691 try { | 1835 try { |
| 1692 return _valueOf(leftOperand.value.logicalAnd(typeProvider, value)); | 1836 return _valueOf(leftOperand.value.logicalAnd(typeProvider, value)); |
| 1693 } on EvaluationException catch (exception) { | 1837 } on EvaluationException catch (exception) { |
| 1694 return _error(node, exception.errorCode); | 1838 return _error(node, exception.errorCode); |
| 1695 } | 1839 } |
| 1696 } | 1840 } |
| 1697 | 1841 |
| 1842 @override |
| 1698 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1843 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1699 | 1844 |
| 1845 @override |
| 1700 EvaluationResultImpl logicalOrValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { | 1846 EvaluationResultImpl logicalOrValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { |
| 1701 try { | 1847 try { |
| 1702 return _valueOf(leftOperand.value.logicalOr(typeProvider, value)); | 1848 return _valueOf(leftOperand.value.logicalOr(typeProvider, value)); |
| 1703 } on EvaluationException catch (exception) { | 1849 } on EvaluationException catch (exception) { |
| 1704 return _error(node, exception.errorCode); | 1850 return _error(node, exception.errorCode); |
| 1705 } | 1851 } |
| 1706 } | 1852 } |
| 1707 | 1853 |
| 1854 @override |
| 1708 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1855 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1709 | 1856 |
| 1857 @override |
| 1710 EvaluationResultImpl minusValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { | 1858 EvaluationResultImpl minusValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { |
| 1711 try { | 1859 try { |
| 1712 return _valueOf(leftOperand.value.minus(typeProvider, value)); | 1860 return _valueOf(leftOperand.value.minus(typeProvider, value)); |
| 1713 } on EvaluationException catch (exception) { | 1861 } on EvaluationException catch (exception) { |
| 1714 return _error(node, exception.errorCode); | 1862 return _error(node, exception.errorCode); |
| 1715 } | 1863 } |
| 1716 } | 1864 } |
| 1717 | 1865 |
| 1866 @override |
| 1718 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1867 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
| 1719 | 1868 |
| 1869 @override |
| 1720 EvaluationResultImpl notEqualValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) { | 1870 EvaluationResultImpl notEqualValid(TypeProvider typeProvider, BinaryExpression
node, ValidResult leftOperand) { |
| 1721 try { | 1871 try { |
| 1722 return _valueOf(leftOperand.value.notEqual(typeProvider, value)); | 1872 return _valueOf(leftOperand.value.notEqual(typeProvider, value)); |
| 1723 } on EvaluationException catch (exception) { | 1873 } on EvaluationException catch (exception) { |
| 1724 return _error(node, exception.errorCode); | 1874 return _error(node, exception.errorCode); |
| 1725 } | 1875 } |
| 1726 } | 1876 } |
| 1727 | 1877 |
| 1878 @override |
| 1728 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1879 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1729 | 1880 |
| 1881 @override |
| 1730 EvaluationResultImpl remainderValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { | 1882 EvaluationResultImpl remainderValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { |
| 1731 try { | 1883 try { |
| 1732 return _valueOf(leftOperand.value.remainder(typeProvider, value)); | 1884 return _valueOf(leftOperand.value.remainder(typeProvider, value)); |
| 1733 } on EvaluationException catch (exception) { | 1885 } on EvaluationException catch (exception) { |
| 1734 return _error(node, exception.errorCode); | 1886 return _error(node, exception.errorCode); |
| 1735 } | 1887 } |
| 1736 } | 1888 } |
| 1737 | 1889 |
| 1890 @override |
| 1738 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1891 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1739 | 1892 |
| 1893 @override |
| 1740 EvaluationResultImpl shiftLeftValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { | 1894 EvaluationResultImpl shiftLeftValid(TypeProvider typeProvider, BinaryExpressio
n node, ValidResult leftOperand) { |
| 1741 try { | 1895 try { |
| 1742 return _valueOf(leftOperand.value.shiftLeft(typeProvider, value)); | 1896 return _valueOf(leftOperand.value.shiftLeft(typeProvider, value)); |
| 1743 } on EvaluationException catch (exception) { | 1897 } on EvaluationException catch (exception) { |
| 1744 return _error(node, exception.errorCode); | 1898 return _error(node, exception.errorCode); |
| 1745 } | 1899 } |
| 1746 } | 1900 } |
| 1747 | 1901 |
| 1902 @override |
| 1748 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1903 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
| 1749 | 1904 |
| 1905 @override |
| 1750 EvaluationResultImpl shiftRightValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) { | 1906 EvaluationResultImpl shiftRightValid(TypeProvider typeProvider, BinaryExpressi
on node, ValidResult leftOperand) { |
| 1751 try { | 1907 try { |
| 1752 return _valueOf(leftOperand.value.shiftRight(typeProvider, value)); | 1908 return _valueOf(leftOperand.value.shiftRight(typeProvider, value)); |
| 1753 } on EvaluationException catch (exception) { | 1909 } on EvaluationException catch (exception) { |
| 1754 return _error(node, exception.errorCode); | 1910 return _error(node, exception.errorCode); |
| 1755 } | 1911 } |
| 1756 } | 1912 } |
| 1757 | 1913 |
| 1914 @override |
| 1758 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1915 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1759 | 1916 |
| 1917 @override |
| 1760 EvaluationResultImpl timesValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { | 1918 EvaluationResultImpl timesValid(TypeProvider typeProvider, BinaryExpression no
de, ValidResult leftOperand) { |
| 1761 try { | 1919 try { |
| 1762 return _valueOf(leftOperand.value.times(typeProvider, value)); | 1920 return _valueOf(leftOperand.value.times(typeProvider, value)); |
| 1763 } on EvaluationException catch (exception) { | 1921 } on EvaluationException catch (exception) { |
| 1764 return _error(node, exception.errorCode); | 1922 return _error(node, exception.errorCode); |
| 1765 } | 1923 } |
| 1766 } | 1924 } |
| 1767 | 1925 |
| 1768 /** | 1926 /** |
| 1769 * Return a result object representing an error associated with the given node
. | 1927 * Return a result object representing an error associated with the given node
. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 */ | 1974 */ |
| 1817 static BoolState from(bool value) => value ? BoolState.TRUE_STATE : BoolState.
FALSE_STATE; | 1975 static BoolState from(bool value) => value ? BoolState.TRUE_STATE : BoolState.
FALSE_STATE; |
| 1818 | 1976 |
| 1819 /** | 1977 /** |
| 1820 * Initialize a newly created state to represent the given value. | 1978 * Initialize a newly created state to represent the given value. |
| 1821 * | 1979 * |
| 1822 * @param value the value of this instance | 1980 * @param value the value of this instance |
| 1823 */ | 1981 */ |
| 1824 BoolState(this.value); | 1982 BoolState(this.value); |
| 1825 | 1983 |
| 1984 @override |
| 1826 BoolState convertToBool() => this; | 1985 BoolState convertToBool() => this; |
| 1827 | 1986 |
| 1987 @override |
| 1828 StringState convertToString() { | 1988 StringState convertToString() { |
| 1829 if (value == null) { | 1989 if (value == null) { |
| 1830 return StringState.UNKNOWN_VALUE; | 1990 return StringState.UNKNOWN_VALUE; |
| 1831 } | 1991 } |
| 1832 return new StringState(value ? "true" : "false"); | 1992 return new StringState(value ? "true" : "false"); |
| 1833 } | 1993 } |
| 1834 | 1994 |
| 1995 @override |
| 1835 BoolState equalEqual(InstanceState rightOperand) { | 1996 BoolState equalEqual(InstanceState rightOperand) { |
| 1836 assertBoolNumStringOrNull(rightOperand); | 1997 assertBoolNumStringOrNull(rightOperand); |
| 1837 if (value == null) { | 1998 if (value == null) { |
| 1838 return UNKNOWN_VALUE; | 1999 return UNKNOWN_VALUE; |
| 1839 } | 2000 } |
| 1840 if (rightOperand is BoolState) { | 2001 if (rightOperand is BoolState) { |
| 1841 bool rightValue = rightOperand.value; | 2002 bool rightValue = rightOperand.value; |
| 1842 if (rightValue == null) { | 2003 if (rightValue == null) { |
| 1843 return UNKNOWN_VALUE; | 2004 return UNKNOWN_VALUE; |
| 1844 } | 2005 } |
| 1845 return BoolState.from(identical(value, rightValue)); | 2006 return BoolState.from(identical(value, rightValue)); |
| 1846 } else if (rightOperand is DynamicState) { | 2007 } else if (rightOperand is DynamicState) { |
| 1847 return UNKNOWN_VALUE; | 2008 return UNKNOWN_VALUE; |
| 1848 } | 2009 } |
| 1849 return FALSE_STATE; | 2010 return FALSE_STATE; |
| 1850 } | 2011 } |
| 1851 | 2012 |
| 2013 @override |
| 1852 bool operator ==(Object object) => object is BoolState && identical(value, obj
ect.value); | 2014 bool operator ==(Object object) => object is BoolState && identical(value, obj
ect.value); |
| 1853 | 2015 |
| 2016 @override |
| 1854 String get typeName => "bool"; | 2017 String get typeName => "bool"; |
| 1855 | 2018 |
| 2019 @override |
| 1856 bool get hasExactValue => true; | 2020 bool get hasExactValue => true; |
| 1857 | 2021 |
| 2022 @override |
| 1858 int get hashCode => value == null ? 0 : (value ? 2 : 3); | 2023 int get hashCode => value == null ? 0 : (value ? 2 : 3); |
| 1859 | 2024 |
| 1860 /** | 2025 /** |
| 1861 * Return `true` if this object represents an object whose type is 'bool'. | 2026 * Return `true` if this object represents an object whose type is 'bool'. |
| 1862 * | 2027 * |
| 1863 * @return `true` if this object represents a boolean value | 2028 * @return `true` if this object represents a boolean value |
| 1864 */ | 2029 */ |
| 2030 @override |
| 1865 bool get isBool => true; | 2031 bool get isBool => true; |
| 1866 | 2032 |
| 2033 @override |
| 1867 bool get isBoolNumStringOrNull => true; | 2034 bool get isBoolNumStringOrNull => true; |
| 1868 | 2035 |
| 2036 @override |
| 1869 BoolState logicalAnd(InstanceState rightOperand) { | 2037 BoolState logicalAnd(InstanceState rightOperand) { |
| 1870 assertBool(rightOperand); | 2038 assertBool(rightOperand); |
| 1871 if (value == null) { | 2039 if (value == null) { |
| 1872 return UNKNOWN_VALUE; | 2040 return UNKNOWN_VALUE; |
| 1873 } | 2041 } |
| 1874 return value ? rightOperand.convertToBool() : FALSE_STATE; | 2042 return value ? rightOperand.convertToBool() : FALSE_STATE; |
| 1875 } | 2043 } |
| 1876 | 2044 |
| 2045 @override |
| 1877 BoolState logicalNot() { | 2046 BoolState logicalNot() { |
| 1878 if (value == null) { | 2047 if (value == null) { |
| 1879 return UNKNOWN_VALUE; | 2048 return UNKNOWN_VALUE; |
| 1880 } | 2049 } |
| 1881 return value ? FALSE_STATE : TRUE_STATE; | 2050 return value ? FALSE_STATE : TRUE_STATE; |
| 1882 } | 2051 } |
| 1883 | 2052 |
| 2053 @override |
| 1884 BoolState logicalOr(InstanceState rightOperand) { | 2054 BoolState logicalOr(InstanceState rightOperand) { |
| 1885 assertBool(rightOperand); | 2055 assertBool(rightOperand); |
| 1886 if (value == null) { | 2056 if (value == null) { |
| 1887 return UNKNOWN_VALUE; | 2057 return UNKNOWN_VALUE; |
| 1888 } | 2058 } |
| 1889 return value ? TRUE_STATE : rightOperand.convertToBool(); | 2059 return value ? TRUE_STATE : rightOperand.convertToBool(); |
| 1890 } | 2060 } |
| 1891 | 2061 |
| 2062 @override |
| 1892 String toString() => value == null ? "-unknown-" : (value ? "true" : "false"); | 2063 String toString() => value == null ? "-unknown-" : (value ? "true" : "false"); |
| 1893 } | 2064 } |
| 1894 | 2065 |
| 1895 /** | 2066 /** |
| 1896 * Instances of the class `DartObjectImpl` represent an instance of a Dart class
. | 2067 * Instances of the class `DartObjectImpl` represent an instance of a Dart class
. |
| 1897 */ | 2068 */ |
| 1898 class DartObjectImpl implements DartObject { | 2069 class DartObjectImpl implements DartObject { |
| 1899 /** | 2070 /** |
| 1900 * The run-time type of this object. | 2071 * The run-time type of this object. |
| 1901 */ | 2072 */ |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 DartObjectImpl equalEqual(TypeProvider typeProvider, DartObjectImpl rightOpera
nd) { | 2204 DartObjectImpl equalEqual(TypeProvider typeProvider, DartObjectImpl rightOpera
nd) { |
| 2034 if (type != rightOperand.type) { | 2205 if (type != rightOperand.type) { |
| 2035 String typeName = type.name; | 2206 String typeName = type.name; |
| 2036 if (!(typeName == "bool" || typeName == "double" || typeName == "int" || t
ypeName == "num" || typeName == "String" || typeName == "Null" || type.isDynamic
)) { | 2207 if (!(typeName == "bool" || typeName == "double" || typeName == "int" || t
ypeName == "num" || typeName == "String" || typeName == "Null" || type.isDynamic
)) { |
| 2037 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_
NUM_STRING); | 2208 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_
NUM_STRING); |
| 2038 } | 2209 } |
| 2039 } | 2210 } |
| 2040 return new DartObjectImpl(typeProvider.boolType, _state.equalEqual(rightOper
and._state)); | 2211 return new DartObjectImpl(typeProvider.boolType, _state.equalEqual(rightOper
and._state)); |
| 2041 } | 2212 } |
| 2042 | 2213 |
| 2214 @override |
| 2043 bool operator ==(Object object) { | 2215 bool operator ==(Object object) { |
| 2044 if (object is! DartObjectImpl) { | 2216 if (object is! DartObjectImpl) { |
| 2045 return false; | 2217 return false; |
| 2046 } | 2218 } |
| 2047 DartObjectImpl dartObject = object as DartObjectImpl; | 2219 DartObjectImpl dartObject = object as DartObjectImpl; |
| 2048 return type == dartObject.type && _state == dartObject._state; | 2220 return type == dartObject.type && _state == dartObject._state; |
| 2049 } | 2221 } |
| 2050 | 2222 |
| 2223 @override |
| 2051 bool get boolValue { | 2224 bool get boolValue { |
| 2052 if (_state is BoolState) { | 2225 if (_state is BoolState) { |
| 2053 return (_state as BoolState).value; | 2226 return (_state as BoolState).value; |
| 2054 } | 2227 } |
| 2055 return null; | 2228 return null; |
| 2056 } | 2229 } |
| 2057 | 2230 |
| 2231 @override |
| 2058 double get doubleValue { | 2232 double get doubleValue { |
| 2059 if (_state is DoubleState) { | 2233 if (_state is DoubleState) { |
| 2060 return (_state as DoubleState).value; | 2234 return (_state as DoubleState).value; |
| 2061 } | 2235 } |
| 2062 return null; | 2236 return null; |
| 2063 } | 2237 } |
| 2064 | 2238 |
| 2239 @override |
| 2065 int get intValue { | 2240 int get intValue { |
| 2066 if (_state is IntState) { | 2241 if (_state is IntState) { |
| 2067 return (_state as IntState).value; | 2242 return (_state as IntState).value; |
| 2068 } | 2243 } |
| 2069 return null; | 2244 return null; |
| 2070 } | 2245 } |
| 2071 | 2246 |
| 2247 @override |
| 2072 String get stringValue { | 2248 String get stringValue { |
| 2073 if (_state is StringState) { | 2249 if (_state is StringState) { |
| 2074 return (_state as StringState).value; | 2250 return (_state as StringState).value; |
| 2075 } | 2251 } |
| 2076 return null; | 2252 return null; |
| 2077 } | 2253 } |
| 2078 | 2254 |
| 2255 @override |
| 2079 Object get value => _state.value; | 2256 Object get value => _state.value; |
| 2080 | 2257 |
| 2081 /** | 2258 /** |
| 2082 * Return the result of invoking the '>' operator on this object with the g
iven argument. | 2259 * Return the result of invoking the '>' operator on this object with the g
iven argument. |
| 2083 * | 2260 * |
| 2084 * @param typeProvider the type provider used to find known types | 2261 * @param typeProvider the type provider used to find known types |
| 2085 * @param rightOperand the right-hand operand of the operation | 2262 * @param rightOperand the right-hand operand of the operation |
| 2086 * @return the result of invoking the '>' operator on this object with the
given argument | 2263 * @return the result of invoking the '>' operator on this object with the
given argument |
| 2087 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind | 2264 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind |
| 2088 */ | 2265 */ |
| 2089 DartObjectImpl greaterThan(TypeProvider typeProvider, DartObjectImpl rightOper
and) => new DartObjectImpl(typeProvider.boolType, _state.greaterThan(rightOperan
d._state)); | 2266 DartObjectImpl greaterThan(TypeProvider typeProvider, DartObjectImpl rightOper
and) => new DartObjectImpl(typeProvider.boolType, _state.greaterThan(rightOperan
d._state)); |
| 2090 | 2267 |
| 2091 /** | 2268 /** |
| 2092 * Return the result of invoking the '>=' operator on this object with the
given argument. | 2269 * Return the result of invoking the '>=' operator on this object with the
given argument. |
| 2093 * | 2270 * |
| 2094 * @param typeProvider the type provider used to find known types | 2271 * @param typeProvider the type provider used to find known types |
| 2095 * @param rightOperand the right-hand operand of the operation | 2272 * @param rightOperand the right-hand operand of the operation |
| 2096 * @return the result of invoking the '>=' operator on this object with the
given argument | 2273 * @return the result of invoking the '>=' operator on this object with the
given argument |
| 2097 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind | 2274 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind |
| 2098 */ | 2275 */ |
| 2099 DartObjectImpl greaterThanOrEqual(TypeProvider typeProvider, DartObjectImpl ri
ghtOperand) => new DartObjectImpl(typeProvider.boolType, _state.greaterThanOrEqu
al(rightOperand._state)); | 2276 DartObjectImpl greaterThanOrEqual(TypeProvider typeProvider, DartObjectImpl ri
ghtOperand) => new DartObjectImpl(typeProvider.boolType, _state.greaterThanOrEqu
al(rightOperand._state)); |
| 2100 | 2277 |
| 2278 @override |
| 2101 bool get hasExactValue => _state.hasExactValue; | 2279 bool get hasExactValue => _state.hasExactValue; |
| 2102 | 2280 |
| 2281 @override |
| 2103 int get hashCode => ObjectUtilities.combineHashCodes(type.hashCode, _state.has
hCode); | 2282 int get hashCode => ObjectUtilities.combineHashCodes(type.hashCode, _state.has
hCode); |
| 2104 | 2283 |
| 2105 /** | 2284 /** |
| 2106 * Return the result of invoking the '~/' operator on this object with the giv
en argument. | 2285 * Return the result of invoking the '~/' operator on this object with the giv
en argument. |
| 2107 * | 2286 * |
| 2108 * @param typeProvider the type provider used to find known types | 2287 * @param typeProvider the type provider used to find known types |
| 2109 * @param rightOperand the right-hand operand of the operation | 2288 * @param rightOperand the right-hand operand of the operation |
| 2110 * @return the result of invoking the '~/' operator on this object with the gi
ven argument | 2289 * @return the result of invoking the '~/' operator on this object with the gi
ven argument |
| 2111 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind | 2290 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind |
| 2112 */ | 2291 */ |
| 2113 DartObjectImpl integerDivide(TypeProvider typeProvider, DartObjectImpl rightOp
erand) => new DartObjectImpl(typeProvider.intType, _state.integerDivide(rightOpe
rand._state)); | 2292 DartObjectImpl integerDivide(TypeProvider typeProvider, DartObjectImpl rightOp
erand) => new DartObjectImpl(typeProvider.intType, _state.integerDivide(rightOpe
rand._state)); |
| 2114 | 2293 |
| 2115 /** | 2294 /** |
| 2116 * Return `true` if this object represents an object whose type is 'bool'. | 2295 * Return `true` if this object represents an object whose type is 'bool'. |
| 2117 * | 2296 * |
| 2118 * @return `true` if this object represents a boolean value | 2297 * @return `true` if this object represents a boolean value |
| 2119 */ | 2298 */ |
| 2120 bool get isBool => _state.isBool; | 2299 bool get isBool => _state.isBool; |
| 2121 | 2300 |
| 2122 /** | 2301 /** |
| 2123 * Return `true` if this object represents an object whose type is either 'boo
l', 'num', | 2302 * Return `true` if this object represents an object whose type is either 'boo
l', 'num', |
| 2124 * 'String', or 'Null'. | 2303 * 'String', or 'Null'. |
| 2125 * | 2304 * |
| 2126 * @return `true` if this object represents either a boolean, numeric, string
or null value | 2305 * @return `true` if this object represents either a boolean, numeric, string
or null value |
| 2127 */ | 2306 */ |
| 2128 bool get isBoolNumStringOrNull => _state.isBoolNumStringOrNull; | 2307 bool get isBoolNumStringOrNull => _state.isBoolNumStringOrNull; |
| 2129 | 2308 |
| 2309 @override |
| 2130 bool get isFalse => _state is BoolState && identical((_state as BoolState).val
ue, false); | 2310 bool get isFalse => _state is BoolState && identical((_state as BoolState).val
ue, false); |
| 2131 | 2311 |
| 2312 @override |
| 2132 bool get isNull => _state is NullState; | 2313 bool get isNull => _state is NullState; |
| 2133 | 2314 |
| 2315 @override |
| 2134 bool get isTrue => _state is BoolState && identical((_state as BoolState).valu
e, true); | 2316 bool get isTrue => _state is BoolState && identical((_state as BoolState).valu
e, true); |
| 2135 | 2317 |
| 2136 /** | 2318 /** |
| 2137 * Return `true` if this object represents an instance of a user-defined class
. | 2319 * Return `true` if this object represents an instance of a user-defined class
. |
| 2138 * | 2320 * |
| 2139 * @return `true` if this object represents an instance of a user-defined clas
s | 2321 * @return `true` if this object represents an instance of a user-defined clas
s |
| 2140 */ | 2322 */ |
| 2141 bool get isUserDefinedObject => _state is GenericState; | 2323 bool get isUserDefinedObject => _state is GenericState; |
| 2142 | 2324 |
| 2143 /** | 2325 /** |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2318 return new DartObjectImpl(typeProvider.intType, result); | 2500 return new DartObjectImpl(typeProvider.intType, result); |
| 2319 } else if (result is DoubleState) { | 2501 } else if (result is DoubleState) { |
| 2320 return new DartObjectImpl(typeProvider.doubleType, result); | 2502 return new DartObjectImpl(typeProvider.doubleType, result); |
| 2321 } else if (result is NumState) { | 2503 } else if (result is NumState) { |
| 2322 return new DartObjectImpl(typeProvider.numType, result); | 2504 return new DartObjectImpl(typeProvider.numType, result); |
| 2323 } | 2505 } |
| 2324 // We should never get here. | 2506 // We should never get here. |
| 2325 throw new IllegalStateException("times returned a ${result.runtimeType.toStr
ing()}"); | 2507 throw new IllegalStateException("times returned a ${result.runtimeType.toStr
ing()}"); |
| 2326 } | 2508 } |
| 2327 | 2509 |
| 2510 @override |
| 2328 String toString() => "${type.displayName} (${_state.toString()})"; | 2511 String toString() => "${type.displayName} (${_state.toString()})"; |
| 2329 } | 2512 } |
| 2330 | 2513 |
| 2331 /** | 2514 /** |
| 2332 * Instances of the class `DoubleState` represent the state of an object represe
nting a | 2515 * Instances of the class `DoubleState` represent the state of an object represe
nting a |
| 2333 * double. | 2516 * double. |
| 2334 */ | 2517 */ |
| 2335 class DoubleState extends NumState { | 2518 class DoubleState extends NumState { |
| 2336 /** | 2519 /** |
| 2337 * The value of this instance. | 2520 * The value of this instance. |
| 2338 */ | 2521 */ |
| 2339 final double value; | 2522 final double value; |
| 2340 | 2523 |
| 2341 /** | 2524 /** |
| 2342 * A state that can be used to represent a double whose value is not known. | 2525 * A state that can be used to represent a double whose value is not known. |
| 2343 */ | 2526 */ |
| 2344 static DoubleState UNKNOWN_VALUE = new DoubleState(null); | 2527 static DoubleState UNKNOWN_VALUE = new DoubleState(null); |
| 2345 | 2528 |
| 2346 /** | 2529 /** |
| 2347 * Initialize a newly created state to represent a double with the given value
. | 2530 * Initialize a newly created state to represent a double with the given value
. |
| 2348 * | 2531 * |
| 2349 * @param value the value of this instance | 2532 * @param value the value of this instance |
| 2350 */ | 2533 */ |
| 2351 DoubleState(this.value); | 2534 DoubleState(this.value); |
| 2352 | 2535 |
| 2536 @override |
| 2353 NumState add(InstanceState rightOperand) { | 2537 NumState add(InstanceState rightOperand) { |
| 2354 assertNumOrNull(rightOperand); | 2538 assertNumOrNull(rightOperand); |
| 2355 if (value == null) { | 2539 if (value == null) { |
| 2356 return UNKNOWN_VALUE; | 2540 return UNKNOWN_VALUE; |
| 2357 } | 2541 } |
| 2358 if (rightOperand is IntState) { | 2542 if (rightOperand is IntState) { |
| 2359 int rightValue = rightOperand.value; | 2543 int rightValue = rightOperand.value; |
| 2360 if (rightValue == null) { | 2544 if (rightValue == null) { |
| 2361 return UNKNOWN_VALUE; | 2545 return UNKNOWN_VALUE; |
| 2362 } | 2546 } |
| 2363 return new DoubleState(value + rightValue.toDouble()); | 2547 return new DoubleState(value + rightValue.toDouble()); |
| 2364 } else if (rightOperand is DoubleState) { | 2548 } else if (rightOperand is DoubleState) { |
| 2365 double rightValue = rightOperand.value; | 2549 double rightValue = rightOperand.value; |
| 2366 if (rightValue == null) { | 2550 if (rightValue == null) { |
| 2367 return UNKNOWN_VALUE; | 2551 return UNKNOWN_VALUE; |
| 2368 } | 2552 } |
| 2369 return new DoubleState(value + rightValue); | 2553 return new DoubleState(value + rightValue); |
| 2370 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2554 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2371 return UNKNOWN_VALUE; | 2555 return UNKNOWN_VALUE; |
| 2372 } | 2556 } |
| 2373 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2557 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2374 } | 2558 } |
| 2375 | 2559 |
| 2560 @override |
| 2376 StringState convertToString() { | 2561 StringState convertToString() { |
| 2377 if (value == null) { | 2562 if (value == null) { |
| 2378 return StringState.UNKNOWN_VALUE; | 2563 return StringState.UNKNOWN_VALUE; |
| 2379 } | 2564 } |
| 2380 return new StringState(value.toString()); | 2565 return new StringState(value.toString()); |
| 2381 } | 2566 } |
| 2382 | 2567 |
| 2568 @override |
| 2383 NumState divide(InstanceState rightOperand) { | 2569 NumState divide(InstanceState rightOperand) { |
| 2384 assertNumOrNull(rightOperand); | 2570 assertNumOrNull(rightOperand); |
| 2385 if (value == null) { | 2571 if (value == null) { |
| 2386 return UNKNOWN_VALUE; | 2572 return UNKNOWN_VALUE; |
| 2387 } | 2573 } |
| 2388 if (rightOperand is IntState) { | 2574 if (rightOperand is IntState) { |
| 2389 int rightValue = rightOperand.value; | 2575 int rightValue = rightOperand.value; |
| 2390 if (rightValue == null) { | 2576 if (rightValue == null) { |
| 2391 return UNKNOWN_VALUE; | 2577 return UNKNOWN_VALUE; |
| 2392 } | 2578 } |
| 2393 return new DoubleState(value / rightValue.toDouble()); | 2579 return new DoubleState(value / rightValue.toDouble()); |
| 2394 } else if (rightOperand is DoubleState) { | 2580 } else if (rightOperand is DoubleState) { |
| 2395 double rightValue = rightOperand.value; | 2581 double rightValue = rightOperand.value; |
| 2396 if (rightValue == null) { | 2582 if (rightValue == null) { |
| 2397 return UNKNOWN_VALUE; | 2583 return UNKNOWN_VALUE; |
| 2398 } | 2584 } |
| 2399 return new DoubleState(value / rightValue); | 2585 return new DoubleState(value / rightValue); |
| 2400 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2586 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2401 return UNKNOWN_VALUE; | 2587 return UNKNOWN_VALUE; |
| 2402 } | 2588 } |
| 2403 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2589 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2404 } | 2590 } |
| 2405 | 2591 |
| 2592 @override |
| 2406 BoolState equalEqual(InstanceState rightOperand) { | 2593 BoolState equalEqual(InstanceState rightOperand) { |
| 2407 assertBoolNumStringOrNull(rightOperand); | 2594 assertBoolNumStringOrNull(rightOperand); |
| 2408 if (value == null) { | 2595 if (value == null) { |
| 2409 return BoolState.UNKNOWN_VALUE; | 2596 return BoolState.UNKNOWN_VALUE; |
| 2410 } | 2597 } |
| 2411 if (rightOperand is DoubleState) { | 2598 if (rightOperand is DoubleState) { |
| 2412 double rightValue = rightOperand.value; | 2599 double rightValue = rightOperand.value; |
| 2413 if (rightValue == null) { | 2600 if (rightValue == null) { |
| 2414 return BoolState.UNKNOWN_VALUE; | 2601 return BoolState.UNKNOWN_VALUE; |
| 2415 } | 2602 } |
| 2416 return BoolState.from(value == rightValue); | 2603 return BoolState.from(value == rightValue); |
| 2417 } else if (rightOperand is IntState) { | 2604 } else if (rightOperand is IntState) { |
| 2418 int rightValue = rightOperand.value; | 2605 int rightValue = rightOperand.value; |
| 2419 if (rightValue == null) { | 2606 if (rightValue == null) { |
| 2420 return BoolState.UNKNOWN_VALUE; | 2607 return BoolState.UNKNOWN_VALUE; |
| 2421 } | 2608 } |
| 2422 return BoolState.from(value == rightValue.toDouble()); | 2609 return BoolState.from(value == rightValue.toDouble()); |
| 2423 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2610 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2424 return BoolState.UNKNOWN_VALUE; | 2611 return BoolState.UNKNOWN_VALUE; |
| 2425 } | 2612 } |
| 2426 return BoolState.FALSE_STATE; | 2613 return BoolState.FALSE_STATE; |
| 2427 } | 2614 } |
| 2428 | 2615 |
| 2616 @override |
| 2429 bool operator ==(Object object) => object is DoubleState && (value == object.v
alue); | 2617 bool operator ==(Object object) => object is DoubleState && (value == object.v
alue); |
| 2430 | 2618 |
| 2619 @override |
| 2431 String get typeName => "double"; | 2620 String get typeName => "double"; |
| 2432 | 2621 |
| 2622 @override |
| 2433 BoolState greaterThan(InstanceState rightOperand) { | 2623 BoolState greaterThan(InstanceState rightOperand) { |
| 2434 assertNumOrNull(rightOperand); | 2624 assertNumOrNull(rightOperand); |
| 2435 if (value == null) { | 2625 if (value == null) { |
| 2436 return BoolState.UNKNOWN_VALUE; | 2626 return BoolState.UNKNOWN_VALUE; |
| 2437 } | 2627 } |
| 2438 if (rightOperand is IntState) { | 2628 if (rightOperand is IntState) { |
| 2439 int rightValue = rightOperand.value; | 2629 int rightValue = rightOperand.value; |
| 2440 if (rightValue == null) { | 2630 if (rightValue == null) { |
| 2441 return BoolState.UNKNOWN_VALUE; | 2631 return BoolState.UNKNOWN_VALUE; |
| 2442 } | 2632 } |
| 2443 return BoolState.from(value > rightValue.toDouble()); | 2633 return BoolState.from(value > rightValue.toDouble()); |
| 2444 } else if (rightOperand is DoubleState) { | 2634 } else if (rightOperand is DoubleState) { |
| 2445 double rightValue = rightOperand.value; | 2635 double rightValue = rightOperand.value; |
| 2446 if (rightValue == null) { | 2636 if (rightValue == null) { |
| 2447 return BoolState.UNKNOWN_VALUE; | 2637 return BoolState.UNKNOWN_VALUE; |
| 2448 } | 2638 } |
| 2449 return BoolState.from(value > rightValue); | 2639 return BoolState.from(value > rightValue); |
| 2450 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2640 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2451 return BoolState.UNKNOWN_VALUE; | 2641 return BoolState.UNKNOWN_VALUE; |
| 2452 } | 2642 } |
| 2453 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2643 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2454 } | 2644 } |
| 2455 | 2645 |
| 2646 @override |
| 2456 BoolState greaterThanOrEqual(InstanceState rightOperand) { | 2647 BoolState greaterThanOrEqual(InstanceState rightOperand) { |
| 2457 assertNumOrNull(rightOperand); | 2648 assertNumOrNull(rightOperand); |
| 2458 if (value == null) { | 2649 if (value == null) { |
| 2459 return BoolState.UNKNOWN_VALUE; | 2650 return BoolState.UNKNOWN_VALUE; |
| 2460 } | 2651 } |
| 2461 if (rightOperand is IntState) { | 2652 if (rightOperand is IntState) { |
| 2462 int rightValue = rightOperand.value; | 2653 int rightValue = rightOperand.value; |
| 2463 if (rightValue == null) { | 2654 if (rightValue == null) { |
| 2464 return BoolState.UNKNOWN_VALUE; | 2655 return BoolState.UNKNOWN_VALUE; |
| 2465 } | 2656 } |
| 2466 return BoolState.from(value >= rightValue.toDouble()); | 2657 return BoolState.from(value >= rightValue.toDouble()); |
| 2467 } else if (rightOperand is DoubleState) { | 2658 } else if (rightOperand is DoubleState) { |
| 2468 double rightValue = rightOperand.value; | 2659 double rightValue = rightOperand.value; |
| 2469 if (rightValue == null) { | 2660 if (rightValue == null) { |
| 2470 return BoolState.UNKNOWN_VALUE; | 2661 return BoolState.UNKNOWN_VALUE; |
| 2471 } | 2662 } |
| 2472 return BoolState.from(value >= rightValue); | 2663 return BoolState.from(value >= rightValue); |
| 2473 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2664 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2474 return BoolState.UNKNOWN_VALUE; | 2665 return BoolState.UNKNOWN_VALUE; |
| 2475 } | 2666 } |
| 2476 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2667 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2477 } | 2668 } |
| 2478 | 2669 |
| 2670 @override |
| 2479 bool get hasExactValue => true; | 2671 bool get hasExactValue => true; |
| 2480 | 2672 |
| 2673 @override |
| 2481 int get hashCode => value == null ? 0 : value.hashCode; | 2674 int get hashCode => value == null ? 0 : value.hashCode; |
| 2482 | 2675 |
| 2676 @override |
| 2483 IntState integerDivide(InstanceState rightOperand) { | 2677 IntState integerDivide(InstanceState rightOperand) { |
| 2484 assertNumOrNull(rightOperand); | 2678 assertNumOrNull(rightOperand); |
| 2485 if (value == null) { | 2679 if (value == null) { |
| 2486 return IntState.UNKNOWN_VALUE; | 2680 return IntState.UNKNOWN_VALUE; |
| 2487 } | 2681 } |
| 2488 if (rightOperand is IntState) { | 2682 if (rightOperand is IntState) { |
| 2489 int rightValue = rightOperand.value; | 2683 int rightValue = rightOperand.value; |
| 2490 if (rightValue == null) { | 2684 if (rightValue == null) { |
| 2491 return IntState.UNKNOWN_VALUE; | 2685 return IntState.UNKNOWN_VALUE; |
| 2492 } | 2686 } |
| 2493 double result = value / rightValue.toDouble(); | 2687 double result = value / rightValue.toDouble(); |
| 2494 return new IntState(result.toInt()); | 2688 return new IntState(result.toInt()); |
| 2495 } else if (rightOperand is DoubleState) { | 2689 } else if (rightOperand is DoubleState) { |
| 2496 double rightValue = rightOperand.value; | 2690 double rightValue = rightOperand.value; |
| 2497 if (rightValue == null) { | 2691 if (rightValue == null) { |
| 2498 return IntState.UNKNOWN_VALUE; | 2692 return IntState.UNKNOWN_VALUE; |
| 2499 } | 2693 } |
| 2500 double result = value / rightValue; | 2694 double result = value / rightValue; |
| 2501 return new IntState(result.toInt()); | 2695 return new IntState(result.toInt()); |
| 2502 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2696 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2503 return IntState.UNKNOWN_VALUE; | 2697 return IntState.UNKNOWN_VALUE; |
| 2504 } | 2698 } |
| 2505 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2699 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2506 } | 2700 } |
| 2507 | 2701 |
| 2702 @override |
| 2508 bool get isBoolNumStringOrNull => true; | 2703 bool get isBoolNumStringOrNull => true; |
| 2509 | 2704 |
| 2705 @override |
| 2510 BoolState lessThan(InstanceState rightOperand) { | 2706 BoolState lessThan(InstanceState rightOperand) { |
| 2511 assertNumOrNull(rightOperand); | 2707 assertNumOrNull(rightOperand); |
| 2512 if (value == null) { | 2708 if (value == null) { |
| 2513 return BoolState.UNKNOWN_VALUE; | 2709 return BoolState.UNKNOWN_VALUE; |
| 2514 } | 2710 } |
| 2515 if (rightOperand is IntState) { | 2711 if (rightOperand is IntState) { |
| 2516 int rightValue = rightOperand.value; | 2712 int rightValue = rightOperand.value; |
| 2517 if (rightValue == null) { | 2713 if (rightValue == null) { |
| 2518 return BoolState.UNKNOWN_VALUE; | 2714 return BoolState.UNKNOWN_VALUE; |
| 2519 } | 2715 } |
| 2520 return BoolState.from(value < rightValue.toDouble()); | 2716 return BoolState.from(value < rightValue.toDouble()); |
| 2521 } else if (rightOperand is DoubleState) { | 2717 } else if (rightOperand is DoubleState) { |
| 2522 double rightValue = rightOperand.value; | 2718 double rightValue = rightOperand.value; |
| 2523 if (rightValue == null) { | 2719 if (rightValue == null) { |
| 2524 return BoolState.UNKNOWN_VALUE; | 2720 return BoolState.UNKNOWN_VALUE; |
| 2525 } | 2721 } |
| 2526 return BoolState.from(value < rightValue); | 2722 return BoolState.from(value < rightValue); |
| 2527 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2723 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2528 return BoolState.UNKNOWN_VALUE; | 2724 return BoolState.UNKNOWN_VALUE; |
| 2529 } | 2725 } |
| 2530 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2726 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2531 } | 2727 } |
| 2532 | 2728 |
| 2729 @override |
| 2533 BoolState lessThanOrEqual(InstanceState rightOperand) { | 2730 BoolState lessThanOrEqual(InstanceState rightOperand) { |
| 2534 assertNumOrNull(rightOperand); | 2731 assertNumOrNull(rightOperand); |
| 2535 if (value == null) { | 2732 if (value == null) { |
| 2536 return BoolState.UNKNOWN_VALUE; | 2733 return BoolState.UNKNOWN_VALUE; |
| 2537 } | 2734 } |
| 2538 if (rightOperand is IntState) { | 2735 if (rightOperand is IntState) { |
| 2539 int rightValue = rightOperand.value; | 2736 int rightValue = rightOperand.value; |
| 2540 if (rightValue == null) { | 2737 if (rightValue == null) { |
| 2541 return BoolState.UNKNOWN_VALUE; | 2738 return BoolState.UNKNOWN_VALUE; |
| 2542 } | 2739 } |
| 2543 return BoolState.from(value <= rightValue.toDouble()); | 2740 return BoolState.from(value <= rightValue.toDouble()); |
| 2544 } else if (rightOperand is DoubleState) { | 2741 } else if (rightOperand is DoubleState) { |
| 2545 double rightValue = rightOperand.value; | 2742 double rightValue = rightOperand.value; |
| 2546 if (rightValue == null) { | 2743 if (rightValue == null) { |
| 2547 return BoolState.UNKNOWN_VALUE; | 2744 return BoolState.UNKNOWN_VALUE; |
| 2548 } | 2745 } |
| 2549 return BoolState.from(value <= rightValue); | 2746 return BoolState.from(value <= rightValue); |
| 2550 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2747 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2551 return BoolState.UNKNOWN_VALUE; | 2748 return BoolState.UNKNOWN_VALUE; |
| 2552 } | 2749 } |
| 2553 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2750 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2554 } | 2751 } |
| 2555 | 2752 |
| 2753 @override |
| 2556 NumState minus(InstanceState rightOperand) { | 2754 NumState minus(InstanceState rightOperand) { |
| 2557 assertNumOrNull(rightOperand); | 2755 assertNumOrNull(rightOperand); |
| 2558 if (value == null) { | 2756 if (value == null) { |
| 2559 return UNKNOWN_VALUE; | 2757 return UNKNOWN_VALUE; |
| 2560 } | 2758 } |
| 2561 if (rightOperand is IntState) { | 2759 if (rightOperand is IntState) { |
| 2562 int rightValue = rightOperand.value; | 2760 int rightValue = rightOperand.value; |
| 2563 if (rightValue == null) { | 2761 if (rightValue == null) { |
| 2564 return UNKNOWN_VALUE; | 2762 return UNKNOWN_VALUE; |
| 2565 } | 2763 } |
| 2566 return new DoubleState(value - rightValue.toDouble()); | 2764 return new DoubleState(value - rightValue.toDouble()); |
| 2567 } else if (rightOperand is DoubleState) { | 2765 } else if (rightOperand is DoubleState) { |
| 2568 double rightValue = rightOperand.value; | 2766 double rightValue = rightOperand.value; |
| 2569 if (rightValue == null) { | 2767 if (rightValue == null) { |
| 2570 return UNKNOWN_VALUE; | 2768 return UNKNOWN_VALUE; |
| 2571 } | 2769 } |
| 2572 return new DoubleState(value - rightValue); | 2770 return new DoubleState(value - rightValue); |
| 2573 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2771 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2574 return UNKNOWN_VALUE; | 2772 return UNKNOWN_VALUE; |
| 2575 } | 2773 } |
| 2576 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2774 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2577 } | 2775 } |
| 2578 | 2776 |
| 2777 @override |
| 2579 NumState negated() { | 2778 NumState negated() { |
| 2580 if (value == null) { | 2779 if (value == null) { |
| 2581 return UNKNOWN_VALUE; | 2780 return UNKNOWN_VALUE; |
| 2582 } | 2781 } |
| 2583 return new DoubleState(-(value)); | 2782 return new DoubleState(-(value)); |
| 2584 } | 2783 } |
| 2585 | 2784 |
| 2785 @override |
| 2586 NumState remainder(InstanceState rightOperand) { | 2786 NumState remainder(InstanceState rightOperand) { |
| 2587 assertNumOrNull(rightOperand); | 2787 assertNumOrNull(rightOperand); |
| 2588 if (value == null) { | 2788 if (value == null) { |
| 2589 return UNKNOWN_VALUE; | 2789 return UNKNOWN_VALUE; |
| 2590 } | 2790 } |
| 2591 if (rightOperand is IntState) { | 2791 if (rightOperand is IntState) { |
| 2592 int rightValue = rightOperand.value; | 2792 int rightValue = rightOperand.value; |
| 2593 if (rightValue == null) { | 2793 if (rightValue == null) { |
| 2594 return UNKNOWN_VALUE; | 2794 return UNKNOWN_VALUE; |
| 2595 } | 2795 } |
| 2596 return new DoubleState(value % rightValue.toDouble()); | 2796 return new DoubleState(value % rightValue.toDouble()); |
| 2597 } else if (rightOperand is DoubleState) { | 2797 } else if (rightOperand is DoubleState) { |
| 2598 double rightValue = rightOperand.value; | 2798 double rightValue = rightOperand.value; |
| 2599 if (rightValue == null) { | 2799 if (rightValue == null) { |
| 2600 return UNKNOWN_VALUE; | 2800 return UNKNOWN_VALUE; |
| 2601 } | 2801 } |
| 2602 return new DoubleState(value % rightValue); | 2802 return new DoubleState(value % rightValue); |
| 2603 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2803 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2604 return UNKNOWN_VALUE; | 2804 return UNKNOWN_VALUE; |
| 2605 } | 2805 } |
| 2606 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2806 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2607 } | 2807 } |
| 2608 | 2808 |
| 2809 @override |
| 2609 NumState times(InstanceState rightOperand) { | 2810 NumState times(InstanceState rightOperand) { |
| 2610 assertNumOrNull(rightOperand); | 2811 assertNumOrNull(rightOperand); |
| 2611 if (value == null) { | 2812 if (value == null) { |
| 2612 return UNKNOWN_VALUE; | 2813 return UNKNOWN_VALUE; |
| 2613 } | 2814 } |
| 2614 if (rightOperand is IntState) { | 2815 if (rightOperand is IntState) { |
| 2615 int rightValue = rightOperand.value; | 2816 int rightValue = rightOperand.value; |
| 2616 if (rightValue == null) { | 2817 if (rightValue == null) { |
| 2617 return UNKNOWN_VALUE; | 2818 return UNKNOWN_VALUE; |
| 2618 } | 2819 } |
| 2619 return new DoubleState(value * rightValue.toDouble()); | 2820 return new DoubleState(value * rightValue.toDouble()); |
| 2620 } else if (rightOperand is DoubleState) { | 2821 } else if (rightOperand is DoubleState) { |
| 2621 double rightValue = rightOperand.value; | 2822 double rightValue = rightOperand.value; |
| 2622 if (rightValue == null) { | 2823 if (rightValue == null) { |
| 2623 return UNKNOWN_VALUE; | 2824 return UNKNOWN_VALUE; |
| 2624 } | 2825 } |
| 2625 return new DoubleState(value * rightValue); | 2826 return new DoubleState(value * rightValue); |
| 2626 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 2827 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 2627 return UNKNOWN_VALUE; | 2828 return UNKNOWN_VALUE; |
| 2628 } | 2829 } |
| 2629 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 2830 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 2630 } | 2831 } |
| 2631 | 2832 |
| 2833 @override |
| 2632 String toString() => value == null ? "-unknown-" : value.toString(); | 2834 String toString() => value == null ? "-unknown-" : value.toString(); |
| 2633 } | 2835 } |
| 2634 | 2836 |
| 2635 /** | 2837 /** |
| 2636 * Instances of the class `DynamicState` represent the state of an object repres
enting a Dart | 2838 * Instances of the class `DynamicState` represent the state of an object repres
enting a Dart |
| 2637 * object for which there is no type information. | 2839 * object for which there is no type information. |
| 2638 */ | 2840 */ |
| 2639 class DynamicState extends InstanceState { | 2841 class DynamicState extends InstanceState { |
| 2640 /** | 2842 /** |
| 2641 * The unique instance of this class. | 2843 * The unique instance of this class. |
| 2642 */ | 2844 */ |
| 2643 static DynamicState DYNAMIC_STATE = new DynamicState(); | 2845 static DynamicState DYNAMIC_STATE = new DynamicState(); |
| 2644 | 2846 |
| 2847 @override |
| 2645 NumState add(InstanceState rightOperand) { | 2848 NumState add(InstanceState rightOperand) { |
| 2646 assertNumOrNull(rightOperand); | 2849 assertNumOrNull(rightOperand); |
| 2647 return _unknownNum(rightOperand); | 2850 return _unknownNum(rightOperand); |
| 2648 } | 2851 } |
| 2649 | 2852 |
| 2853 @override |
| 2650 IntState bitAnd(InstanceState rightOperand) { | 2854 IntState bitAnd(InstanceState rightOperand) { |
| 2651 assertIntOrNull(rightOperand); | 2855 assertIntOrNull(rightOperand); |
| 2652 return IntState.UNKNOWN_VALUE; | 2856 return IntState.UNKNOWN_VALUE; |
| 2653 } | 2857 } |
| 2654 | 2858 |
| 2859 @override |
| 2655 IntState bitNot() => IntState.UNKNOWN_VALUE; | 2860 IntState bitNot() => IntState.UNKNOWN_VALUE; |
| 2656 | 2861 |
| 2862 @override |
| 2657 IntState bitOr(InstanceState rightOperand) { | 2863 IntState bitOr(InstanceState rightOperand) { |
| 2658 assertIntOrNull(rightOperand); | 2864 assertIntOrNull(rightOperand); |
| 2659 return IntState.UNKNOWN_VALUE; | 2865 return IntState.UNKNOWN_VALUE; |
| 2660 } | 2866 } |
| 2661 | 2867 |
| 2868 @override |
| 2662 IntState bitXor(InstanceState rightOperand) { | 2869 IntState bitXor(InstanceState rightOperand) { |
| 2663 assertIntOrNull(rightOperand); | 2870 assertIntOrNull(rightOperand); |
| 2664 return IntState.UNKNOWN_VALUE; | 2871 return IntState.UNKNOWN_VALUE; |
| 2665 } | 2872 } |
| 2666 | 2873 |
| 2874 @override |
| 2667 StringState concatenate(InstanceState rightOperand) { | 2875 StringState concatenate(InstanceState rightOperand) { |
| 2668 assertString(rightOperand); | 2876 assertString(rightOperand); |
| 2669 return StringState.UNKNOWN_VALUE; | 2877 return StringState.UNKNOWN_VALUE; |
| 2670 } | 2878 } |
| 2671 | 2879 |
| 2880 @override |
| 2672 BoolState convertToBool() => BoolState.UNKNOWN_VALUE; | 2881 BoolState convertToBool() => BoolState.UNKNOWN_VALUE; |
| 2673 | 2882 |
| 2883 @override |
| 2674 StringState convertToString() => StringState.UNKNOWN_VALUE; | 2884 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 2675 | 2885 |
| 2886 @override |
| 2676 NumState divide(InstanceState rightOperand) { | 2887 NumState divide(InstanceState rightOperand) { |
| 2677 assertNumOrNull(rightOperand); | 2888 assertNumOrNull(rightOperand); |
| 2678 return _unknownNum(rightOperand); | 2889 return _unknownNum(rightOperand); |
| 2679 } | 2890 } |
| 2680 | 2891 |
| 2892 @override |
| 2681 BoolState equalEqual(InstanceState rightOperand) { | 2893 BoolState equalEqual(InstanceState rightOperand) { |
| 2682 assertBoolNumStringOrNull(rightOperand); | 2894 assertBoolNumStringOrNull(rightOperand); |
| 2683 return BoolState.UNKNOWN_VALUE; | 2895 return BoolState.UNKNOWN_VALUE; |
| 2684 } | 2896 } |
| 2685 | 2897 |
| 2898 @override |
| 2686 String get typeName => "dynamic"; | 2899 String get typeName => "dynamic"; |
| 2687 | 2900 |
| 2901 @override |
| 2688 BoolState greaterThan(InstanceState rightOperand) { | 2902 BoolState greaterThan(InstanceState rightOperand) { |
| 2689 assertNumOrNull(rightOperand); | 2903 assertNumOrNull(rightOperand); |
| 2690 return BoolState.UNKNOWN_VALUE; | 2904 return BoolState.UNKNOWN_VALUE; |
| 2691 } | 2905 } |
| 2692 | 2906 |
| 2907 @override |
| 2693 BoolState greaterThanOrEqual(InstanceState rightOperand) { | 2908 BoolState greaterThanOrEqual(InstanceState rightOperand) { |
| 2694 assertNumOrNull(rightOperand); | 2909 assertNumOrNull(rightOperand); |
| 2695 return BoolState.UNKNOWN_VALUE; | 2910 return BoolState.UNKNOWN_VALUE; |
| 2696 } | 2911 } |
| 2697 | 2912 |
| 2913 @override |
| 2698 IntState integerDivide(InstanceState rightOperand) { | 2914 IntState integerDivide(InstanceState rightOperand) { |
| 2699 assertNumOrNull(rightOperand); | 2915 assertNumOrNull(rightOperand); |
| 2700 return IntState.UNKNOWN_VALUE; | 2916 return IntState.UNKNOWN_VALUE; |
| 2701 } | 2917 } |
| 2702 | 2918 |
| 2919 @override |
| 2703 bool get isBool => true; | 2920 bool get isBool => true; |
| 2704 | 2921 |
| 2922 @override |
| 2705 bool get isBoolNumStringOrNull => true; | 2923 bool get isBoolNumStringOrNull => true; |
| 2706 | 2924 |
| 2925 @override |
| 2707 BoolState lessThan(InstanceState rightOperand) { | 2926 BoolState lessThan(InstanceState rightOperand) { |
| 2708 assertNumOrNull(rightOperand); | 2927 assertNumOrNull(rightOperand); |
| 2709 return BoolState.UNKNOWN_VALUE; | 2928 return BoolState.UNKNOWN_VALUE; |
| 2710 } | 2929 } |
| 2711 | 2930 |
| 2931 @override |
| 2712 BoolState lessThanOrEqual(InstanceState rightOperand) { | 2932 BoolState lessThanOrEqual(InstanceState rightOperand) { |
| 2713 assertNumOrNull(rightOperand); | 2933 assertNumOrNull(rightOperand); |
| 2714 return BoolState.UNKNOWN_VALUE; | 2934 return BoolState.UNKNOWN_VALUE; |
| 2715 } | 2935 } |
| 2716 | 2936 |
| 2937 @override |
| 2717 BoolState logicalAnd(InstanceState rightOperand) { | 2938 BoolState logicalAnd(InstanceState rightOperand) { |
| 2718 assertBool(rightOperand); | 2939 assertBool(rightOperand); |
| 2719 return BoolState.UNKNOWN_VALUE; | 2940 return BoolState.UNKNOWN_VALUE; |
| 2720 } | 2941 } |
| 2721 | 2942 |
| 2943 @override |
| 2722 BoolState logicalNot() => BoolState.UNKNOWN_VALUE; | 2944 BoolState logicalNot() => BoolState.UNKNOWN_VALUE; |
| 2723 | 2945 |
| 2946 @override |
| 2724 BoolState logicalOr(InstanceState rightOperand) { | 2947 BoolState logicalOr(InstanceState rightOperand) { |
| 2725 assertBool(rightOperand); | 2948 assertBool(rightOperand); |
| 2726 return rightOperand.convertToBool(); | 2949 return rightOperand.convertToBool(); |
| 2727 } | 2950 } |
| 2728 | 2951 |
| 2952 @override |
| 2729 NumState minus(InstanceState rightOperand) { | 2953 NumState minus(InstanceState rightOperand) { |
| 2730 assertNumOrNull(rightOperand); | 2954 assertNumOrNull(rightOperand); |
| 2731 return _unknownNum(rightOperand); | 2955 return _unknownNum(rightOperand); |
| 2732 } | 2956 } |
| 2733 | 2957 |
| 2958 @override |
| 2734 NumState negated() => NumState.UNKNOWN_VALUE; | 2959 NumState negated() => NumState.UNKNOWN_VALUE; |
| 2735 | 2960 |
| 2961 @override |
| 2736 NumState remainder(InstanceState rightOperand) { | 2962 NumState remainder(InstanceState rightOperand) { |
| 2737 assertNumOrNull(rightOperand); | 2963 assertNumOrNull(rightOperand); |
| 2738 return _unknownNum(rightOperand); | 2964 return _unknownNum(rightOperand); |
| 2739 } | 2965 } |
| 2740 | 2966 |
| 2967 @override |
| 2741 IntState shiftLeft(InstanceState rightOperand) { | 2968 IntState shiftLeft(InstanceState rightOperand) { |
| 2742 assertIntOrNull(rightOperand); | 2969 assertIntOrNull(rightOperand); |
| 2743 return IntState.UNKNOWN_VALUE; | 2970 return IntState.UNKNOWN_VALUE; |
| 2744 } | 2971 } |
| 2745 | 2972 |
| 2973 @override |
| 2746 IntState shiftRight(InstanceState rightOperand) { | 2974 IntState shiftRight(InstanceState rightOperand) { |
| 2747 assertIntOrNull(rightOperand); | 2975 assertIntOrNull(rightOperand); |
| 2748 return IntState.UNKNOWN_VALUE; | 2976 return IntState.UNKNOWN_VALUE; |
| 2749 } | 2977 } |
| 2750 | 2978 |
| 2979 @override |
| 2751 NumState times(InstanceState rightOperand) { | 2980 NumState times(InstanceState rightOperand) { |
| 2752 assertNumOrNull(rightOperand); | 2981 assertNumOrNull(rightOperand); |
| 2753 return _unknownNum(rightOperand); | 2982 return _unknownNum(rightOperand); |
| 2754 } | 2983 } |
| 2755 | 2984 |
| 2756 /** | 2985 /** |
| 2757 * Return an object representing an unknown numeric value whose type is based
on the type of the | 2986 * Return an object representing an unknown numeric value whose type is based
on the type of the |
| 2758 * right-hand operand. | 2987 * right-hand operand. |
| 2759 * | 2988 * |
| 2760 * @param rightOperand the operand whose type will determine the type of the r
esult | 2989 * @param rightOperand the operand whose type will determine the type of the r
esult |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 | 3029 |
| 2801 /** | 3030 /** |
| 2802 * Initialize a newly created state to represent the given function. | 3031 * Initialize a newly created state to represent the given function. |
| 2803 * | 3032 * |
| 2804 * @param element the element representing the function being modeled | 3033 * @param element the element representing the function being modeled |
| 2805 */ | 3034 */ |
| 2806 FunctionState(ExecutableElement element) { | 3035 FunctionState(ExecutableElement element) { |
| 2807 this._element = element; | 3036 this._element = element; |
| 2808 } | 3037 } |
| 2809 | 3038 |
| 3039 @override |
| 2810 StringState convertToString() { | 3040 StringState convertToString() { |
| 2811 if (_element == null) { | 3041 if (_element == null) { |
| 2812 return StringState.UNKNOWN_VALUE; | 3042 return StringState.UNKNOWN_VALUE; |
| 2813 } | 3043 } |
| 2814 return new StringState(_element.name); | 3044 return new StringState(_element.name); |
| 2815 } | 3045 } |
| 2816 | 3046 |
| 3047 @override |
| 2817 bool operator ==(Object object) => object is FunctionState && (_element == obj
ect._element); | 3048 bool operator ==(Object object) => object is FunctionState && (_element == obj
ect._element); |
| 2818 | 3049 |
| 3050 @override |
| 2819 BoolState equalEqual(InstanceState rightOperand) { | 3051 BoolState equalEqual(InstanceState rightOperand) { |
| 2820 if (_element == null) { | 3052 if (_element == null) { |
| 2821 return BoolState.UNKNOWN_VALUE; | 3053 return BoolState.UNKNOWN_VALUE; |
| 2822 } | 3054 } |
| 2823 if (rightOperand is FunctionState) { | 3055 if (rightOperand is FunctionState) { |
| 2824 ExecutableElement rightElement = rightOperand._element; | 3056 ExecutableElement rightElement = rightOperand._element; |
| 2825 if (rightElement == null) { | 3057 if (rightElement == null) { |
| 2826 return BoolState.UNKNOWN_VALUE; | 3058 return BoolState.UNKNOWN_VALUE; |
| 2827 } | 3059 } |
| 2828 return BoolState.from(_element == rightElement); | 3060 return BoolState.from(_element == rightElement); |
| 2829 } else if (rightOperand is DynamicState) { | 3061 } else if (rightOperand is DynamicState) { |
| 2830 return BoolState.UNKNOWN_VALUE; | 3062 return BoolState.UNKNOWN_VALUE; |
| 2831 } | 3063 } |
| 2832 return BoolState.FALSE_STATE; | 3064 return BoolState.FALSE_STATE; |
| 2833 } | 3065 } |
| 2834 | 3066 |
| 3067 @override |
| 2835 String get typeName => "Function"; | 3068 String get typeName => "Function"; |
| 2836 | 3069 |
| 3070 @override |
| 2837 int get hashCode => _element == null ? 0 : _element.hashCode; | 3071 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 2838 | 3072 |
| 3073 @override |
| 2839 String toString() => _element == null ? "-unknown-" : _element.name; | 3074 String toString() => _element == null ? "-unknown-" : _element.name; |
| 2840 } | 3075 } |
| 2841 | 3076 |
| 2842 /** | 3077 /** |
| 2843 * Instances of the class `GenericState` represent the state of an object repres
enting a Dart | 3078 * Instances of the class `GenericState` represent the state of an object repres
enting a Dart |
| 2844 * object for which there is no more specific state. | 3079 * object for which there is no more specific state. |
| 2845 */ | 3080 */ |
| 2846 class GenericState extends InstanceState { | 3081 class GenericState extends InstanceState { |
| 2847 /** | 3082 /** |
| 2848 * The values of the fields of this instance. | 3083 * The values of the fields of this instance. |
| 2849 */ | 3084 */ |
| 2850 Map<String, DartObjectImpl> _fieldMap = new Map<String, DartObjectImpl>(); | 3085 Map<String, DartObjectImpl> _fieldMap = new Map<String, DartObjectImpl>(); |
| 2851 | 3086 |
| 2852 /** | 3087 /** |
| 2853 * A state that can be used to represent an object whose state is not known. | 3088 * A state that can be used to represent an object whose state is not known. |
| 2854 */ | 3089 */ |
| 2855 static GenericState UNKNOWN_VALUE = new GenericState(new Map<String, DartObjec
tImpl>()); | 3090 static GenericState UNKNOWN_VALUE = new GenericState(new Map<String, DartObjec
tImpl>()); |
| 2856 | 3091 |
| 2857 /** | 3092 /** |
| 2858 * Initialize a newly created state to represent a newly created object. | 3093 * Initialize a newly created state to represent a newly created object. |
| 2859 * | 3094 * |
| 2860 * @param fieldMap the values of the fields of this instance | 3095 * @param fieldMap the values of the fields of this instance |
| 2861 */ | 3096 */ |
| 2862 GenericState(Map<String, DartObjectImpl> fieldMap) { | 3097 GenericState(Map<String, DartObjectImpl> fieldMap) { |
| 2863 this._fieldMap = fieldMap; | 3098 this._fieldMap = fieldMap; |
| 2864 } | 3099 } |
| 2865 | 3100 |
| 3101 @override |
| 2866 StringState convertToString() => StringState.UNKNOWN_VALUE; | 3102 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 2867 | 3103 |
| 3104 @override |
| 2868 bool operator ==(Object object) { | 3105 bool operator ==(Object object) { |
| 2869 if (object is! GenericState) { | 3106 if (object is! GenericState) { |
| 2870 return false; | 3107 return false; |
| 2871 } | 3108 } |
| 2872 GenericState state = object as GenericState; | 3109 GenericState state = object as GenericState; |
| 2873 Set<String> otherFields = new Set<String>(); | 3110 Set<String> otherFields = new Set<String>(); |
| 2874 for (String fieldName in _fieldMap.keys.toSet()) { | 3111 for (String fieldName in _fieldMap.keys.toSet()) { |
| 2875 if (_fieldMap[fieldName] != state._fieldMap[fieldName]) { | 3112 if (_fieldMap[fieldName] != state._fieldMap[fieldName]) { |
| 2876 return false; | 3113 return false; |
| 2877 } | 3114 } |
| 2878 otherFields.remove(fieldName); | 3115 otherFields.remove(fieldName); |
| 2879 } | 3116 } |
| 2880 for (String fieldName in otherFields) { | 3117 for (String fieldName in otherFields) { |
| 2881 if (state._fieldMap[fieldName] != _fieldMap[fieldName]) { | 3118 if (state._fieldMap[fieldName] != _fieldMap[fieldName]) { |
| 2882 return false; | 3119 return false; |
| 2883 } | 3120 } |
| 2884 } | 3121 } |
| 2885 return true; | 3122 return true; |
| 2886 } | 3123 } |
| 2887 | 3124 |
| 3125 @override |
| 2888 BoolState equalEqual(InstanceState rightOperand) { | 3126 BoolState equalEqual(InstanceState rightOperand) { |
| 2889 assertBoolNumStringOrNull(rightOperand); | 3127 assertBoolNumStringOrNull(rightOperand); |
| 2890 if (rightOperand is DynamicState) { | 3128 if (rightOperand is DynamicState) { |
| 2891 return BoolState.UNKNOWN_VALUE; | 3129 return BoolState.UNKNOWN_VALUE; |
| 2892 } | 3130 } |
| 2893 return BoolState.from(this == rightOperand); | 3131 return BoolState.from(this == rightOperand); |
| 2894 } | 3132 } |
| 2895 | 3133 |
| 3134 @override |
| 2896 String get typeName => "user defined type"; | 3135 String get typeName => "user defined type"; |
| 2897 | 3136 |
| 3137 @override |
| 2898 int get hashCode { | 3138 int get hashCode { |
| 2899 int hashCode = 0; | 3139 int hashCode = 0; |
| 2900 for (DartObjectImpl value in _fieldMap.values) { | 3140 for (DartObjectImpl value in _fieldMap.values) { |
| 2901 hashCode += value.hashCode; | 3141 hashCode += value.hashCode; |
| 2902 } | 3142 } |
| 2903 return hashCode; | 3143 return hashCode; |
| 2904 } | 3144 } |
| 2905 } | 3145 } |
| 2906 | 3146 |
| 2907 /** | 3147 /** |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3317 */ | 3557 */ |
| 3318 static IntState UNKNOWN_VALUE = new IntState(null); | 3558 static IntState UNKNOWN_VALUE = new IntState(null); |
| 3319 | 3559 |
| 3320 /** | 3560 /** |
| 3321 * Initialize a newly created state to represent an int with the given value. | 3561 * Initialize a newly created state to represent an int with the given value. |
| 3322 * | 3562 * |
| 3323 * @param value the value of this instance | 3563 * @param value the value of this instance |
| 3324 */ | 3564 */ |
| 3325 IntState(this.value); | 3565 IntState(this.value); |
| 3326 | 3566 |
| 3567 @override |
| 3327 NumState add(InstanceState rightOperand) { | 3568 NumState add(InstanceState rightOperand) { |
| 3328 assertNumOrNull(rightOperand); | 3569 assertNumOrNull(rightOperand); |
| 3329 if (value == null) { | 3570 if (value == null) { |
| 3330 if (rightOperand is DoubleState) { | 3571 if (rightOperand is DoubleState) { |
| 3331 return DoubleState.UNKNOWN_VALUE; | 3572 return DoubleState.UNKNOWN_VALUE; |
| 3332 } | 3573 } |
| 3333 return UNKNOWN_VALUE; | 3574 return UNKNOWN_VALUE; |
| 3334 } | 3575 } |
| 3335 if (rightOperand is IntState) { | 3576 if (rightOperand is IntState) { |
| 3336 int rightValue = rightOperand.value; | 3577 int rightValue = rightOperand.value; |
| 3337 if (rightValue == null) { | 3578 if (rightValue == null) { |
| 3338 return UNKNOWN_VALUE; | 3579 return UNKNOWN_VALUE; |
| 3339 } | 3580 } |
| 3340 return new IntState(value + rightValue); | 3581 return new IntState(value + rightValue); |
| 3341 } else if (rightOperand is DoubleState) { | 3582 } else if (rightOperand is DoubleState) { |
| 3342 double rightValue = rightOperand.value; | 3583 double rightValue = rightOperand.value; |
| 3343 if (rightValue == null) { | 3584 if (rightValue == null) { |
| 3344 return DoubleState.UNKNOWN_VALUE; | 3585 return DoubleState.UNKNOWN_VALUE; |
| 3345 } | 3586 } |
| 3346 return new DoubleState(value.toDouble() + rightValue); | 3587 return new DoubleState(value.toDouble() + rightValue); |
| 3347 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3588 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3348 return UNKNOWN_VALUE; | 3589 return UNKNOWN_VALUE; |
| 3349 } | 3590 } |
| 3350 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3591 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3351 } | 3592 } |
| 3352 | 3593 |
| 3594 @override |
| 3353 IntState bitAnd(InstanceState rightOperand) { | 3595 IntState bitAnd(InstanceState rightOperand) { |
| 3354 assertIntOrNull(rightOperand); | 3596 assertIntOrNull(rightOperand); |
| 3355 if (value == null) { | 3597 if (value == null) { |
| 3356 return UNKNOWN_VALUE; | 3598 return UNKNOWN_VALUE; |
| 3357 } | 3599 } |
| 3358 if (rightOperand is IntState) { | 3600 if (rightOperand is IntState) { |
| 3359 int rightValue = rightOperand.value; | 3601 int rightValue = rightOperand.value; |
| 3360 if (rightValue == null) { | 3602 if (rightValue == null) { |
| 3361 return UNKNOWN_VALUE; | 3603 return UNKNOWN_VALUE; |
| 3362 } | 3604 } |
| 3363 return new IntState(value & rightValue); | 3605 return new IntState(value & rightValue); |
| 3364 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3606 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3365 return UNKNOWN_VALUE; | 3607 return UNKNOWN_VALUE; |
| 3366 } | 3608 } |
| 3367 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3609 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3368 } | 3610 } |
| 3369 | 3611 |
| 3612 @override |
| 3370 IntState bitNot() { | 3613 IntState bitNot() { |
| 3371 if (value == null) { | 3614 if (value == null) { |
| 3372 return UNKNOWN_VALUE; | 3615 return UNKNOWN_VALUE; |
| 3373 } | 3616 } |
| 3374 return new IntState(~value); | 3617 return new IntState(~value); |
| 3375 } | 3618 } |
| 3376 | 3619 |
| 3620 @override |
| 3377 IntState bitOr(InstanceState rightOperand) { | 3621 IntState bitOr(InstanceState rightOperand) { |
| 3378 assertIntOrNull(rightOperand); | 3622 assertIntOrNull(rightOperand); |
| 3379 if (value == null) { | 3623 if (value == null) { |
| 3380 return UNKNOWN_VALUE; | 3624 return UNKNOWN_VALUE; |
| 3381 } | 3625 } |
| 3382 if (rightOperand is IntState) { | 3626 if (rightOperand is IntState) { |
| 3383 int rightValue = rightOperand.value; | 3627 int rightValue = rightOperand.value; |
| 3384 if (rightValue == null) { | 3628 if (rightValue == null) { |
| 3385 return UNKNOWN_VALUE; | 3629 return UNKNOWN_VALUE; |
| 3386 } | 3630 } |
| 3387 return new IntState(value | rightValue); | 3631 return new IntState(value | rightValue); |
| 3388 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3632 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3389 return UNKNOWN_VALUE; | 3633 return UNKNOWN_VALUE; |
| 3390 } | 3634 } |
| 3391 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3635 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3392 } | 3636 } |
| 3393 | 3637 |
| 3638 @override |
| 3394 IntState bitXor(InstanceState rightOperand) { | 3639 IntState bitXor(InstanceState rightOperand) { |
| 3395 assertIntOrNull(rightOperand); | 3640 assertIntOrNull(rightOperand); |
| 3396 if (value == null) { | 3641 if (value == null) { |
| 3397 return UNKNOWN_VALUE; | 3642 return UNKNOWN_VALUE; |
| 3398 } | 3643 } |
| 3399 if (rightOperand is IntState) { | 3644 if (rightOperand is IntState) { |
| 3400 int rightValue = rightOperand.value; | 3645 int rightValue = rightOperand.value; |
| 3401 if (rightValue == null) { | 3646 if (rightValue == null) { |
| 3402 return UNKNOWN_VALUE; | 3647 return UNKNOWN_VALUE; |
| 3403 } | 3648 } |
| 3404 return new IntState(value ^ rightValue); | 3649 return new IntState(value ^ rightValue); |
| 3405 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3650 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3406 return UNKNOWN_VALUE; | 3651 return UNKNOWN_VALUE; |
| 3407 } | 3652 } |
| 3408 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3653 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3409 } | 3654 } |
| 3410 | 3655 |
| 3656 @override |
| 3411 StringState convertToString() { | 3657 StringState convertToString() { |
| 3412 if (value == null) { | 3658 if (value == null) { |
| 3413 return StringState.UNKNOWN_VALUE; | 3659 return StringState.UNKNOWN_VALUE; |
| 3414 } | 3660 } |
| 3415 return new StringState(value.toString()); | 3661 return new StringState(value.toString()); |
| 3416 } | 3662 } |
| 3417 | 3663 |
| 3664 @override |
| 3418 NumState divide(InstanceState rightOperand) { | 3665 NumState divide(InstanceState rightOperand) { |
| 3419 assertNumOrNull(rightOperand); | 3666 assertNumOrNull(rightOperand); |
| 3420 if (value == null) { | 3667 if (value == null) { |
| 3421 if (rightOperand is DoubleState) { | 3668 if (rightOperand is DoubleState) { |
| 3422 return DoubleState.UNKNOWN_VALUE; | 3669 return DoubleState.UNKNOWN_VALUE; |
| 3423 } | 3670 } |
| 3424 return UNKNOWN_VALUE; | 3671 return UNKNOWN_VALUE; |
| 3425 } | 3672 } |
| 3426 if (rightOperand is IntState) { | 3673 if (rightOperand is IntState) { |
| 3427 int rightValue = rightOperand.value; | 3674 int rightValue = rightOperand.value; |
| 3428 if (rightValue == null) { | 3675 if (rightValue == null) { |
| 3429 return UNKNOWN_VALUE; | 3676 return UNKNOWN_VALUE; |
| 3430 } else if (rightValue == 0) { | 3677 } else if (rightValue == 0) { |
| 3431 return new DoubleState(value.toDouble() / rightValue.toDouble()); | 3678 return new DoubleState(value.toDouble() / rightValue.toDouble()); |
| 3432 } | 3679 } |
| 3433 return new IntState(value ~/ rightValue); | 3680 return new IntState(value ~/ rightValue); |
| 3434 } else if (rightOperand is DoubleState) { | 3681 } else if (rightOperand is DoubleState) { |
| 3435 double rightValue = rightOperand.value; | 3682 double rightValue = rightOperand.value; |
| 3436 if (rightValue == null) { | 3683 if (rightValue == null) { |
| 3437 return DoubleState.UNKNOWN_VALUE; | 3684 return DoubleState.UNKNOWN_VALUE; |
| 3438 } | 3685 } |
| 3439 return new DoubleState(value.toDouble() / rightValue); | 3686 return new DoubleState(value.toDouble() / rightValue); |
| 3440 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3687 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3441 return UNKNOWN_VALUE; | 3688 return UNKNOWN_VALUE; |
| 3442 } | 3689 } |
| 3443 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3690 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3444 } | 3691 } |
| 3445 | 3692 |
| 3693 @override |
| 3446 BoolState equalEqual(InstanceState rightOperand) { | 3694 BoolState equalEqual(InstanceState rightOperand) { |
| 3447 assertBoolNumStringOrNull(rightOperand); | 3695 assertBoolNumStringOrNull(rightOperand); |
| 3448 if (value == null) { | 3696 if (value == null) { |
| 3449 return BoolState.UNKNOWN_VALUE; | 3697 return BoolState.UNKNOWN_VALUE; |
| 3450 } | 3698 } |
| 3451 if (rightOperand is IntState) { | 3699 if (rightOperand is IntState) { |
| 3452 int rightValue = rightOperand.value; | 3700 int rightValue = rightOperand.value; |
| 3453 if (rightValue == null) { | 3701 if (rightValue == null) { |
| 3454 return BoolState.UNKNOWN_VALUE; | 3702 return BoolState.UNKNOWN_VALUE; |
| 3455 } | 3703 } |
| 3456 return BoolState.from(value == rightValue); | 3704 return BoolState.from(value == rightValue); |
| 3457 } else if (rightOperand is DoubleState) { | 3705 } else if (rightOperand is DoubleState) { |
| 3458 double rightValue = rightOperand.value; | 3706 double rightValue = rightOperand.value; |
| 3459 if (rightValue == null) { | 3707 if (rightValue == null) { |
| 3460 return BoolState.UNKNOWN_VALUE; | 3708 return BoolState.UNKNOWN_VALUE; |
| 3461 } | 3709 } |
| 3462 return BoolState.from(rightValue == value.toDouble()); | 3710 return BoolState.from(rightValue == value.toDouble()); |
| 3463 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3711 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3464 return BoolState.UNKNOWN_VALUE; | 3712 return BoolState.UNKNOWN_VALUE; |
| 3465 } | 3713 } |
| 3466 return BoolState.FALSE_STATE; | 3714 return BoolState.FALSE_STATE; |
| 3467 } | 3715 } |
| 3468 | 3716 |
| 3717 @override |
| 3469 bool operator ==(Object object) => object is IntState && (value == object.valu
e); | 3718 bool operator ==(Object object) => object is IntState && (value == object.valu
e); |
| 3470 | 3719 |
| 3720 @override |
| 3471 String get typeName => "int"; | 3721 String get typeName => "int"; |
| 3472 | 3722 |
| 3723 @override |
| 3473 BoolState greaterThan(InstanceState rightOperand) { | 3724 BoolState greaterThan(InstanceState rightOperand) { |
| 3474 assertNumOrNull(rightOperand); | 3725 assertNumOrNull(rightOperand); |
| 3475 if (value == null) { | 3726 if (value == null) { |
| 3476 return BoolState.UNKNOWN_VALUE; | 3727 return BoolState.UNKNOWN_VALUE; |
| 3477 } | 3728 } |
| 3478 if (rightOperand is IntState) { | 3729 if (rightOperand is IntState) { |
| 3479 int rightValue = rightOperand.value; | 3730 int rightValue = rightOperand.value; |
| 3480 if (rightValue == null) { | 3731 if (rightValue == null) { |
| 3481 return BoolState.UNKNOWN_VALUE; | 3732 return BoolState.UNKNOWN_VALUE; |
| 3482 } | 3733 } |
| 3483 return BoolState.from(value.compareTo(rightValue) > 0); | 3734 return BoolState.from(value.compareTo(rightValue) > 0); |
| 3484 } else if (rightOperand is DoubleState) { | 3735 } else if (rightOperand is DoubleState) { |
| 3485 double rightValue = rightOperand.value; | 3736 double rightValue = rightOperand.value; |
| 3486 if (rightValue == null) { | 3737 if (rightValue == null) { |
| 3487 return BoolState.UNKNOWN_VALUE; | 3738 return BoolState.UNKNOWN_VALUE; |
| 3488 } | 3739 } |
| 3489 return BoolState.from(value.toDouble() > rightValue); | 3740 return BoolState.from(value.toDouble() > rightValue); |
| 3490 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3741 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3491 return BoolState.UNKNOWN_VALUE; | 3742 return BoolState.UNKNOWN_VALUE; |
| 3492 } | 3743 } |
| 3493 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3744 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3494 } | 3745 } |
| 3495 | 3746 |
| 3747 @override |
| 3496 BoolState greaterThanOrEqual(InstanceState rightOperand) { | 3748 BoolState greaterThanOrEqual(InstanceState rightOperand) { |
| 3497 assertNumOrNull(rightOperand); | 3749 assertNumOrNull(rightOperand); |
| 3498 if (value == null) { | 3750 if (value == null) { |
| 3499 return BoolState.UNKNOWN_VALUE; | 3751 return BoolState.UNKNOWN_VALUE; |
| 3500 } | 3752 } |
| 3501 if (rightOperand is IntState) { | 3753 if (rightOperand is IntState) { |
| 3502 int rightValue = rightOperand.value; | 3754 int rightValue = rightOperand.value; |
| 3503 if (rightValue == null) { | 3755 if (rightValue == null) { |
| 3504 return BoolState.UNKNOWN_VALUE; | 3756 return BoolState.UNKNOWN_VALUE; |
| 3505 } | 3757 } |
| 3506 return BoolState.from(value.compareTo(rightValue) >= 0); | 3758 return BoolState.from(value.compareTo(rightValue) >= 0); |
| 3507 } else if (rightOperand is DoubleState) { | 3759 } else if (rightOperand is DoubleState) { |
| 3508 double rightValue = rightOperand.value; | 3760 double rightValue = rightOperand.value; |
| 3509 if (rightValue == null) { | 3761 if (rightValue == null) { |
| 3510 return BoolState.UNKNOWN_VALUE; | 3762 return BoolState.UNKNOWN_VALUE; |
| 3511 } | 3763 } |
| 3512 return BoolState.from(value.toDouble() >= rightValue); | 3764 return BoolState.from(value.toDouble() >= rightValue); |
| 3513 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3765 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3514 return BoolState.UNKNOWN_VALUE; | 3766 return BoolState.UNKNOWN_VALUE; |
| 3515 } | 3767 } |
| 3516 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3768 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3517 } | 3769 } |
| 3518 | 3770 |
| 3771 @override |
| 3519 bool get hasExactValue => true; | 3772 bool get hasExactValue => true; |
| 3520 | 3773 |
| 3774 @override |
| 3521 int get hashCode => value == null ? 0 : value.hashCode; | 3775 int get hashCode => value == null ? 0 : value.hashCode; |
| 3522 | 3776 |
| 3777 @override |
| 3523 IntState integerDivide(InstanceState rightOperand) { | 3778 IntState integerDivide(InstanceState rightOperand) { |
| 3524 assertNumOrNull(rightOperand); | 3779 assertNumOrNull(rightOperand); |
| 3525 if (value == null) { | 3780 if (value == null) { |
| 3526 return UNKNOWN_VALUE; | 3781 return UNKNOWN_VALUE; |
| 3527 } | 3782 } |
| 3528 if (rightOperand is IntState) { | 3783 if (rightOperand is IntState) { |
| 3529 int rightValue = rightOperand.value; | 3784 int rightValue = rightOperand.value; |
| 3530 if (rightValue == null) { | 3785 if (rightValue == null) { |
| 3531 return UNKNOWN_VALUE; | 3786 return UNKNOWN_VALUE; |
| 3532 } else if (rightValue == 0) { | 3787 } else if (rightValue == 0) { |
| 3533 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_IDB
ZE); | 3788 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_IDB
ZE); |
| 3534 } | 3789 } |
| 3535 return new IntState(value ~/ rightValue); | 3790 return new IntState(value ~/ rightValue); |
| 3536 } else if (rightOperand is DoubleState) { | 3791 } else if (rightOperand is DoubleState) { |
| 3537 double rightValue = rightOperand.value; | 3792 double rightValue = rightOperand.value; |
| 3538 if (rightValue == null) { | 3793 if (rightValue == null) { |
| 3539 return UNKNOWN_VALUE; | 3794 return UNKNOWN_VALUE; |
| 3540 } | 3795 } |
| 3541 double result = value.toDouble() / rightValue; | 3796 double result = value.toDouble() / rightValue; |
| 3542 return new IntState(result.toInt()); | 3797 return new IntState(result.toInt()); |
| 3543 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3798 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3544 return UNKNOWN_VALUE; | 3799 return UNKNOWN_VALUE; |
| 3545 } | 3800 } |
| 3546 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3801 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3547 } | 3802 } |
| 3548 | 3803 |
| 3804 @override |
| 3549 bool get isBoolNumStringOrNull => true; | 3805 bool get isBoolNumStringOrNull => true; |
| 3550 | 3806 |
| 3807 @override |
| 3551 BoolState lessThan(InstanceState rightOperand) { | 3808 BoolState lessThan(InstanceState rightOperand) { |
| 3552 assertNumOrNull(rightOperand); | 3809 assertNumOrNull(rightOperand); |
| 3553 if (value == null) { | 3810 if (value == null) { |
| 3554 return BoolState.UNKNOWN_VALUE; | 3811 return BoolState.UNKNOWN_VALUE; |
| 3555 } | 3812 } |
| 3556 if (rightOperand is IntState) { | 3813 if (rightOperand is IntState) { |
| 3557 int rightValue = rightOperand.value; | 3814 int rightValue = rightOperand.value; |
| 3558 if (rightValue == null) { | 3815 if (rightValue == null) { |
| 3559 return BoolState.UNKNOWN_VALUE; | 3816 return BoolState.UNKNOWN_VALUE; |
| 3560 } | 3817 } |
| 3561 return BoolState.from(value.compareTo(rightValue) < 0); | 3818 return BoolState.from(value.compareTo(rightValue) < 0); |
| 3562 } else if (rightOperand is DoubleState) { | 3819 } else if (rightOperand is DoubleState) { |
| 3563 double rightValue = rightOperand.value; | 3820 double rightValue = rightOperand.value; |
| 3564 if (rightValue == null) { | 3821 if (rightValue == null) { |
| 3565 return BoolState.UNKNOWN_VALUE; | 3822 return BoolState.UNKNOWN_VALUE; |
| 3566 } | 3823 } |
| 3567 return BoolState.from(value.toDouble() < rightValue); | 3824 return BoolState.from(value.toDouble() < rightValue); |
| 3568 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3825 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3569 return BoolState.UNKNOWN_VALUE; | 3826 return BoolState.UNKNOWN_VALUE; |
| 3570 } | 3827 } |
| 3571 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3828 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3572 } | 3829 } |
| 3573 | 3830 |
| 3831 @override |
| 3574 BoolState lessThanOrEqual(InstanceState rightOperand) { | 3832 BoolState lessThanOrEqual(InstanceState rightOperand) { |
| 3575 assertNumOrNull(rightOperand); | 3833 assertNumOrNull(rightOperand); |
| 3576 if (value == null) { | 3834 if (value == null) { |
| 3577 return BoolState.UNKNOWN_VALUE; | 3835 return BoolState.UNKNOWN_VALUE; |
| 3578 } | 3836 } |
| 3579 if (rightOperand is IntState) { | 3837 if (rightOperand is IntState) { |
| 3580 int rightValue = rightOperand.value; | 3838 int rightValue = rightOperand.value; |
| 3581 if (rightValue == null) { | 3839 if (rightValue == null) { |
| 3582 return BoolState.UNKNOWN_VALUE; | 3840 return BoolState.UNKNOWN_VALUE; |
| 3583 } | 3841 } |
| 3584 return BoolState.from(value.compareTo(rightValue) <= 0); | 3842 return BoolState.from(value.compareTo(rightValue) <= 0); |
| 3585 } else if (rightOperand is DoubleState) { | 3843 } else if (rightOperand is DoubleState) { |
| 3586 double rightValue = rightOperand.value; | 3844 double rightValue = rightOperand.value; |
| 3587 if (rightValue == null) { | 3845 if (rightValue == null) { |
| 3588 return BoolState.UNKNOWN_VALUE; | 3846 return BoolState.UNKNOWN_VALUE; |
| 3589 } | 3847 } |
| 3590 return BoolState.from(value.toDouble() <= rightValue); | 3848 return BoolState.from(value.toDouble() <= rightValue); |
| 3591 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3849 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3592 return BoolState.UNKNOWN_VALUE; | 3850 return BoolState.UNKNOWN_VALUE; |
| 3593 } | 3851 } |
| 3594 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3852 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3595 } | 3853 } |
| 3596 | 3854 |
| 3855 @override |
| 3597 NumState minus(InstanceState rightOperand) { | 3856 NumState minus(InstanceState rightOperand) { |
| 3598 assertNumOrNull(rightOperand); | 3857 assertNumOrNull(rightOperand); |
| 3599 if (value == null) { | 3858 if (value == null) { |
| 3600 if (rightOperand is DoubleState) { | 3859 if (rightOperand is DoubleState) { |
| 3601 return DoubleState.UNKNOWN_VALUE; | 3860 return DoubleState.UNKNOWN_VALUE; |
| 3602 } | 3861 } |
| 3603 return UNKNOWN_VALUE; | 3862 return UNKNOWN_VALUE; |
| 3604 } | 3863 } |
| 3605 if (rightOperand is IntState) { | 3864 if (rightOperand is IntState) { |
| 3606 int rightValue = rightOperand.value; | 3865 int rightValue = rightOperand.value; |
| 3607 if (rightValue == null) { | 3866 if (rightValue == null) { |
| 3608 return UNKNOWN_VALUE; | 3867 return UNKNOWN_VALUE; |
| 3609 } | 3868 } |
| 3610 return new IntState(value - rightValue); | 3869 return new IntState(value - rightValue); |
| 3611 } else if (rightOperand is DoubleState) { | 3870 } else if (rightOperand is DoubleState) { |
| 3612 double rightValue = rightOperand.value; | 3871 double rightValue = rightOperand.value; |
| 3613 if (rightValue == null) { | 3872 if (rightValue == null) { |
| 3614 return DoubleState.UNKNOWN_VALUE; | 3873 return DoubleState.UNKNOWN_VALUE; |
| 3615 } | 3874 } |
| 3616 return new DoubleState(value.toDouble() - rightValue); | 3875 return new DoubleState(value.toDouble() - rightValue); |
| 3617 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3876 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3618 return UNKNOWN_VALUE; | 3877 return UNKNOWN_VALUE; |
| 3619 } | 3878 } |
| 3620 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3879 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3621 } | 3880 } |
| 3622 | 3881 |
| 3882 @override |
| 3623 NumState negated() { | 3883 NumState negated() { |
| 3624 if (value == null) { | 3884 if (value == null) { |
| 3625 return UNKNOWN_VALUE; | 3885 return UNKNOWN_VALUE; |
| 3626 } | 3886 } |
| 3627 return new IntState(-value); | 3887 return new IntState(-value); |
| 3628 } | 3888 } |
| 3629 | 3889 |
| 3890 @override |
| 3630 NumState remainder(InstanceState rightOperand) { | 3891 NumState remainder(InstanceState rightOperand) { |
| 3631 assertNumOrNull(rightOperand); | 3892 assertNumOrNull(rightOperand); |
| 3632 if (value == null) { | 3893 if (value == null) { |
| 3633 if (rightOperand is DoubleState) { | 3894 if (rightOperand is DoubleState) { |
| 3634 return DoubleState.UNKNOWN_VALUE; | 3895 return DoubleState.UNKNOWN_VALUE; |
| 3635 } | 3896 } |
| 3636 return UNKNOWN_VALUE; | 3897 return UNKNOWN_VALUE; |
| 3637 } | 3898 } |
| 3638 if (rightOperand is IntState) { | 3899 if (rightOperand is IntState) { |
| 3639 int rightValue = rightOperand.value; | 3900 int rightValue = rightOperand.value; |
| 3640 if (rightValue == null) { | 3901 if (rightValue == null) { |
| 3641 return UNKNOWN_VALUE; | 3902 return UNKNOWN_VALUE; |
| 3642 } else if (rightValue == 0) { | 3903 } else if (rightValue == 0) { |
| 3643 return new DoubleState(value.toDouble() % rightValue.toDouble()); | 3904 return new DoubleState(value.toDouble() % rightValue.toDouble()); |
| 3644 } | 3905 } |
| 3645 return new IntState(value.remainder(rightValue)); | 3906 return new IntState(value.remainder(rightValue)); |
| 3646 } else if (rightOperand is DoubleState) { | 3907 } else if (rightOperand is DoubleState) { |
| 3647 double rightValue = rightOperand.value; | 3908 double rightValue = rightOperand.value; |
| 3648 if (rightValue == null) { | 3909 if (rightValue == null) { |
| 3649 return DoubleState.UNKNOWN_VALUE; | 3910 return DoubleState.UNKNOWN_VALUE; |
| 3650 } | 3911 } |
| 3651 return new DoubleState(value.toDouble() % rightValue); | 3912 return new DoubleState(value.toDouble() % rightValue); |
| 3652 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3913 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3653 return UNKNOWN_VALUE; | 3914 return UNKNOWN_VALUE; |
| 3654 } | 3915 } |
| 3655 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3916 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3656 } | 3917 } |
| 3657 | 3918 |
| 3919 @override |
| 3658 IntState shiftLeft(InstanceState rightOperand) { | 3920 IntState shiftLeft(InstanceState rightOperand) { |
| 3659 assertIntOrNull(rightOperand); | 3921 assertIntOrNull(rightOperand); |
| 3660 if (value == null) { | 3922 if (value == null) { |
| 3661 return UNKNOWN_VALUE; | 3923 return UNKNOWN_VALUE; |
| 3662 } | 3924 } |
| 3663 if (rightOperand is IntState) { | 3925 if (rightOperand is IntState) { |
| 3664 int rightValue = rightOperand.value; | 3926 int rightValue = rightOperand.value; |
| 3665 if (rightValue == null) { | 3927 if (rightValue == null) { |
| 3666 return UNKNOWN_VALUE; | 3928 return UNKNOWN_VALUE; |
| 3667 } else if (rightValue.bitLength > 31) { | 3929 } else if (rightValue.bitLength > 31) { |
| 3668 return UNKNOWN_VALUE; | 3930 return UNKNOWN_VALUE; |
| 3669 } | 3931 } |
| 3670 return new IntState(value << rightValue); | 3932 return new IntState(value << rightValue); |
| 3671 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3933 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3672 return UNKNOWN_VALUE; | 3934 return UNKNOWN_VALUE; |
| 3673 } | 3935 } |
| 3674 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3936 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3675 } | 3937 } |
| 3676 | 3938 |
| 3939 @override |
| 3677 IntState shiftRight(InstanceState rightOperand) { | 3940 IntState shiftRight(InstanceState rightOperand) { |
| 3678 assertIntOrNull(rightOperand); | 3941 assertIntOrNull(rightOperand); |
| 3679 if (value == null) { | 3942 if (value == null) { |
| 3680 return UNKNOWN_VALUE; | 3943 return UNKNOWN_VALUE; |
| 3681 } | 3944 } |
| 3682 if (rightOperand is IntState) { | 3945 if (rightOperand is IntState) { |
| 3683 int rightValue = rightOperand.value; | 3946 int rightValue = rightOperand.value; |
| 3684 if (rightValue == null) { | 3947 if (rightValue == null) { |
| 3685 return UNKNOWN_VALUE; | 3948 return UNKNOWN_VALUE; |
| 3686 } else if (rightValue.bitLength > 31) { | 3949 } else if (rightValue.bitLength > 31) { |
| 3687 return UNKNOWN_VALUE; | 3950 return UNKNOWN_VALUE; |
| 3688 } | 3951 } |
| 3689 return new IntState(value >> rightValue); | 3952 return new IntState(value >> rightValue); |
| 3690 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3953 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3691 return UNKNOWN_VALUE; | 3954 return UNKNOWN_VALUE; |
| 3692 } | 3955 } |
| 3693 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3956 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3694 } | 3957 } |
| 3695 | 3958 |
| 3959 @override |
| 3696 NumState times(InstanceState rightOperand) { | 3960 NumState times(InstanceState rightOperand) { |
| 3697 assertNumOrNull(rightOperand); | 3961 assertNumOrNull(rightOperand); |
| 3698 if (value == null) { | 3962 if (value == null) { |
| 3699 if (rightOperand is DoubleState) { | 3963 if (rightOperand is DoubleState) { |
| 3700 return DoubleState.UNKNOWN_VALUE; | 3964 return DoubleState.UNKNOWN_VALUE; |
| 3701 } | 3965 } |
| 3702 return UNKNOWN_VALUE; | 3966 return UNKNOWN_VALUE; |
| 3703 } | 3967 } |
| 3704 if (rightOperand is IntState) { | 3968 if (rightOperand is IntState) { |
| 3705 int rightValue = rightOperand.value; | 3969 int rightValue = rightOperand.value; |
| 3706 if (rightValue == null) { | 3970 if (rightValue == null) { |
| 3707 return UNKNOWN_VALUE; | 3971 return UNKNOWN_VALUE; |
| 3708 } | 3972 } |
| 3709 return new IntState(value * rightValue); | 3973 return new IntState(value * rightValue); |
| 3710 } else if (rightOperand is DoubleState) { | 3974 } else if (rightOperand is DoubleState) { |
| 3711 double rightValue = rightOperand.value; | 3975 double rightValue = rightOperand.value; |
| 3712 if (rightValue == null) { | 3976 if (rightValue == null) { |
| 3713 return DoubleState.UNKNOWN_VALUE; | 3977 return DoubleState.UNKNOWN_VALUE; |
| 3714 } | 3978 } |
| 3715 return new DoubleState(value.toDouble() * rightValue); | 3979 return new DoubleState(value.toDouble() * rightValue); |
| 3716 } else if (rightOperand is DynamicState || rightOperand is NumState) { | 3980 } else if (rightOperand is DynamicState || rightOperand is NumState) { |
| 3717 return UNKNOWN_VALUE; | 3981 return UNKNOWN_VALUE; |
| 3718 } | 3982 } |
| 3719 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 3983 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3720 } | 3984 } |
| 3721 | 3985 |
| 3986 @override |
| 3722 String toString() => value == null ? "-unknown-" : value.toString(); | 3987 String toString() => value == null ? "-unknown-" : value.toString(); |
| 3723 } | 3988 } |
| 3724 | 3989 |
| 3725 /** | 3990 /** |
| 3726 * The unique instance of the class `ListState` represents the state of an objec
t representing | 3991 * The unique instance of the class `ListState` represents the state of an objec
t representing |
| 3727 * a list. | 3992 * a list. |
| 3728 */ | 3993 */ |
| 3729 class ListState extends InstanceState { | 3994 class ListState extends InstanceState { |
| 3730 /** | 3995 /** |
| 3731 * The elements of the list. | 3996 * The elements of the list. |
| 3732 */ | 3997 */ |
| 3733 List<DartObjectImpl> _elements; | 3998 List<DartObjectImpl> _elements; |
| 3734 | 3999 |
| 3735 /** | 4000 /** |
| 3736 * Initialize a newly created state to represent a list with the given element
s. | 4001 * Initialize a newly created state to represent a list with the given element
s. |
| 3737 * | 4002 * |
| 3738 * @param elements the elements of the list | 4003 * @param elements the elements of the list |
| 3739 */ | 4004 */ |
| 3740 ListState(List<DartObjectImpl> elements) { | 4005 ListState(List<DartObjectImpl> elements) { |
| 3741 this._elements = elements; | 4006 this._elements = elements; |
| 3742 } | 4007 } |
| 3743 | 4008 |
| 4009 @override |
| 3744 StringState convertToString() => StringState.UNKNOWN_VALUE; | 4010 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 3745 | 4011 |
| 4012 @override |
| 3746 BoolState equalEqual(InstanceState rightOperand) { | 4013 BoolState equalEqual(InstanceState rightOperand) { |
| 3747 assertBoolNumStringOrNull(rightOperand); | 4014 assertBoolNumStringOrNull(rightOperand); |
| 3748 if (rightOperand is DynamicState) { | 4015 if (rightOperand is DynamicState) { |
| 3749 return BoolState.UNKNOWN_VALUE; | 4016 return BoolState.UNKNOWN_VALUE; |
| 3750 } | 4017 } |
| 3751 return BoolState.from(this == rightOperand); | 4018 return BoolState.from(this == rightOperand); |
| 3752 } | 4019 } |
| 3753 | 4020 |
| 4021 @override |
| 3754 bool operator ==(Object object) { | 4022 bool operator ==(Object object) { |
| 3755 if (object is! ListState) { | 4023 if (object is! ListState) { |
| 3756 return false; | 4024 return false; |
| 3757 } | 4025 } |
| 3758 List<DartObjectImpl> otherElements = (object as ListState)._elements; | 4026 List<DartObjectImpl> otherElements = (object as ListState)._elements; |
| 3759 int count = _elements.length; | 4027 int count = _elements.length; |
| 3760 if (otherElements.length != count) { | 4028 if (otherElements.length != count) { |
| 3761 return false; | 4029 return false; |
| 3762 } else if (count == 0) { | 4030 } else if (count == 0) { |
| 3763 return true; | 4031 return true; |
| 3764 } | 4032 } |
| 3765 for (int i = 0; i < count; i++) { | 4033 for (int i = 0; i < count; i++) { |
| 3766 if (_elements[i] != otherElements[i]) { | 4034 if (_elements[i] != otherElements[i]) { |
| 3767 return false; | 4035 return false; |
| 3768 } | 4036 } |
| 3769 } | 4037 } |
| 3770 return true; | 4038 return true; |
| 3771 } | 4039 } |
| 3772 | 4040 |
| 4041 @override |
| 3773 String get typeName => "List"; | 4042 String get typeName => "List"; |
| 3774 | 4043 |
| 4044 @override |
| 3775 List<Object> get value { | 4045 List<Object> get value { |
| 3776 int count = _elements.length; | 4046 int count = _elements.length; |
| 3777 List<Object> result = new List<Object>(count); | 4047 List<Object> result = new List<Object>(count); |
| 3778 for (int i = 0; i < count; i++) { | 4048 for (int i = 0; i < count; i++) { |
| 3779 DartObjectImpl element = _elements[i]; | 4049 DartObjectImpl element = _elements[i]; |
| 3780 if (!element.hasExactValue) { | 4050 if (!element.hasExactValue) { |
| 3781 return null; | 4051 return null; |
| 3782 } | 4052 } |
| 3783 result[i] = element.value; | 4053 result[i] = element.value; |
| 3784 } | 4054 } |
| 3785 return result; | 4055 return result; |
| 3786 } | 4056 } |
| 3787 | 4057 |
| 4058 @override |
| 3788 bool get hasExactValue { | 4059 bool get hasExactValue { |
| 3789 int count = _elements.length; | 4060 int count = _elements.length; |
| 3790 for (int i = 0; i < count; i++) { | 4061 for (int i = 0; i < count; i++) { |
| 3791 if (!_elements[i].hasExactValue) { | 4062 if (!_elements[i].hasExactValue) { |
| 3792 return false; | 4063 return false; |
| 3793 } | 4064 } |
| 3794 } | 4065 } |
| 3795 return true; | 4066 return true; |
| 3796 } | 4067 } |
| 3797 | 4068 |
| 4069 @override |
| 3798 int get hashCode { | 4070 int get hashCode { |
| 3799 int value = 0; | 4071 int value = 0; |
| 3800 int count = _elements.length; | 4072 int count = _elements.length; |
| 3801 for (int i = 0; i < count; i++) { | 4073 for (int i = 0; i < count; i++) { |
| 3802 value = (value << 3) ^ _elements[i].hashCode; | 4074 value = (value << 3) ^ _elements[i].hashCode; |
| 3803 } | 4075 } |
| 3804 return value; | 4076 return value; |
| 3805 } | 4077 } |
| 3806 } | 4078 } |
| 3807 | 4079 |
| 3808 /** | 4080 /** |
| 3809 * The unique instance of the class `ListState` represents the state of an objec
t representing | 4081 * The unique instance of the class `ListState` represents the state of an objec
t representing |
| 3810 * a map. | 4082 * a map. |
| 3811 */ | 4083 */ |
| 3812 class MapState extends InstanceState { | 4084 class MapState extends InstanceState { |
| 3813 /** | 4085 /** |
| 3814 * The entries in the map. | 4086 * The entries in the map. |
| 3815 */ | 4087 */ |
| 3816 Map<DartObjectImpl, DartObjectImpl> _entries; | 4088 Map<DartObjectImpl, DartObjectImpl> _entries; |
| 3817 | 4089 |
| 3818 /** | 4090 /** |
| 3819 * Initialize a newly created state to represent a map with the given entries. | 4091 * Initialize a newly created state to represent a map with the given entries. |
| 3820 * | 4092 * |
| 3821 * @param entries the entries in the map | 4093 * @param entries the entries in the map |
| 3822 */ | 4094 */ |
| 3823 MapState(Map<DartObjectImpl, DartObjectImpl> entries) { | 4095 MapState(Map<DartObjectImpl, DartObjectImpl> entries) { |
| 3824 this._entries = entries; | 4096 this._entries = entries; |
| 3825 } | 4097 } |
| 3826 | 4098 |
| 4099 @override |
| 3827 StringState convertToString() => StringState.UNKNOWN_VALUE; | 4100 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 3828 | 4101 |
| 4102 @override |
| 3829 BoolState equalEqual(InstanceState rightOperand) { | 4103 BoolState equalEqual(InstanceState rightOperand) { |
| 3830 assertBoolNumStringOrNull(rightOperand); | 4104 assertBoolNumStringOrNull(rightOperand); |
| 3831 if (rightOperand is DynamicState) { | 4105 if (rightOperand is DynamicState) { |
| 3832 return BoolState.UNKNOWN_VALUE; | 4106 return BoolState.UNKNOWN_VALUE; |
| 3833 } | 4107 } |
| 3834 return BoolState.from(this == rightOperand); | 4108 return BoolState.from(this == rightOperand); |
| 3835 } | 4109 } |
| 3836 | 4110 |
| 4111 @override |
| 3837 bool operator ==(Object object) { | 4112 bool operator ==(Object object) { |
| 3838 if (object is! MapState) { | 4113 if (object is! MapState) { |
| 3839 return false; | 4114 return false; |
| 3840 } | 4115 } |
| 3841 Map<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)._en
tries; | 4116 Map<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)._en
tries; |
| 3842 int count = _entries.length; | 4117 int count = _entries.length; |
| 3843 if (otherElements.length != count) { | 4118 if (otherElements.length != count) { |
| 3844 return false; | 4119 return false; |
| 3845 } else if (count == 0) { | 4120 } else if (count == 0) { |
| 3846 return true; | 4121 return true; |
| 3847 } | 4122 } |
| 3848 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 4123 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { |
| 3849 DartObjectImpl key = entry.getKey(); | 4124 DartObjectImpl key = entry.getKey(); |
| 3850 DartObjectImpl value = entry.getValue(); | 4125 DartObjectImpl value = entry.getValue(); |
| 3851 DartObjectImpl otherValue = otherElements[key]; | 4126 DartObjectImpl otherValue = otherElements[key]; |
| 3852 if (value != otherValue) { | 4127 if (value != otherValue) { |
| 3853 return false; | 4128 return false; |
| 3854 } | 4129 } |
| 3855 } | 4130 } |
| 3856 return true; | 4131 return true; |
| 3857 } | 4132 } |
| 3858 | 4133 |
| 4134 @override |
| 3859 String get typeName => "Map"; | 4135 String get typeName => "Map"; |
| 3860 | 4136 |
| 4137 @override |
| 3861 Map<Object, Object> get value { | 4138 Map<Object, Object> get value { |
| 3862 Map<Object, Object> result = new Map<Object, Object>(); | 4139 Map<Object, Object> result = new Map<Object, Object>(); |
| 3863 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 4140 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { |
| 3864 DartObjectImpl key = entry.getKey(); | 4141 DartObjectImpl key = entry.getKey(); |
| 3865 DartObjectImpl value = entry.getValue(); | 4142 DartObjectImpl value = entry.getValue(); |
| 3866 if (!key.hasExactValue || !value.hasExactValue) { | 4143 if (!key.hasExactValue || !value.hasExactValue) { |
| 3867 return null; | 4144 return null; |
| 3868 } | 4145 } |
| 3869 result[key.value] = value.value; | 4146 result[key.value] = value.value; |
| 3870 } | 4147 } |
| 3871 return result; | 4148 return result; |
| 3872 } | 4149 } |
| 3873 | 4150 |
| 4151 @override |
| 3874 bool get hasExactValue { | 4152 bool get hasExactValue { |
| 3875 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 4153 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { |
| 3876 if (!entry.getKey().hasExactValue || !entry.getValue().hasExactValue) { | 4154 if (!entry.getKey().hasExactValue || !entry.getValue().hasExactValue) { |
| 3877 return false; | 4155 return false; |
| 3878 } | 4156 } |
| 3879 } | 4157 } |
| 3880 return true; | 4158 return true; |
| 3881 } | 4159 } |
| 3882 | 4160 |
| 4161 @override |
| 3883 int get hashCode { | 4162 int get hashCode { |
| 3884 int value = 0; | 4163 int value = 0; |
| 3885 for (DartObjectImpl key in _entries.keys.toSet()) { | 4164 for (DartObjectImpl key in _entries.keys.toSet()) { |
| 3886 value = (value << 3) ^ key.hashCode; | 4165 value = (value << 3) ^ key.hashCode; |
| 3887 } | 4166 } |
| 3888 return value; | 4167 return value; |
| 3889 } | 4168 } |
| 3890 } | 4169 } |
| 3891 | 4170 |
| 3892 /** | 4171 /** |
| 3893 * The unique instance of the class `NullState` represents the state of the valu
e 'null'. | 4172 * The unique instance of the class `NullState` represents the state of the valu
e 'null'. |
| 3894 */ | 4173 */ |
| 3895 class NullState extends InstanceState { | 4174 class NullState extends InstanceState { |
| 3896 /** | 4175 /** |
| 3897 * An instance representing the boolean value 'true'. | 4176 * An instance representing the boolean value 'true'. |
| 3898 */ | 4177 */ |
| 3899 static NullState NULL_STATE = new NullState(); | 4178 static NullState NULL_STATE = new NullState(); |
| 3900 | 4179 |
| 4180 @override |
| 3901 BoolState convertToBool() { | 4181 BoolState convertToBool() { |
| 3902 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 4182 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3903 } | 4183 } |
| 3904 | 4184 |
| 4185 @override |
| 3905 StringState convertToString() => new StringState("null"); | 4186 StringState convertToString() => new StringState("null"); |
| 3906 | 4187 |
| 4188 @override |
| 3907 BoolState equalEqual(InstanceState rightOperand) { | 4189 BoolState equalEqual(InstanceState rightOperand) { |
| 3908 assertBoolNumStringOrNull(rightOperand); | 4190 assertBoolNumStringOrNull(rightOperand); |
| 3909 if (rightOperand is DynamicState) { | 4191 if (rightOperand is DynamicState) { |
| 3910 return BoolState.UNKNOWN_VALUE; | 4192 return BoolState.UNKNOWN_VALUE; |
| 3911 } | 4193 } |
| 3912 return BoolState.from(rightOperand is NullState); | 4194 return BoolState.from(rightOperand is NullState); |
| 3913 } | 4195 } |
| 3914 | 4196 |
| 4197 @override |
| 3915 bool operator ==(Object object) => object is NullState; | 4198 bool operator ==(Object object) => object is NullState; |
| 3916 | 4199 |
| 4200 @override |
| 3917 String get typeName => "Null"; | 4201 String get typeName => "Null"; |
| 3918 | 4202 |
| 4203 @override |
| 3919 bool get hasExactValue => true; | 4204 bool get hasExactValue => true; |
| 3920 | 4205 |
| 4206 @override |
| 3921 int get hashCode => 0; | 4207 int get hashCode => 0; |
| 3922 | 4208 |
| 4209 @override |
| 3923 bool get isBoolNumStringOrNull => true; | 4210 bool get isBoolNumStringOrNull => true; |
| 3924 | 4211 |
| 4212 @override |
| 3925 BoolState logicalNot() { | 4213 BoolState logicalNot() { |
| 3926 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); | 4214 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTI
ON); |
| 3927 } | 4215 } |
| 3928 | 4216 |
| 4217 @override |
| 3929 String toString() => "null"; | 4218 String toString() => "null"; |
| 3930 } | 4219 } |
| 3931 | 4220 |
| 3932 /** | 4221 /** |
| 3933 * Instances of the class `NumState` represent the state of an object representi
ng a number of | 4222 * Instances of the class `NumState` represent the state of an object representi
ng a number of |
| 3934 * an unknown type (a 'num'). | 4223 * an unknown type (a 'num'). |
| 3935 */ | 4224 */ |
| 3936 class NumState extends InstanceState { | 4225 class NumState extends InstanceState { |
| 3937 /** | 4226 /** |
| 3938 * A state that can be used to represent a number whose value is not known. | 4227 * A state that can be used to represent a number whose value is not known. |
| 3939 */ | 4228 */ |
| 3940 static NumState UNKNOWN_VALUE = new NumState(); | 4229 static NumState UNKNOWN_VALUE = new NumState(); |
| 3941 | 4230 |
| 4231 @override |
| 3942 NumState add(InstanceState rightOperand) { | 4232 NumState add(InstanceState rightOperand) { |
| 3943 assertNumOrNull(rightOperand); | 4233 assertNumOrNull(rightOperand); |
| 3944 return UNKNOWN_VALUE; | 4234 return UNKNOWN_VALUE; |
| 3945 } | 4235 } |
| 3946 | 4236 |
| 4237 @override |
| 3947 StringState convertToString() => StringState.UNKNOWN_VALUE; | 4238 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 3948 | 4239 |
| 4240 @override |
| 3949 NumState divide(InstanceState rightOperand) { | 4241 NumState divide(InstanceState rightOperand) { |
| 3950 assertNumOrNull(rightOperand); | 4242 assertNumOrNull(rightOperand); |
| 3951 return UNKNOWN_VALUE; | 4243 return UNKNOWN_VALUE; |
| 3952 } | 4244 } |
| 3953 | 4245 |
| 4246 @override |
| 3954 bool operator ==(Object object) => object is NumState; | 4247 bool operator ==(Object object) => object is NumState; |
| 3955 | 4248 |
| 4249 @override |
| 3956 BoolState equalEqual(InstanceState rightOperand) { | 4250 BoolState equalEqual(InstanceState rightOperand) { |
| 3957 assertBoolNumStringOrNull(rightOperand); | 4251 assertBoolNumStringOrNull(rightOperand); |
| 3958 return BoolState.UNKNOWN_VALUE; | 4252 return BoolState.UNKNOWN_VALUE; |
| 3959 } | 4253 } |
| 3960 | 4254 |
| 4255 @override |
| 3961 String get typeName => "num"; | 4256 String get typeName => "num"; |
| 3962 | 4257 |
| 4258 @override |
| 3963 BoolState greaterThan(InstanceState rightOperand) { | 4259 BoolState greaterThan(InstanceState rightOperand) { |
| 3964 assertNumOrNull(rightOperand); | 4260 assertNumOrNull(rightOperand); |
| 3965 return BoolState.UNKNOWN_VALUE; | 4261 return BoolState.UNKNOWN_VALUE; |
| 3966 } | 4262 } |
| 3967 | 4263 |
| 4264 @override |
| 3968 BoolState greaterThanOrEqual(InstanceState rightOperand) { | 4265 BoolState greaterThanOrEqual(InstanceState rightOperand) { |
| 3969 assertNumOrNull(rightOperand); | 4266 assertNumOrNull(rightOperand); |
| 3970 return BoolState.UNKNOWN_VALUE; | 4267 return BoolState.UNKNOWN_VALUE; |
| 3971 } | 4268 } |
| 3972 | 4269 |
| 4270 @override |
| 3973 int get hashCode => 7; | 4271 int get hashCode => 7; |
| 3974 | 4272 |
| 4273 @override |
| 3975 IntState integerDivide(InstanceState rightOperand) { | 4274 IntState integerDivide(InstanceState rightOperand) { |
| 3976 assertNumOrNull(rightOperand); | 4275 assertNumOrNull(rightOperand); |
| 3977 if (rightOperand is IntState) { | 4276 if (rightOperand is IntState) { |
| 3978 int rightValue = rightOperand.value; | 4277 int rightValue = rightOperand.value; |
| 3979 if (rightValue == null) { | 4278 if (rightValue == null) { |
| 3980 return IntState.UNKNOWN_VALUE; | 4279 return IntState.UNKNOWN_VALUE; |
| 3981 } else if (rightValue == 0) { | 4280 } else if (rightValue == 0) { |
| 3982 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_IDB
ZE); | 4281 throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_IDB
ZE); |
| 3983 } | 4282 } |
| 3984 } else if (rightOperand is DynamicState) { | 4283 } else if (rightOperand is DynamicState) { |
| 3985 return IntState.UNKNOWN_VALUE; | 4284 return IntState.UNKNOWN_VALUE; |
| 3986 } | 4285 } |
| 3987 return IntState.UNKNOWN_VALUE; | 4286 return IntState.UNKNOWN_VALUE; |
| 3988 } | 4287 } |
| 3989 | 4288 |
| 4289 @override |
| 3990 bool get isBoolNumStringOrNull => true; | 4290 bool get isBoolNumStringOrNull => true; |
| 3991 | 4291 |
| 4292 @override |
| 3992 BoolState lessThan(InstanceState rightOperand) { | 4293 BoolState lessThan(InstanceState rightOperand) { |
| 3993 assertNumOrNull(rightOperand); | 4294 assertNumOrNull(rightOperand); |
| 3994 return BoolState.UNKNOWN_VALUE; | 4295 return BoolState.UNKNOWN_VALUE; |
| 3995 } | 4296 } |
| 3996 | 4297 |
| 4298 @override |
| 3997 BoolState lessThanOrEqual(InstanceState rightOperand) { | 4299 BoolState lessThanOrEqual(InstanceState rightOperand) { |
| 3998 assertNumOrNull(rightOperand); | 4300 assertNumOrNull(rightOperand); |
| 3999 return BoolState.UNKNOWN_VALUE; | 4301 return BoolState.UNKNOWN_VALUE; |
| 4000 } | 4302 } |
| 4001 | 4303 |
| 4304 @override |
| 4002 NumState minus(InstanceState rightOperand) { | 4305 NumState minus(InstanceState rightOperand) { |
| 4003 assertNumOrNull(rightOperand); | 4306 assertNumOrNull(rightOperand); |
| 4004 return UNKNOWN_VALUE; | 4307 return UNKNOWN_VALUE; |
| 4005 } | 4308 } |
| 4006 | 4309 |
| 4310 @override |
| 4007 NumState negated() => UNKNOWN_VALUE; | 4311 NumState negated() => UNKNOWN_VALUE; |
| 4008 | 4312 |
| 4313 @override |
| 4009 NumState remainder(InstanceState rightOperand) { | 4314 NumState remainder(InstanceState rightOperand) { |
| 4010 assertNumOrNull(rightOperand); | 4315 assertNumOrNull(rightOperand); |
| 4011 return UNKNOWN_VALUE; | 4316 return UNKNOWN_VALUE; |
| 4012 } | 4317 } |
| 4013 | 4318 |
| 4319 @override |
| 4014 NumState times(InstanceState rightOperand) { | 4320 NumState times(InstanceState rightOperand) { |
| 4015 assertNumOrNull(rightOperand); | 4321 assertNumOrNull(rightOperand); |
| 4016 return UNKNOWN_VALUE; | 4322 return UNKNOWN_VALUE; |
| 4017 } | 4323 } |
| 4018 | 4324 |
| 4325 @override |
| 4019 String toString() => "-unknown-"; | 4326 String toString() => "-unknown-"; |
| 4020 } | 4327 } |
| 4021 | 4328 |
| 4022 /** | 4329 /** |
| 4023 * Instances of the class `StringState` represent the state of an object represe
nting a | 4330 * Instances of the class `StringState` represent the state of an object represe
nting a |
| 4024 * string. | 4331 * string. |
| 4025 */ | 4332 */ |
| 4026 class StringState extends InstanceState { | 4333 class StringState extends InstanceState { |
| 4027 /** | 4334 /** |
| 4028 * The value of this instance. | 4335 * The value of this instance. |
| 4029 */ | 4336 */ |
| 4030 final String value; | 4337 final String value; |
| 4031 | 4338 |
| 4032 /** | 4339 /** |
| 4033 * A state that can be used to represent a double whose value is not known. | 4340 * A state that can be used to represent a double whose value is not known. |
| 4034 */ | 4341 */ |
| 4035 static StringState UNKNOWN_VALUE = new StringState(null); | 4342 static StringState UNKNOWN_VALUE = new StringState(null); |
| 4036 | 4343 |
| 4037 /** | 4344 /** |
| 4038 * Initialize a newly created state to represent the given value. | 4345 * Initialize a newly created state to represent the given value. |
| 4039 * | 4346 * |
| 4040 * @param value the value of this instance | 4347 * @param value the value of this instance |
| 4041 */ | 4348 */ |
| 4042 StringState(this.value); | 4349 StringState(this.value); |
| 4043 | 4350 |
| 4351 @override |
| 4044 StringState concatenate(InstanceState rightOperand) { | 4352 StringState concatenate(InstanceState rightOperand) { |
| 4045 if (value == null) { | 4353 if (value == null) { |
| 4046 return UNKNOWN_VALUE; | 4354 return UNKNOWN_VALUE; |
| 4047 } | 4355 } |
| 4048 if (rightOperand is StringState) { | 4356 if (rightOperand is StringState) { |
| 4049 String rightValue = rightOperand.value; | 4357 String rightValue = rightOperand.value; |
| 4050 if (rightValue == null) { | 4358 if (rightValue == null) { |
| 4051 return UNKNOWN_VALUE; | 4359 return UNKNOWN_VALUE; |
| 4052 } | 4360 } |
| 4053 return new StringState("${value}${rightValue}"); | 4361 return new StringState("${value}${rightValue}"); |
| 4054 } else if (rightOperand is DynamicState) { | 4362 } else if (rightOperand is DynamicState) { |
| 4055 return UNKNOWN_VALUE; | 4363 return UNKNOWN_VALUE; |
| 4056 } | 4364 } |
| 4057 return super.concatenate(rightOperand); | 4365 return super.concatenate(rightOperand); |
| 4058 } | 4366 } |
| 4059 | 4367 |
| 4368 @override |
| 4060 StringState convertToString() => this; | 4369 StringState convertToString() => this; |
| 4061 | 4370 |
| 4371 @override |
| 4062 BoolState equalEqual(InstanceState rightOperand) { | 4372 BoolState equalEqual(InstanceState rightOperand) { |
| 4063 assertBoolNumStringOrNull(rightOperand); | 4373 assertBoolNumStringOrNull(rightOperand); |
| 4064 if (value == null) { | 4374 if (value == null) { |
| 4065 return BoolState.UNKNOWN_VALUE; | 4375 return BoolState.UNKNOWN_VALUE; |
| 4066 } | 4376 } |
| 4067 if (rightOperand is StringState) { | 4377 if (rightOperand is StringState) { |
| 4068 String rightValue = rightOperand.value; | 4378 String rightValue = rightOperand.value; |
| 4069 if (rightValue == null) { | 4379 if (rightValue == null) { |
| 4070 return BoolState.UNKNOWN_VALUE; | 4380 return BoolState.UNKNOWN_VALUE; |
| 4071 } | 4381 } |
| 4072 return BoolState.from(value == rightValue); | 4382 return BoolState.from(value == rightValue); |
| 4073 } else if (rightOperand is DynamicState) { | 4383 } else if (rightOperand is DynamicState) { |
| 4074 return BoolState.UNKNOWN_VALUE; | 4384 return BoolState.UNKNOWN_VALUE; |
| 4075 } | 4385 } |
| 4076 return BoolState.FALSE_STATE; | 4386 return BoolState.FALSE_STATE; |
| 4077 } | 4387 } |
| 4078 | 4388 |
| 4389 @override |
| 4079 bool operator ==(Object object) => object is StringState && (value == object.v
alue); | 4390 bool operator ==(Object object) => object is StringState && (value == object.v
alue); |
| 4080 | 4391 |
| 4392 @override |
| 4081 String get typeName => "String"; | 4393 String get typeName => "String"; |
| 4082 | 4394 |
| 4395 @override |
| 4083 bool get hasExactValue => true; | 4396 bool get hasExactValue => true; |
| 4084 | 4397 |
| 4398 @override |
| 4085 int get hashCode => value == null ? 0 : value.hashCode; | 4399 int get hashCode => value == null ? 0 : value.hashCode; |
| 4086 | 4400 |
| 4401 @override |
| 4087 bool get isBoolNumStringOrNull => true; | 4402 bool get isBoolNumStringOrNull => true; |
| 4088 | 4403 |
| 4404 @override |
| 4089 String toString() => value == null ? "-unknown-" : "'${value}'"; | 4405 String toString() => value == null ? "-unknown-" : "'${value}'"; |
| 4090 } | 4406 } |
| 4091 | 4407 |
| 4092 /** | 4408 /** |
| 4093 * Instances of the class `StringState` represent the state of an object represe
nting a | 4409 * Instances of the class `StringState` represent the state of an object represe
nting a |
| 4094 * symbol. | 4410 * symbol. |
| 4095 */ | 4411 */ |
| 4096 class SymbolState extends InstanceState { | 4412 class SymbolState extends InstanceState { |
| 4097 /** | 4413 /** |
| 4098 * The value of this instance. | 4414 * The value of this instance. |
| 4099 */ | 4415 */ |
| 4100 final String value; | 4416 final String value; |
| 4101 | 4417 |
| 4102 /** | 4418 /** |
| 4103 * Initialize a newly created state to represent the given value. | 4419 * Initialize a newly created state to represent the given value. |
| 4104 * | 4420 * |
| 4105 * @param value the value of this instance | 4421 * @param value the value of this instance |
| 4106 */ | 4422 */ |
| 4107 SymbolState(this.value); | 4423 SymbolState(this.value); |
| 4108 | 4424 |
| 4425 @override |
| 4109 StringState convertToString() { | 4426 StringState convertToString() { |
| 4110 if (value == null) { | 4427 if (value == null) { |
| 4111 return StringState.UNKNOWN_VALUE; | 4428 return StringState.UNKNOWN_VALUE; |
| 4112 } | 4429 } |
| 4113 return new StringState(value); | 4430 return new StringState(value); |
| 4114 } | 4431 } |
| 4115 | 4432 |
| 4433 @override |
| 4116 BoolState equalEqual(InstanceState rightOperand) { | 4434 BoolState equalEqual(InstanceState rightOperand) { |
| 4117 assertBoolNumStringOrNull(rightOperand); | 4435 assertBoolNumStringOrNull(rightOperand); |
| 4118 if (value == null) { | 4436 if (value == null) { |
| 4119 return BoolState.UNKNOWN_VALUE; | 4437 return BoolState.UNKNOWN_VALUE; |
| 4120 } | 4438 } |
| 4121 if (rightOperand is SymbolState) { | 4439 if (rightOperand is SymbolState) { |
| 4122 String rightValue = rightOperand.value; | 4440 String rightValue = rightOperand.value; |
| 4123 if (rightValue == null) { | 4441 if (rightValue == null) { |
| 4124 return BoolState.UNKNOWN_VALUE; | 4442 return BoolState.UNKNOWN_VALUE; |
| 4125 } | 4443 } |
| 4126 return BoolState.from(value == rightValue); | 4444 return BoolState.from(value == rightValue); |
| 4127 } else if (rightOperand is DynamicState) { | 4445 } else if (rightOperand is DynamicState) { |
| 4128 return BoolState.UNKNOWN_VALUE; | 4446 return BoolState.UNKNOWN_VALUE; |
| 4129 } | 4447 } |
| 4130 return BoolState.FALSE_STATE; | 4448 return BoolState.FALSE_STATE; |
| 4131 } | 4449 } |
| 4132 | 4450 |
| 4451 @override |
| 4133 bool operator ==(Object object) => object is SymbolState && (value == object.v
alue); | 4452 bool operator ==(Object object) => object is SymbolState && (value == object.v
alue); |
| 4134 | 4453 |
| 4454 @override |
| 4135 String get typeName => "Symbol"; | 4455 String get typeName => "Symbol"; |
| 4136 | 4456 |
| 4457 @override |
| 4137 bool get hasExactValue => true; | 4458 bool get hasExactValue => true; |
| 4138 | 4459 |
| 4460 @override |
| 4139 int get hashCode => value == null ? 0 : value.hashCode; | 4461 int get hashCode => value == null ? 0 : value.hashCode; |
| 4140 | 4462 |
| 4463 @override |
| 4141 String toString() => value == null ? "-unknown-" : "#${value}"; | 4464 String toString() => value == null ? "-unknown-" : "#${value}"; |
| 4142 } | 4465 } |
| 4143 | 4466 |
| 4144 /** | 4467 /** |
| 4145 * Instances of the class `TypeState` represent the state of an object represent
ing a type. | 4468 * Instances of the class `TypeState` represent the state of an object represent
ing a type. |
| 4146 */ | 4469 */ |
| 4147 class TypeState extends InstanceState { | 4470 class TypeState extends InstanceState { |
| 4148 /** | 4471 /** |
| 4149 * The element representing the type being modeled. | 4472 * The element representing the type being modeled. |
| 4150 */ | 4473 */ |
| 4151 Element _element; | 4474 Element _element; |
| 4152 | 4475 |
| 4153 /** | 4476 /** |
| 4154 * Initialize a newly created state to represent the given value. | 4477 * Initialize a newly created state to represent the given value. |
| 4155 * | 4478 * |
| 4156 * @param element the element representing the type being modeled | 4479 * @param element the element representing the type being modeled |
| 4157 */ | 4480 */ |
| 4158 TypeState(Element element) { | 4481 TypeState(Element element) { |
| 4159 this._element = element; | 4482 this._element = element; |
| 4160 } | 4483 } |
| 4161 | 4484 |
| 4485 @override |
| 4162 StringState convertToString() { | 4486 StringState convertToString() { |
| 4163 if (_element == null) { | 4487 if (_element == null) { |
| 4164 return StringState.UNKNOWN_VALUE; | 4488 return StringState.UNKNOWN_VALUE; |
| 4165 } | 4489 } |
| 4166 return new StringState(_element.name); | 4490 return new StringState(_element.name); |
| 4167 } | 4491 } |
| 4168 | 4492 |
| 4493 @override |
| 4169 bool operator ==(Object object) => object is TypeState && (_element == object.
_element); | 4494 bool operator ==(Object object) => object is TypeState && (_element == object.
_element); |
| 4170 | 4495 |
| 4496 @override |
| 4171 BoolState equalEqual(InstanceState rightOperand) { | 4497 BoolState equalEqual(InstanceState rightOperand) { |
| 4172 assertBoolNumStringOrNull(rightOperand); | 4498 assertBoolNumStringOrNull(rightOperand); |
| 4173 if (_element == null) { | 4499 if (_element == null) { |
| 4174 return BoolState.UNKNOWN_VALUE; | 4500 return BoolState.UNKNOWN_VALUE; |
| 4175 } | 4501 } |
| 4176 if (rightOperand is TypeState) { | 4502 if (rightOperand is TypeState) { |
| 4177 Element rightElement = rightOperand._element; | 4503 Element rightElement = rightOperand._element; |
| 4178 if (rightElement == null) { | 4504 if (rightElement == null) { |
| 4179 return BoolState.UNKNOWN_VALUE; | 4505 return BoolState.UNKNOWN_VALUE; |
| 4180 } | 4506 } |
| 4181 return BoolState.from(_element == rightElement); | 4507 return BoolState.from(_element == rightElement); |
| 4182 } else if (rightOperand is DynamicState) { | 4508 } else if (rightOperand is DynamicState) { |
| 4183 return BoolState.UNKNOWN_VALUE; | 4509 return BoolState.UNKNOWN_VALUE; |
| 4184 } | 4510 } |
| 4185 return BoolState.FALSE_STATE; | 4511 return BoolState.FALSE_STATE; |
| 4186 } | 4512 } |
| 4187 | 4513 |
| 4514 @override |
| 4188 String get typeName => "Type"; | 4515 String get typeName => "Type"; |
| 4189 | 4516 |
| 4517 @override |
| 4190 int get hashCode => _element == null ? 0 : _element.hashCode; | 4518 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 4191 | 4519 |
| 4520 @override |
| 4192 String toString() => _element == null ? "-unknown-" : _element.name; | 4521 String toString() => _element == null ? "-unknown-" : _element.name; |
| 4193 } | 4522 } |
| OLD | NEW |