| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // it, but we don't bother to check because there's nothing we can do abou
t it at this point. | 363 // it, but we don't bother to check because there's nothing we can do abou
t it at this point. |
| 364 // | 364 // |
| 365 return; | 365 return; |
| 366 } | 366 } |
| 367 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis
itor(_typeProvider)); | 367 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis
itor(_typeProvider)); |
| 368 (variable as VariableElementImpl).evaluationResult = result; | 368 (variable as VariableElementImpl).evaluationResult = result; |
| 369 if (result is ErrorResult) { | 369 if (result is ErrorResult) { |
| 370 List<AnalysisError> errors = new List<AnalysisError>(); | 370 List<AnalysisError> errors = new List<AnalysisError>(); |
| 371 for (ErrorResult_ErrorData data in result.errorData) { | 371 for (ErrorResult_ErrorData data in result.errorData) { |
| 372 AstNode node = data.node; | 372 AstNode node = data.node; |
| 373 Source source = variable.getAncestor(CompilationUnitElement).source; | 373 Source source = variable.getAncestor((element) => element is Compilation
UnitElement).source; |
| 374 errors.add(new AnalysisError.con2(source, node.offset, node.length, data
.errorCode, [])); | 374 errors.add(new AnalysisError.con2(source, node.offset, node.length, data
.errorCode, [])); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 /** | 379 /** |
| 380 * Generate an error indicating that the given variable is not a valid compile
-time constant | 380 * Generate an error indicating that the given variable is not a valid compile
-time constant |
| 381 * because it references at least one of the variables in the given cycle, eac
h of which directly | 381 * because it references at least one of the variables in the given cycle, eac
h of which directly |
| 382 * or indirectly references the variable. | 382 * or indirectly references the variable. |
| 383 * | 383 * |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } else if (operatorType == TokenType.TILDE_SLASH) { | 514 } else if (operatorType == TokenType.TILDE_SLASH) { |
| 515 return leftResult.integerDivide(_typeProvider, node, rightResult); | 515 return leftResult.integerDivide(_typeProvider, node, rightResult); |
| 516 } else { | 516 } else { |
| 517 // TODO(brianwilkerson) Figure out which error to report. | 517 // TODO(brianwilkerson) Figure out which error to report. |
| 518 return error(node, null); | 518 return error(node, null); |
| 519 } | 519 } |
| 520 break; | 520 break; |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => valid2(_typeP
rovider.boolType, BoolState.from(node.value)); | 524 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => valid(_typePr
ovider.boolType, BoolState.from(node.value)); |
| 525 | 525 |
| 526 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) { | 526 EvaluationResultImpl visitConditionalExpression(ConditionalExpression node) { |
| 527 Expression condition = node.condition; | 527 Expression condition = node.condition; |
| 528 EvaluationResultImpl conditionResult = condition.accept(this); | 528 EvaluationResultImpl conditionResult = condition.accept(this); |
| 529 EvaluationResultImpl thenResult = node.thenExpression.accept(this); | 529 EvaluationResultImpl thenResult = node.thenExpression.accept(this); |
| 530 EvaluationResultImpl elseResult = node.elseExpression.accept(this); | 530 EvaluationResultImpl elseResult = node.elseExpression.accept(this); |
| 531 if (conditionResult is ErrorResult) { | 531 if (conditionResult is ErrorResult) { |
| 532 return union(union(conditionResult as ErrorResult, thenResult), elseResult
); | 532 return union(union(conditionResult as ErrorResult, thenResult), elseResult
); |
| 533 } else if (!(conditionResult as ValidResult).isBool) { | 533 } else if (!(conditionResult as ValidResult).isBool) { |
| 534 return new ErrorResult.con1(condition, CompileTimeErrorCode.CONST_EVAL_TYP
E_BOOL); | 534 return new ErrorResult.con1(condition, CompileTimeErrorCode.CONST_EVAL_TYP
E_BOOL); |
| 535 } else if (thenResult is ErrorResult) { | 535 } else if (thenResult is ErrorResult) { |
| 536 return union(thenResult, elseResult); | 536 return union(thenResult, elseResult); |
| 537 } else if (elseResult is ErrorResult) { | 537 } else if (elseResult is ErrorResult) { |
| 538 return elseResult; | 538 return elseResult; |
| 539 } | 539 } |
| 540 conditionResult = conditionResult.applyBooleanConversion(_typeProvider, cond
ition); | 540 conditionResult = conditionResult.applyBooleanConversion(_typeProvider, cond
ition); |
| 541 if (conditionResult is ErrorResult) { | 541 if (conditionResult is ErrorResult) { |
| 542 return conditionResult; | 542 return conditionResult; |
| 543 } | 543 } |
| 544 ValidResult validResult = conditionResult as ValidResult; | 544 ValidResult validResult = conditionResult as ValidResult; |
| 545 if (validResult.isTrue) { | 545 if (validResult.isTrue) { |
| 546 return thenResult; | 546 return thenResult; |
| 547 } else if (validResult.isFalse) { | 547 } else if (validResult.isFalse) { |
| 548 return elseResult; | 548 return elseResult; |
| 549 } | 549 } |
| 550 InterfaceType thenType = (thenResult as ValidResult).value.type; | 550 InterfaceType thenType = (thenResult as ValidResult).value.type; |
| 551 InterfaceType elseType = (elseResult as ValidResult).value.type; | 551 InterfaceType elseType = (elseResult as ValidResult).value.type; |
| 552 return valid(thenType.getLeastUpperBound(elseType) as InterfaceType); | 552 return validWithUnknownValue(thenType.getLeastUpperBound(elseType) as Interf
aceType); |
| 553 } | 553 } |
| 554 | 554 |
| 555 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => valid2(_typePro
vider.doubleType, new DoubleState(node.value)); | 555 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => valid(_typeProv
ider.doubleType, new DoubleState(node.value)); |
| 556 | 556 |
| 557 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { | 557 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { |
| 558 if (!node.isConst) { | 558 if (!node.isConst) { |
| 559 // TODO(brianwilkerson) Figure out which error to report. | 559 // TODO(brianwilkerson) Figure out which error to report. |
| 560 return error(node, null); | 560 return error(node, null); |
| 561 } | 561 } |
| 562 ConstructorElement constructor = node.staticElement; | 562 ConstructorElement constructor = node.staticElement; |
| 563 if (constructor != null && constructor.isConst) { | 563 if (constructor != null && constructor.isConst) { |
| 564 NodeList<Expression> arguments = node.argumentList.arguments; | 564 NodeList<Expression> arguments = node.argumentList.arguments; |
| 565 int argumentCount = arguments.length; | 565 int argumentCount = arguments.length; |
| 566 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou
nt); | 566 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCou
nt); |
| 567 Map<String, DartObjectImpl> namedArgumentValues = new Map<String, DartObje
ctImpl>(); | 567 Map<String, DartObjectImpl> namedArgumentValues = new Map<String, DartObje
ctImpl>(); |
| 568 for (int i = 0; i < argumentCount; i++) { | 568 for (int i = 0; i < argumentCount; i++) { |
| 569 Expression argument = arguments[i]; | 569 Expression argument = arguments[i]; |
| 570 if (argument is NamedExpression) { | 570 if (argument is NamedExpression) { |
| 571 NamedExpression namedExpression = argument; | 571 NamedExpression namedExpression = argument; |
| 572 String name = namedExpression.name.label.name; | 572 String name = namedExpression.name.label.name; |
| 573 namedArgumentValues[name] = valueOf(namedExpression.expression); | 573 namedArgumentValues[name] = valueOf(namedExpression.expression); |
| 574 argumentValues[i] = null2; | 574 argumentValues[i] = null2; |
| 575 } else { | 575 } else { |
| 576 argumentValues[i] = valueOf(argument); | 576 argumentValues[i] = valueOf(argument); |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 InterfaceType definingClass = constructor.returnType as InterfaceType; | 579 InterfaceType definingClass = constructor.returnType as InterfaceType; |
| 580 if (definingClass.element.library.isDartCore) { | 580 if (definingClass.element.library.isDartCore) { |
| 581 String className = definingClass.name; | 581 String className = definingClass.name; |
| 582 if (className == "Symbol" && argumentCount == 1) { | 582 if (className == "Symbol" && argumentCount == 1) { |
| 583 String argumentValue = argumentValues[0].stringValue; | 583 String argumentValue = argumentValues[0].stringValue; |
| 584 if (argumentValue != null) { | 584 if (argumentValue != null) { |
| 585 return valid2(definingClass, new SymbolState(argumentValue)); | 585 return valid(definingClass, new SymbolState(argumentValue)); |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 Map<String, DartObjectImpl> fieldMap = new Map<String, DartObjectImpl>(); | 589 Map<String, DartObjectImpl> fieldMap = new Map<String, DartObjectImpl>(); |
| 590 List<ParameterElement> parameters = constructor.parameters; | 590 List<ParameterElement> parameters = constructor.parameters; |
| 591 int parameterCount = parameters.length; | 591 int parameterCount = parameters.length; |
| 592 for (int i = 0; i < parameterCount; i++) { | 592 for (int i = 0; i < parameterCount; i++) { |
| 593 ParameterElement parameter = parameters[i]; | 593 ParameterElement parameter = parameters[i]; |
| 594 if (parameter.isInitializingFormal) { | 594 if (parameter.isInitializingFormal) { |
| 595 String fieldName = (parameter as FieldFormalParameterElement).field.na
me; | 595 String fieldName = (parameter as FieldFormalParameterElement).field.na
me; |
| 596 if (identical(parameter.parameterKind, ParameterKind.NAMED)) { | 596 if (identical(parameter.parameterKind, ParameterKind.NAMED)) { |
| 597 DartObjectImpl argumentValue = namedArgumentValues[parameter.name]; | 597 DartObjectImpl argumentValue = namedArgumentValues[parameter.name]; |
| 598 if (argumentValue != null) { | 598 if (argumentValue != null) { |
| 599 fieldMap[fieldName] = argumentValue; | 599 fieldMap[fieldName] = argumentValue; |
| 600 } | 600 } |
| 601 } else if (i < argumentCount) { | 601 } else if (i < argumentCount) { |
| 602 fieldMap[fieldName] = argumentValues[i]; | 602 fieldMap[fieldName] = argumentValues[i]; |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 } | 605 } |
| 606 // TODO(brianwilkerson) This doesn't handle fields initialized in an initi
alizer. We should be | 606 // 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 | 607 // able to handle fields initialized by the superclass' constructor fairly
easily, but other |
| 608 // initializers will be harder. | 608 // initializers will be harder. |
| 609 return valid2(definingClass, new GenericState(fieldMap)); | 609 return valid(definingClass, new GenericState(fieldMap)); |
| 610 } | 610 } |
| 611 // TODO(brianwilkerson) Figure out which error to report. | 611 // TODO(brianwilkerson) Figure out which error to report. |
| 612 return error(node, null); | 612 return error(node, null); |
| 613 } | 613 } |
| 614 | 614 |
| 615 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => valid2(_typeP
rovider.intType, new IntState(node.value)); | 615 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => valid(_typePr
ovider.intType, new IntState(node.value)); |
| 616 | 616 |
| 617 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { | 617 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { |
| 618 EvaluationResultImpl result = node.expression.accept(this); | 618 EvaluationResultImpl result = node.expression.accept(this); |
| 619 if (result is ValidResult && !result.isBoolNumStringOrNull) { | 619 if (result is ValidResult && !result.isBoolNumStringOrNull) { |
| 620 return error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); | 620 return error(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); |
| 621 } | 621 } |
| 622 return result.performToString(_typeProvider, node); | 622 return result.performToString(_typeProvider, node); |
| 623 } | 623 } |
| 624 | 624 |
| 625 EvaluationResultImpl visitInterpolationString(InterpolationString node) => val
id2(_typeProvider.stringType, new StringState(node.value)); | 625 EvaluationResultImpl visitInterpolationString(InterpolationString node) => val
id(_typeProvider.stringType, new StringState(node.value)); |
| 626 | 626 |
| 627 EvaluationResultImpl visitListLiteral(ListLiteral node) { | 627 EvaluationResultImpl visitListLiteral(ListLiteral node) { |
| 628 if (node.constKeyword == null) { | 628 if (node.constKeyword == null) { |
| 629 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_LI
ST_LITERAL); | 629 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_LI
ST_LITERAL); |
| 630 } | 630 } |
| 631 ErrorResult result = null; | 631 ErrorResult result = null; |
| 632 List<DartObjectImpl> elements = new List<DartObjectImpl>(); | 632 List<DartObjectImpl> elements = new List<DartObjectImpl>(); |
| 633 for (Expression element in node.elements) { | 633 for (Expression element in node.elements) { |
| 634 EvaluationResultImpl elementResult = element.accept(this); | 634 EvaluationResultImpl elementResult = element.accept(this); |
| 635 result = union(result, elementResult); | 635 result = union(result, elementResult); |
| 636 if (elementResult is ValidResult) { | 636 if (elementResult is ValidResult) { |
| 637 elements.add(elementResult.value); | 637 elements.add(elementResult.value); |
| 638 } | 638 } |
| 639 } | 639 } |
| 640 if (result != null) { | 640 if (result != null) { |
| 641 return result; | 641 return result; |
| 642 } | 642 } |
| 643 return valid2(_typeProvider.listType, new ListState(new List.from(elements))
); | 643 return valid(_typeProvider.listType, new ListState(new List.from(elements)))
; |
| 644 } | 644 } |
| 645 | 645 |
| 646 EvaluationResultImpl visitMapLiteral(MapLiteral node) { | 646 EvaluationResultImpl visitMapLiteral(MapLiteral node) { |
| 647 if (node.constKeyword == null) { | 647 if (node.constKeyword == null) { |
| 648 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); | 648 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); |
| 649 } | 649 } |
| 650 ErrorResult result = null; | 650 ErrorResult result = null; |
| 651 Map<DartObjectImpl, DartObjectImpl> map = new Map<DartObjectImpl, DartObject
Impl>(); | 651 Map<DartObjectImpl, DartObjectImpl> map = new Map<DartObjectImpl, DartObject
Impl>(); |
| 652 for (MapLiteralEntry entry in node.entries) { | 652 for (MapLiteralEntry entry in node.entries) { |
| 653 EvaluationResultImpl keyResult = entry.key.accept(this); | 653 EvaluationResultImpl keyResult = entry.key.accept(this); |
| 654 EvaluationResultImpl valueResult = entry.value.accept(this); | 654 EvaluationResultImpl valueResult = entry.value.accept(this); |
| 655 result = union(result, keyResult); | 655 result = union(result, keyResult); |
| 656 result = union(result, valueResult); | 656 result = union(result, valueResult); |
| 657 if (keyResult is ValidResult && valueResult is ValidResult) { | 657 if (keyResult is ValidResult && valueResult is ValidResult) { |
| 658 map[keyResult.value] = valueResult.value; | 658 map[keyResult.value] = valueResult.value; |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 if (result != null) { | 661 if (result != null) { |
| 662 return result; | 662 return result; |
| 663 } | 663 } |
| 664 return valid2(_typeProvider.mapType, new MapState(map)); | 664 return valid(_typeProvider.mapType, new MapState(map)); |
| 665 } | 665 } |
| 666 | 666 |
| 667 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { | 667 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { |
| 668 Element element = node.methodName.staticElement; | 668 Element element = node.methodName.staticElement; |
| 669 if (element is FunctionElement) { | 669 if (element is FunctionElement) { |
| 670 FunctionElement function = element; | 670 FunctionElement function = element; |
| 671 if (function.name == "identical") { | 671 if (function.name == "identical") { |
| 672 NodeList<Expression> arguments = node.argumentList.arguments; | 672 NodeList<Expression> arguments = node.argumentList.arguments; |
| 673 if (arguments.length == 2) { | 673 if (arguments.length == 2) { |
| 674 Element enclosingElement = function.enclosingElement; | 674 Element enclosingElement = function.enclosingElement; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 return error(node, null); | 726 return error(node, null); |
| 727 } | 727 } |
| 728 break; | 728 break; |
| 729 } | 729 } |
| 730 } | 730 } |
| 731 | 731 |
| 732 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa
lue(node, node.propertyName.staticElement); | 732 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa
lue(node, node.propertyName.staticElement); |
| 733 | 733 |
| 734 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta
ntValue(node, node.staticElement); | 734 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta
ntValue(node, node.staticElement); |
| 735 | 735 |
| 736 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => val
id2(_typeProvider.stringType, new StringState(node.value)); | 736 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => val
id(_typeProvider.stringType, new StringState(node.value)); |
| 737 | 737 |
| 738 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { | 738 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { |
| 739 EvaluationResultImpl result = null; | 739 EvaluationResultImpl result = null; |
| 740 for (InterpolationElement element in node.elements) { | 740 for (InterpolationElement element in node.elements) { |
| 741 if (result == null) { | 741 if (result == null) { |
| 742 result = element.accept(this); | 742 result = element.accept(this); |
| 743 } else { | 743 } else { |
| 744 result = result.concatenate(_typeProvider, node, element.accept(this)); | 744 result = result.concatenate(_typeProvider, node, element.accept(this)); |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 return result; | 747 return result; |
| 748 } | 748 } |
| 749 | 749 |
| 750 EvaluationResultImpl visitSymbolLiteral(SymbolLiteral node) { | 750 EvaluationResultImpl visitSymbolLiteral(SymbolLiteral node) { |
| 751 JavaStringBuilder builder = new JavaStringBuilder(); | 751 JavaStringBuilder builder = new JavaStringBuilder(); |
| 752 List<Token> components = node.components; | 752 List<Token> components = node.components; |
| 753 for (int i = 0; i < components.length; i++) { | 753 for (int i = 0; i < components.length; i++) { |
| 754 if (i > 0) { | 754 if (i > 0) { |
| 755 builder.appendChar(0x2E); | 755 builder.appendChar(0x2E); |
| 756 } | 756 } |
| 757 builder.append(components[i].lexeme); | 757 builder.append(components[i].lexeme); |
| 758 } | 758 } |
| 759 return valid2(_typeProvider.symbolType, new SymbolState(builder.toString()))
; | 759 return valid(_typeProvider.symbolType, new SymbolState(builder.toString())); |
| 760 } | 760 } |
| 761 | 761 |
| 762 /** | 762 /** |
| 763 * Return a result object representing an error associated with the given node
. | 763 * Return a result object representing an error associated with the given node
. |
| 764 * | 764 * |
| 765 * @param node the AST node associated with the error | 765 * @param node the AST node associated with the error |
| 766 * @param code the error code indicating the nature of the error | 766 * @param code the error code indicating the nature of the error |
| 767 * @return a result object representing an error associated with the given nod
e | 767 * @return a result object representing an error associated with the given nod
e |
| 768 */ | 768 */ |
| 769 ErrorResult error(AstNode node, ErrorCode code) => new ErrorResult.con1(node,
code == null ? CompileTimeErrorCode.INVALID_CONSTANT : code); | 769 ErrorResult error(AstNode node, ErrorCode code) => new ErrorResult.con1(node,
code == null ? CompileTimeErrorCode.INVALID_CONSTANT : code); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 781 } | 781 } |
| 782 if (element is VariableElementImpl) { | 782 if (element is VariableElementImpl) { |
| 783 VariableElementImpl variableElementImpl = element; | 783 VariableElementImpl variableElementImpl = element; |
| 784 EvaluationResultImpl value = variableElementImpl.evaluationResult; | 784 EvaluationResultImpl value = variableElementImpl.evaluationResult; |
| 785 if (variableElementImpl.isConst && value != null) { | 785 if (variableElementImpl.isConst && value != null) { |
| 786 return value; | 786 return value; |
| 787 } | 787 } |
| 788 } else if (element is ExecutableElement) { | 788 } else if (element is ExecutableElement) { |
| 789 ExecutableElement function = element; | 789 ExecutableElement function = element; |
| 790 if (function.isStatic) { | 790 if (function.isStatic) { |
| 791 return valid2(_typeProvider.functionType, new FunctionState(function)); | 791 return valid(_typeProvider.functionType, new FunctionState(function)); |
| 792 } | 792 } |
| 793 } else if (element is ClassElement || element is FunctionTypeAliasElement) { | 793 } else if (element is ClassElement || element is FunctionTypeAliasElement) { |
| 794 return valid2(_typeProvider.typeType, new TypeState(element)); | 794 return valid(_typeProvider.typeType, new TypeState(element)); |
| 795 } | 795 } |
| 796 // TODO(brianwilkerson) Figure out which error to report. | 796 // TODO(brianwilkerson) Figure out which error to report. |
| 797 return error(node, null); | 797 return error(node, null); |
| 798 } | 798 } |
| 799 | 799 |
| 800 /** | 800 /** |
| 801 * Return an object representing the value 'null'. | 801 * Return an object representing the value 'null'. |
| 802 * | 802 * |
| 803 * @return an object representing the value 'null' | 803 * @return an object representing the value 'null' |
| 804 */ | 804 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 822 if (rightResult is ErrorResult) { | 822 if (rightResult is ErrorResult) { |
| 823 if (leftResult != null) { | 823 if (leftResult != null) { |
| 824 return new ErrorResult.con2(leftResult, rightResult); | 824 return new ErrorResult.con2(leftResult, rightResult); |
| 825 } else { | 825 } else { |
| 826 return rightResult; | 826 return rightResult; |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 return leftResult; | 829 return leftResult; |
| 830 } | 830 } |
| 831 | 831 |
| 832 ValidResult valid(InterfaceType type) { | 832 ValidResult valid(InterfaceType type, InstanceState state) => new ValidResult(
new DartObjectImpl(type, state)); |
| 833 |
| 834 ValidResult validWithUnknownValue(InterfaceType type) { |
| 833 if (type.element.library.isDartCore) { | 835 if (type.element.library.isDartCore) { |
| 834 String typeName = type.name; | 836 String typeName = type.name; |
| 835 if (typeName == "bool") { | 837 if (typeName == "bool") { |
| 836 return valid2(type, BoolState.UNKNOWN_VALUE); | 838 return valid(type, BoolState.UNKNOWN_VALUE); |
| 837 } else if (typeName == "double") { | 839 } else if (typeName == "double") { |
| 838 return valid2(type, DoubleState.UNKNOWN_VALUE); | 840 return valid(type, DoubleState.UNKNOWN_VALUE); |
| 839 } else if (typeName == "int") { | 841 } else if (typeName == "int") { |
| 840 return valid2(type, IntState.UNKNOWN_VALUE); | 842 return valid(type, IntState.UNKNOWN_VALUE); |
| 841 } else if (typeName == "String") { | 843 } else if (typeName == "String") { |
| 842 return valid2(type, StringState.UNKNOWN_VALUE); | 844 return valid(type, StringState.UNKNOWN_VALUE); |
| 843 } | 845 } |
| 844 } | 846 } |
| 845 return valid2(type, GenericState.UNKNOWN_VALUE); | 847 return valid(type, GenericState.UNKNOWN_VALUE); |
| 846 } | 848 } |
| 847 | 849 |
| 848 ValidResult valid2(InterfaceType type, InstanceState state) => new ValidResult
(new DartObjectImpl(type, state)); | |
| 849 | |
| 850 /** | 850 /** |
| 851 * Return the value of the given expression, or a representation of 'null' if
the expression | 851 * Return the value of the given expression, or a representation of 'null' if
the expression |
| 852 * cannot be evaluated. | 852 * cannot be evaluated. |
| 853 * | 853 * |
| 854 * @param expression the expression whose value is to be returned | 854 * @param expression the expression whose value is to be returned |
| 855 * @return the value of the given expression | 855 * @return the value of the given expression |
| 856 */ | 856 */ |
| 857 DartObjectImpl valueOf(Expression expression) { | 857 DartObjectImpl valueOf(Expression expression) { |
| 858 EvaluationResultImpl expressionValue = expression.accept(this); | 858 EvaluationResultImpl expressionValue = expression.accept(this); |
| 859 if (expressionValue is ValidResult) { | 859 if (expressionValue is ValidResult) { |
| (...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4184 } | 4184 } |
| 4185 return BoolState.FALSE_STATE; | 4185 return BoolState.FALSE_STATE; |
| 4186 } | 4186 } |
| 4187 | 4187 |
| 4188 String get typeName => "Type"; | 4188 String get typeName => "Type"; |
| 4189 | 4189 |
| 4190 int get hashCode => _element == null ? 0 : _element.hashCode; | 4190 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 4191 | 4191 |
| 4192 String toString() => _element == null ? "-unknown-" : _element.name; | 4192 String toString() => _element == null ? "-unknown-" : _element.name; |
| 4193 } | 4193 } |
| OLD | NEW |