ConstantEvaluator class

Instances of the class ConstantEvaluator evaluate constant expressions to produce their compile-time value.

According to the Dart Language Specification:

A constant expression is one of the following:

  • A literal number.
  • A literal boolean.
  • A literal string where any interpolated expression is a compile-time constant that evaluates to a numeric, string or boolean value or to null.
  • A literal symbol.
  • null.
  • A qualified reference to a static constant variable.
  • An identifier expression that denotes a constant variable, class or type alias.
  • A constant constructor invocation.
  • A constant list literal.
  • A constant map literal.
  • A simple or qualified identifier denoting a top-level function or a static method.
  • A parenthesized expression (e) where e is a constant expression.
  • An expression of the form identical(e1, e2) where e1 and e2 are constant expressions and identical() is statically bound to the predefined dart function identical() discussed above.
  • An expression of one of the forms e1 == e2 or e1 != e2 where e1 and e2 are constant expressions that evaluate to a numeric, string or boolean value.
  • An expression of one of the forms !e, e1 && e2 or e1 || e2, where e, e1 and e2 are constant expressions that evaluate to a boolean value.
  • An expression of one of the forms ~e, e1 ^ e2, e1 & e2, e1 | e2, e1 >> e2 or e1 << e2, where e, e1 and e2 are constant expressions that evaluate to an integer value or to null.
  • An expression of one of the forms -e, e1 -e2, e1 * e2, e1 / e2, e1 ~/ e2, e1 > e2, e1 < e2, e1 >= e2, e1 <= e2 or e1 % e2, where e, e1 and e2 are constant expressions that evaluate to a numeric value or to null.
  • An expression of one the form e1 + e2, e1 -e2 where e1 and e2 are constant expressions that evaluate to a numeric or string value or to null.
  • An expression of the form e1 ? e2 : e3 where e1, e2 and e3 are constant expressions, and e1 evaluates to a boolean value.

However, this comment is now at least a little bit out of sync with the spec.

The values returned by instances of this class are therefore null and instances of the classes Boolean, BigInteger, Double, String, and DartObject.

In addition, this class defines several values that can be returned to indicate various conditions encountered during evaluation. These are documented with the static fields that define those values.

Inheritance

Constructors

ConstantEvaluator()

Properties

hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

visitAdjacentStrings(AdjacentStrings node) → Object
override
visitBinaryExpression(BinaryExpression node) → Object
override
visitBooleanLiteral(BooleanLiteral node) → Object
override
visitDoubleLiteral(DoubleLiteral node) → Object
override
visitIntegerLiteral(IntegerLiteral node) → Object
override
visitInterpolationExpression(InterpolationExpression node) → Object
override
visitInterpolationString(InterpolationString node) → Object
override
visitListLiteral(ListLiteral node) → Object
override
visitMethodInvocation(MethodInvocation node) → Object
override
visitNode(AstNode node) → Object
override
visitNullLiteral(NullLiteral node) → Object
override
visitParenthesizedExpression(ParenthesizedExpression node) → Object
override
visitPrefixedIdentifier(PrefixedIdentifier node) → Object
override
visitPrefixExpression(PrefixExpression node) → Object
override
visitPropertyAccess(PropertyAccess node) → Object
override
visitSetOrMapLiteral(SetOrMapLiteral node) → Object
override
visitSimpleIdentifier(SimpleIdentifier node) → Object
override
visitSimpleStringLiteral(SimpleStringLiteral node) → Object
override
visitStringInterpolation(StringInterpolation node) → Object
override
visitSymbolLiteral(SymbolLiteral node) → Object
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() → String
Returns a string representation of this object.
inherited
visitAnnotatedNode(AnnotatedNode node) → Object
inherited
visitAnnotation(Annotation node) → Object
inherited
visitArgumentList(ArgumentList node) → Object
inherited
visitAsExpression(AsExpression node) → Object
inherited
visitAssertInitializer(AssertInitializer node) → Object
inherited
visitAssertStatement(AssertStatement node) → Object
inherited
visitAssignmentExpression(AssignmentExpression node) → Object
inherited
visitAwaitExpression(AwaitExpression node) → Object
inherited
visitBlock(Block node) → Object
inherited
visitBlockFunctionBody(BlockFunctionBody node) → Object
inherited
visitBreakStatement(BreakStatement node) → Object
inherited
visitCascadeExpression(CascadeExpression node) → Object
inherited
visitCatchClause(CatchClause node) → Object
inherited
visitClassDeclaration(ClassDeclaration node) → Object
inherited
visitClassMember(ClassMember node) → Object
inherited
visitClassTypeAlias(ClassTypeAlias node) → Object
inherited
visitCollectionElement(CollectionElement node) → Object
inherited
visitCombinator(Combinator node) → Object
inherited
visitComment(Comment node) → Object
inherited
visitCommentReference(CommentReference node) → Object
inherited
visitCompilationUnit(CompilationUnit node) → Object
inherited
visitCompilationUnitMember(CompilationUnitMember node) → Object
inherited
visitConditionalExpression(ConditionalExpression node) → Object
inherited
visitConfiguration(Configuration node) → Object
inherited
visitConstructorDeclaration(ConstructorDeclaration node) → Object
inherited
visitConstructorFieldInitializer(ConstructorFieldInitializer node) → Object
inherited
visitConstructorInitializer(ConstructorInitializer node) → Object
inherited
visitConstructorName(ConstructorName node) → Object
inherited
visitContinueStatement(ContinueStatement node) → Object
inherited
visitDeclaration(Declaration node) → Object
inherited
visitDeclaredIdentifier(DeclaredIdentifier node) → Object
inherited
visitDefaultFormalParameter(DefaultFormalParameter node) → Object
inherited
visitDirective(Directive node) → Object
inherited
visitDoStatement(DoStatement node) → Object
inherited
visitDottedName(DottedName node) → Object
inherited
visitEmptyFunctionBody(EmptyFunctionBody node) → Object
inherited
visitEmptyStatement(EmptyStatement node) → Object
inherited
visitEnumConstantDeclaration(EnumConstantDeclaration node) → Object
inherited
visitEnumDeclaration(EnumDeclaration node) → Object
inherited
visitExportDirective(ExportDirective node) → Object
inherited
visitExpression(Expression node) → Object
inherited
visitExpressionFunctionBody(ExpressionFunctionBody node) → Object
inherited
visitExpressionStatement(ExpressionStatement node) → Object
inherited
visitExtendsClause(ExtendsClause node) → Object
inherited
visitExtensionDeclaration(ExtensionDeclaration node) → Object
inherited
visitExtensionOverride(ExtensionOverride node) → Object
inherited
visitFieldDeclaration(FieldDeclaration node) → Object
inherited
visitFieldFormalParameter(FieldFormalParameter node) → Object
inherited
visitForEachParts(ForEachParts node) → Object
inherited
visitForEachPartsWithDeclaration(ForEachPartsWithDeclaration node) → Object
inherited
visitForEachPartsWithIdentifier(ForEachPartsWithIdentifier node) → Object
inherited
visitForElement(ForElement node) → Object
inherited
visitFormalParameter(FormalParameter node) → Object
inherited
visitFormalParameterList(FormalParameterList node) → Object
inherited
visitForParts(ForParts node) → Object
inherited
visitForPartsWithDeclarations(ForPartsWithDeclarations node) → Object
inherited
visitForPartsWithExpression(ForPartsWithExpression node) → Object
inherited
visitForStatement(ForStatement node) → Object
inherited
visitFunctionBody(FunctionBody node) → Object
inherited
visitFunctionDeclaration(FunctionDeclaration node) → Object
inherited
visitFunctionDeclarationStatement(FunctionDeclarationStatement node) → Object
inherited
visitFunctionExpression(FunctionExpression node) → Object
inherited
visitFunctionExpressionInvocation(FunctionExpressionInvocation node) → Object
inherited
visitFunctionTypeAlias(FunctionTypeAlias node) → Object
inherited
visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) → Object
inherited
visitGenericFunctionType(GenericFunctionType node) → Object
inherited
visitGenericTypeAlias(GenericTypeAlias node) → Object
inherited
visitHideCombinator(HideCombinator node) → Object
inherited
visitIdentifier(Identifier node) → Object
inherited
visitIfElement(IfElement node) → Object
inherited
visitIfStatement(IfStatement node) → Object
inherited
visitImplementsClause(ImplementsClause node) → Object
inherited
visitImportDirective(ImportDirective node) → Object
inherited
visitIndexExpression(IndexExpression node) → Object
inherited
visitInstanceCreationExpression(InstanceCreationExpression node) → Object
inherited
visitInterpolationElement(InterpolationElement node) → Object
inherited
visitInvocationExpression(InvocationExpression node) → Object
inherited
visitIsExpression(IsExpression node) → Object
inherited
visitLabel(Label node) → Object
inherited
visitLabeledStatement(LabeledStatement node) → Object
inherited
visitLibraryDirective(LibraryDirective node) → Object
inherited
visitLibraryIdentifier(LibraryIdentifier node) → Object
inherited
visitLiteral(Literal node) → Object
inherited
visitMapLiteralEntry(MapLiteralEntry node) → Object
inherited
visitMethodDeclaration(MethodDeclaration node) → Object
inherited
visitMixinDeclaration(MixinDeclaration node) → Object
inherited
visitNamedCompilationUnitMember(NamedCompilationUnitMember node) → Object
inherited
visitNamedExpression(NamedExpression node) → Object
inherited
visitNamespaceDirective(NamespaceDirective node) → Object
inherited
visitNativeClause(NativeClause node) → Object
inherited
visitNativeFunctionBody(NativeFunctionBody node) → Object
inherited
visitNormalFormalParameter(NormalFormalParameter node) → Object
inherited
visitOnClause(OnClause node) → Object
inherited
visitPartDirective(PartDirective node) → Object
inherited
visitPartOfDirective(PartOfDirective node) → Object
inherited
visitPostfixExpression(PostfixExpression node) → Object
inherited
visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) → Object
inherited
visitRethrowExpression(RethrowExpression node) → Object
inherited
visitReturnStatement(ReturnStatement node) → Object
inherited
visitScriptTag(ScriptTag scriptTag) → Object
inherited
visitShowCombinator(ShowCombinator node) → Object
inherited
visitSimpleFormalParameter(SimpleFormalParameter node) → Object
inherited
visitSingleStringLiteral(SingleStringLiteral node) → Object
inherited
visitSpreadElement(SpreadElement node) → Object
inherited
visitStatement(Statement node) → Object
inherited
visitStringLiteral(StringLiteral node) → Object
inherited
visitSuperConstructorInvocation(SuperConstructorInvocation node) → Object
inherited
visitSuperExpression(SuperExpression node) → Object
inherited
visitSwitchCase(SwitchCase node) → Object
inherited
visitSwitchDefault(SwitchDefault node) → Object
inherited
visitSwitchMember(SwitchMember node) → Object
inherited
visitSwitchStatement(SwitchStatement node) → Object
inherited
visitThisExpression(ThisExpression node) → Object
inherited
visitThrowExpression(ThrowExpression node) → Object
inherited
visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) → Object
inherited
visitTryStatement(TryStatement node) → Object
inherited
visitTypeAlias(TypeAlias node) → Object
inherited
visitTypeAnnotation(TypeAnnotation node) → Object
inherited
visitTypeArgumentList(TypeArgumentList node) → Object
inherited
visitTypedLiteral(TypedLiteral node) → Object
inherited
visitTypeName(TypeName node) → Object
inherited
visitTypeParameter(TypeParameter node) → Object
inherited
visitTypeParameterList(TypeParameterList node) → Object
inherited
visitUriBasedDirective(UriBasedDirective node) → Object
inherited
visitVariableDeclaration(VariableDeclaration node) → Object
inherited
visitVariableDeclarationList(VariableDeclarationList node) → Object
inherited
visitVariableDeclarationStatement(VariableDeclarationStatement node) → Object
inherited
visitWhileStatement(WhileStatement node) → Object
inherited
visitWithClause(WithClause node) → Object
inherited
visitYieldStatement(YieldStatement node) → Object
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited

Static Properties

NOT_A_CONSTANT ↔ Object
The value returned for expressions (or non-expression nodes) that are not compile-time constant expressions.
read / write