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

Side by Side Diff: runtime/vm/ast.h

Issue 935713002: Accept constant string concatenation and constant string length as constant (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef VM_AST_H_ 5 #ifndef VM_AST_H_
6 #define VM_AST_H_ 6 #define VM_AST_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // parsing as the assignment context was not known yet at that time. 122 // parsing as the assignment context was not known yet at that time.
123 virtual AstNode* MakeAssignmentNode(AstNode* rhs) { 123 virtual AstNode* MakeAssignmentNode(AstNode* rhs) {
124 return NULL; // By default all nodes are not assignable. 124 return NULL; // By default all nodes are not assignable.
125 } 125 }
126 126
127 // Return NULL if 'unary_op_kind' can't be applied. 127 // Return NULL if 'unary_op_kind' can't be applied.
128 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind) { 128 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind) {
129 return NULL; 129 return NULL;
130 } 130 }
131 131
132 // Returns true if this node can be a compile-time constant, assuming
133 // that all nodes it depends on are also compile-time constants of
134 // the proper types and values.
135 // See the concept of "potentially constant expression" in the language spec.
136 // The purpose of IsPotentiallyConst is to detect cases where the node is
137 // known NOT to be a constant expression, in which case false is returned and
138 // a compile-time error is reported by the compiler. Otherwise, an error may
139 // still be reported at run-time depending on actual values.
132 virtual bool IsPotentiallyConst() const { return false; } 140 virtual bool IsPotentiallyConst() const { return false; }
133 141
134 // Analyzes an expression to determine whether it is a compile time 142 // Analyzes an expression to determine whether it is a compile time
135 // constant or not. Returns NULL if the expression is not a compile time 143 // constant or not. Returns NULL if the expression is not a compile time
136 // constant. Otherwise, the return value is an approximation of the 144 // constant. Otherwise, the return value is an approximation of the
137 // actual value of the const expression. The type of the returned value 145 // actual value of the const expression. The type of the returned value
138 // corresponds to the type of the const expression and is either 146 // corresponds to the type of the const expression and is either
139 // Number, Integer, String, Bool, or anything else (not a subtype of 147 // Number, Integer, String, Bool, or anything else (not a subtype of
140 // the former). 148 // the former).
141 virtual const Instance* EvalConstExpr() const { return NULL; } 149 virtual const Instance* EvalConstExpr() const { return NULL; }
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 1424
1417 AstNode* receiver() const { return receiver_; } 1425 AstNode* receiver() const { return receiver_; }
1418 const String& field_name() const { return field_name_; } 1426 const String& field_name() const { return field_name_; }
1419 1427
1420 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1428 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1421 receiver()->Visit(visitor); 1429 receiver()->Visit(visitor);
1422 } 1430 }
1423 1431
1424 virtual AstNode* MakeAssignmentNode(AstNode* rhs); 1432 virtual AstNode* MakeAssignmentNode(AstNode* rhs);
1425 1433
1434 virtual bool IsPotentiallyConst() const;
1435 virtual const Instance* EvalConstExpr() const;
1436
1426 DECLARE_COMMON_NODE_FUNCTIONS(InstanceGetterNode); 1437 DECLARE_COMMON_NODE_FUNCTIONS(InstanceGetterNode);
1427 1438
1428 private: 1439 private:
1429 AstNode* receiver_; 1440 AstNode* receiver_;
1430 const String& field_name_; 1441 const String& field_name_;
1431 1442
1432 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceGetterNode); 1443 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceGetterNode);
1433 }; 1444 };
1434 1445
1435 1446
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 const intptr_t try_index_; 1915 const intptr_t try_index_;
1905 1916
1906 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); 1917 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode);
1907 }; 1918 };
1908 1919
1909 } // namespace dart 1920 } // namespace dart
1910 1921
1911 #undef DECLARE_COMMON_NODE_FUNCTIONS 1922 #undef DECLARE_COMMON_NODE_FUNCTIONS
1912 1923
1913 #endif // VM_AST_H_ 1924 #endif // VM_AST_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698