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

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

Issue 10831142: Associate the correct type to method receivers (instead of Dynamic type). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/code_descriptors_test.cc » ('j') | runtime/vm/object.h » ('J')
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 GrowableArray<AstNode*> elements_; 301 GrowableArray<AstNode*> elements_;
302 302
303 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode); 303 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode);
304 }; 304 };
305 305
306 306
307 class LiteralNode : public AstNode { 307 class LiteralNode : public AstNode {
308 public: 308 public:
309 LiteralNode(intptr_t token_pos, const Instance& literal) 309 LiteralNode(intptr_t token_pos, const Instance& literal)
310 : AstNode(token_pos), literal_(literal) { 310 : AstNode(token_pos), literal_(literal) {
311 ASSERT(literal.IsZoneHandle()); 311 ASSERT(literal_.IsZoneHandle());
312 ASSERT(literal.IsSmi() || literal.IsOld()); 312 ASSERT(literal_.IsSmi() || literal_.IsOld());
313 #if defined(DEBUG) 313 #if defined(DEBUG)
314 if (literal.IsString()) { 314 if (literal_.IsString()) {
315 ASSERT(String::Cast(literal).IsSymbol()); 315 ASSERT(String::Cast(literal_).IsSymbol());
316 } 316 }
317 #endif // defined(DEBUG) 317 #endif // defined(DEBUG)
318 ASSERT(literal.IsNull() || 318 ASSERT(literal_.IsNull() ||
319 Class::Handle(literal.clazz()).is_finalized() || 319 Class::Handle(literal_.clazz()).is_finalized() ||
320 Class::Handle(literal.clazz()).is_prefinalized()); 320 Class::Handle(literal_.clazz()).is_prefinalized());
321 } 321 }
322 322
323 const Instance& literal() const { return literal_; } 323 const Instance& literal() const { return literal_; }
324 324
325 virtual const Instance* EvalConstExpr() const { 325 virtual const Instance* EvalConstExpr() const {
326 return &literal(); 326 return &literal();
327 } 327 }
328 328
329 virtual void VisitChildren(AstNodeVisitor* visitor) const { } 329 virtual void VisitChildren(AstNodeVisitor* visitor) const { }
330 330
331 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind); 331 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind);
332 332
333 DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode); 333 DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode);
334 334
335 private: 335 private:
336 const Instance& literal_; 336 const Instance& literal_;
337 337
338 DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode); 338 DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode);
339 }; 339 };
340 340
341 341
342 class TypeNode : public AstNode { 342 class TypeNode : public AstNode {
343 public: 343 public:
344 TypeNode(intptr_t token_pos, const AbstractType& type) 344 TypeNode(intptr_t token_pos, const AbstractType& type)
345 : AstNode(token_pos), type_(type) { 345 : AstNode(token_pos), type_(type) {
346 ASSERT(type.IsZoneHandle()); 346 ASSERT(type_.IsZoneHandle());
347 ASSERT(!type.IsNull()); 347 ASSERT(!type_.IsNull());
348 ASSERT(type.IsFinalized()); 348 ASSERT(type_.IsFinalized());
349 } 349 }
350 350
351 const AbstractType& type() const { return type_; } 351 const AbstractType& type() const { return type_; }
352 352
353 virtual void VisitChildren(AstNodeVisitor* visitor) const { } 353 virtual void VisitChildren(AstNodeVisitor* visitor) const { }
354 354
355 DECLARE_COMMON_NODE_FUNCTIONS(TypeNode); 355 DECLARE_COMMON_NODE_FUNCTIONS(TypeNode);
356 356
357 private: 357 private:
358 const AbstractType& type_; 358 const AbstractType& type_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 class ClosureNode : public AstNode { 397 class ClosureNode : public AstNode {
398 public: 398 public:
399 ClosureNode(intptr_t token_pos, 399 ClosureNode(intptr_t token_pos,
400 const Function& function, 400 const Function& function,
401 AstNode* receiver, // Non-null for implicit instance closures. 401 AstNode* receiver, // Non-null for implicit instance closures.
402 LocalScope* scope) // Null for implicit closures. 402 LocalScope* scope) // Null for implicit closures.
403 : AstNode(token_pos), 403 : AstNode(token_pos),
404 function_(function), 404 function_(function),
405 receiver_(receiver), 405 receiver_(receiver),
406 scope_(scope) { 406 scope_(scope) {
407 ASSERT(function.IsZoneHandle()); 407 ASSERT(function_.IsZoneHandle());
408 ASSERT((function.IsNonImplicitClosureFunction() && 408 ASSERT((function_.IsNonImplicitClosureFunction() &&
409 (receiver_ == NULL) && (scope_ != NULL)) || 409 (receiver_ == NULL) && (scope_ != NULL)) ||
410 (function.IsImplicitInstanceClosureFunction() && 410 (function_.IsImplicitInstanceClosureFunction() &&
411 (receiver_ != NULL) && (scope_ == NULL)) || 411 (receiver_ != NULL) && (scope_ == NULL)) ||
412 (function.IsImplicitStaticClosureFunction() && 412 (function_.IsImplicitStaticClosureFunction() &&
413 (receiver_ == NULL) && (scope_ == NULL))); 413 (receiver_ == NULL) && (scope_ == NULL)));
414 } 414 }
415 415
416 const Function& function() const { return function_; } 416 const Function& function() const { return function_; }
417 AstNode* receiver() const { return receiver_; } 417 AstNode* receiver() const { return receiver_; }
418 LocalScope* scope() const { return scope_; } 418 LocalScope* scope() const { return scope_; }
419 419
420 virtual void VisitChildren(AstNodeVisitor* visitor) const { 420 virtual void VisitChildren(AstNodeVisitor* visitor) const {
421 if (receiver() != NULL) { 421 if (receiver() != NULL) {
422 receiver()->Visit(visitor); 422 receiver()->Visit(visitor);
(...skipping 12 matching lines...) Expand all
435 435
436 436
437 // Primary nodes hold identifiers or values (library, class or function) 437 // Primary nodes hold identifiers or values (library, class or function)
438 // resolved from an identifier. Primary nodes should not ever make it to the 438 // resolved from an identifier. Primary nodes should not ever make it to the
439 // code generation phase as they will be transformed into the correct call or 439 // code generation phase as they will be transformed into the correct call or
440 // field access nodes. 440 // field access nodes.
441 class PrimaryNode : public AstNode { 441 class PrimaryNode : public AstNode {
442 public: 442 public:
443 PrimaryNode(intptr_t token_pos, const Object& primary) 443 PrimaryNode(intptr_t token_pos, const Object& primary)
444 : AstNode(token_pos), primary_(primary) { 444 : AstNode(token_pos), primary_(primary) {
445 ASSERT(primary.IsZoneHandle()); 445 ASSERT(primary_.IsZoneHandle());
446 } 446 }
447 447
448 const Object& primary() const { return primary_; } 448 const Object& primary() const { return primary_; }
449 449
450 virtual void VisitChildren(AstNodeVisitor* visitor) const; 450 virtual void VisitChildren(AstNodeVisitor* visitor) const;
451 451
452 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); 452 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode);
453 453
454 private: 454 private:
455 const Object& primary_; 455 const Object& primary_;
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 Token::Kind kind_; 922 Token::Kind kind_;
923 SourceLabel* label_; 923 SourceLabel* label_;
924 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; 924 GrowableArray<InlinedFinallyNode*> inlined_finally_list_;
925 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); 925 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode);
926 }; 926 };
927 927
928 928
929 class LoadLocalNode : public AstNode { 929 class LoadLocalNode : public AstNode {
930 public: 930 public:
931 LoadLocalNode(intptr_t token_pos, const LocalVariable& local) 931 LoadLocalNode(intptr_t token_pos, const LocalVariable& local)
932 : AstNode(token_pos), local_(local), pseudo_(NULL) { } 932 : AstNode(token_pos), local_(local), pseudo_(NULL) {
933 ASSERT(&local_ != NULL);
srdjan 2012/08/02 22:29:46 That can't be, can it? You can't pass *NULL to it?
regis 2012/08/02 23:01:26 Actually, yes, you can pass *receiver with receive
934 }
933 // The pseudo node does not produce input but must be visited before 935 // The pseudo node does not produce input but must be visited before
934 // completing local load. 936 // completing local load.
935 LoadLocalNode(intptr_t token_pos, 937 LoadLocalNode(intptr_t token_pos,
936 const LocalVariable& local, 938 const LocalVariable& local,
937 AstNode* pseudo) 939 AstNode* pseudo)
938 : AstNode(token_pos), local_(local), pseudo_(pseudo) {} 940 : AstNode(token_pos), local_(local), pseudo_(pseudo) {
941 ASSERT(&local_ != NULL);
942 }
939 943
940 const LocalVariable& local() const { return local_; } 944 const LocalVariable& local() const { return local_; }
941 AstNode* pseudo() const { return pseudo_; } // Can be NULL. 945 AstNode* pseudo() const { return pseudo_; } // Can be NULL.
942 bool HasPseudo() const { return pseudo_ != NULL; } 946 bool HasPseudo() const { return pseudo_ != NULL; }
943 947
944 virtual void VisitChildren(AstNodeVisitor* visitor) const { 948 virtual void VisitChildren(AstNodeVisitor* visitor) const {
945 if (HasPseudo()) { 949 if (HasPseudo()) {
946 pseudo()->Visit(visitor); 950 pseudo()->Visit(visitor);
947 } 951 }
948 } 952 }
949 953
950 virtual AstNode* MakeAssignmentNode(AstNode* rhs); 954 virtual AstNode* MakeAssignmentNode(AstNode* rhs);
951 955
952 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode); 956 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode);
953 957
954 private: 958 private:
955 const LocalVariable& local_; 959 const LocalVariable& local_;
956 AstNode* pseudo_; 960 AstNode* pseudo_;
957 961
958 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode); 962 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode);
959 }; 963 };
960 964
961 965
962 class StoreLocalNode : public AstNode { 966 class StoreLocalNode : public AstNode {
963 public: 967 public:
964 StoreLocalNode(intptr_t token_pos, 968 StoreLocalNode(intptr_t token_pos,
965 const LocalVariable& local, 969 const LocalVariable& local,
966 AstNode* value) 970 AstNode* value)
967 : AstNode(token_pos), local_(local), value_(value) { 971 : AstNode(token_pos), local_(local), value_(value) {
972 ASSERT(&local_ != NULL);
968 ASSERT(value_ != NULL); 973 ASSERT(value_ != NULL);
969 } 974 }
970 975
971 const LocalVariable& local() const { return local_; } 976 const LocalVariable& local() const { return local_; }
972 AstNode* value() const { return value_; } 977 AstNode* value() const { return value_; }
973 978
974 virtual void VisitChildren(AstNodeVisitor* visitor) const { 979 virtual void VisitChildren(AstNodeVisitor* visitor) const {
975 value()->Visit(visitor); 980 value()->Visit(visitor);
976 } 981 }
977 982
978 DECLARE_COMMON_NODE_FUNCTIONS(StoreLocalNode); 983 DECLARE_COMMON_NODE_FUNCTIONS(StoreLocalNode);
979 984
980 private: 985 private:
981 const LocalVariable& local_; 986 const LocalVariable& local_;
982 AstNode* value_; 987 AstNode* value_;
983 988
984 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode); 989 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode);
985 }; 990 };
986 991
987 992
988 993
989 class LoadInstanceFieldNode : public AstNode { 994 class LoadInstanceFieldNode : public AstNode {
990 public: 995 public:
991 LoadInstanceFieldNode(intptr_t token_pos, 996 LoadInstanceFieldNode(intptr_t token_pos,
992 AstNode* instance, 997 AstNode* instance,
993 const Field& field) 998 const Field& field)
994 : AstNode(token_pos), instance_(instance), field_(field) { 999 : AstNode(token_pos), instance_(instance), field_(field) {
995 ASSERT(instance_ != NULL); 1000 ASSERT(instance_ != NULL);
996 ASSERT(field.IsZoneHandle()); 1001 ASSERT(field_.IsZoneHandle());
997 } 1002 }
998 1003
999 AstNode* instance() const { return instance_; } 1004 AstNode* instance() const { return instance_; }
1000 const Field& field() const { return field_; } 1005 const Field& field() const { return field_; }
1001 1006
1002 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1007 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1003 instance()->Visit(visitor); 1008 instance()->Visit(visitor);
1004 } 1009 }
1005 1010
1006 DECLARE_COMMON_NODE_FUNCTIONS(LoadInstanceFieldNode); 1011 DECLARE_COMMON_NODE_FUNCTIONS(LoadInstanceFieldNode);
(...skipping 10 matching lines...) Expand all
1017 public: 1022 public:
1018 StoreInstanceFieldNode(intptr_t token_pos, 1023 StoreInstanceFieldNode(intptr_t token_pos,
1019 AstNode* instance, 1024 AstNode* instance,
1020 const Field& field, 1025 const Field& field,
1021 AstNode* value) 1026 AstNode* value)
1022 : AstNode(token_pos), 1027 : AstNode(token_pos),
1023 instance_(instance), 1028 instance_(instance),
1024 field_(field), 1029 field_(field),
1025 value_(value) { 1030 value_(value) {
1026 ASSERT(instance_ != NULL); 1031 ASSERT(instance_ != NULL);
1027 ASSERT(field.IsZoneHandle()); 1032 ASSERT(field_.IsZoneHandle());
1028 ASSERT(value_ != NULL); 1033 ASSERT(value_ != NULL);
1029 } 1034 }
1030 1035
1031 AstNode* instance() const { return instance_; } 1036 AstNode* instance() const { return instance_; }
1032 const Field& field() const { return field_; } 1037 const Field& field() const { return field_; }
1033 AstNode* value() const { return value_; } 1038 AstNode* value() const { return value_; }
1034 1039
1035 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1040 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1036 instance()->Visit(visitor); 1041 instance()->Visit(visitor);
1037 value()->Visit(visitor); 1042 value()->Visit(visitor);
1038 } 1043 }
1039 1044
1040 DECLARE_COMMON_NODE_FUNCTIONS(StoreInstanceFieldNode); 1045 DECLARE_COMMON_NODE_FUNCTIONS(StoreInstanceFieldNode);
1041 1046
1042 private: 1047 private:
1043 AstNode* instance_; 1048 AstNode* instance_;
1044 const Field& field_; 1049 const Field& field_;
1045 AstNode* value_; 1050 AstNode* value_;
1046 1051
1047 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreInstanceFieldNode); 1052 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreInstanceFieldNode);
1048 }; 1053 };
1049 1054
1050 1055
1051 class LoadStaticFieldNode : public AstNode { 1056 class LoadStaticFieldNode : public AstNode {
1052 public: 1057 public:
1053 LoadStaticFieldNode(intptr_t token_pos, const Field& field) 1058 LoadStaticFieldNode(intptr_t token_pos, const Field& field)
1054 : AstNode(token_pos), field_(field) { 1059 : AstNode(token_pos), field_(field) {
1055 ASSERT(field.IsZoneHandle()); 1060 ASSERT(field_.IsZoneHandle());
1056 } 1061 }
1057 1062
1058 const Field& field() const { return field_; } 1063 const Field& field() const { return field_; }
1059 1064
1060 virtual void VisitChildren(AstNodeVisitor* visitor) const { } 1065 virtual void VisitChildren(AstNodeVisitor* visitor) const { }
1061 1066
1062 virtual AstNode* MakeAssignmentNode(AstNode* rhs); 1067 virtual AstNode* MakeAssignmentNode(AstNode* rhs);
1063 1068
1064 virtual const Instance* EvalConstExpr() const { 1069 virtual const Instance* EvalConstExpr() const {
1065 ASSERT(field_.is_static()); 1070 ASSERT(field_.is_static());
1066 return field_.is_final() ? &Instance::ZoneHandle(field_.value()) : NULL; 1071 return field_.is_final() ? &Instance::ZoneHandle(field_.value()) : NULL;
1067 } 1072 }
1068 1073
1069 DECLARE_COMMON_NODE_FUNCTIONS(LoadStaticFieldNode); 1074 DECLARE_COMMON_NODE_FUNCTIONS(LoadStaticFieldNode);
1070 1075
1071 private: 1076 private:
1072 const Field& field_; 1077 const Field& field_;
1073 1078
1074 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode); 1079 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode);
1075 }; 1080 };
1076 1081
1077 1082
1078 class StoreStaticFieldNode : public AstNode { 1083 class StoreStaticFieldNode : public AstNode {
1079 public: 1084 public:
1080 StoreStaticFieldNode(intptr_t token_pos, const Field& field, AstNode* value) 1085 StoreStaticFieldNode(intptr_t token_pos, const Field& field, AstNode* value)
1081 : AstNode(token_pos), field_(field), value_(value) { 1086 : AstNode(token_pos), field_(field), value_(value) {
1082 ASSERT(field.IsZoneHandle()); 1087 ASSERT(field_.IsZoneHandle());
1083 ASSERT(value_ != NULL); 1088 ASSERT(value_ != NULL);
1084 } 1089 }
1085 1090
1086 const Field& field() const { return field_; } 1091 const Field& field() const { return field_; }
1087 AstNode* value() const { return value_; } 1092 AstNode* value() const { return value_; }
1088 1093
1089 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1094 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1090 value()->Visit(visitor); 1095 value()->Visit(visitor);
1091 } 1096 }
1092 1097
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 1340
1336 1341
1337 class StaticCallNode : public AstNode { 1342 class StaticCallNode : public AstNode {
1338 public: 1343 public:
1339 StaticCallNode(intptr_t token_pos, 1344 StaticCallNode(intptr_t token_pos,
1340 const Function& function, 1345 const Function& function,
1341 ArgumentListNode* arguments) 1346 ArgumentListNode* arguments)
1342 : AstNode(token_pos), 1347 : AstNode(token_pos),
1343 function_(function), 1348 function_(function),
1344 arguments_(arguments) { 1349 arguments_(arguments) {
1345 ASSERT(function.IsZoneHandle()); 1350 ASSERT(function_.IsZoneHandle());
1346 ASSERT(arguments_ != NULL); 1351 ASSERT(arguments_ != NULL);
1347 } 1352 }
1348 1353
1349 const Function& function() const { return function_; } 1354 const Function& function() const { return function_; }
1350 ArgumentListNode* arguments() const { return arguments_; } 1355 ArgumentListNode* arguments() const { return arguments_; }
1351 1356
1352 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1357 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1353 arguments()->Visit(visitor); 1358 arguments()->Visit(visitor);
1354 } 1359 }
1355 1360
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 const LocalVariable& context_var_; 1659 const LocalVariable& context_var_;
1655 1660
1656 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); 1661 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode);
1657 }; 1662 };
1658 1663
1659 } // namespace dart 1664 } // namespace dart
1660 1665
1661 #undef DECLARE_COMMON_NODE_FUNCTIONS 1666 #undef DECLARE_COMMON_NODE_FUNCTIONS
1662 1667
1663 #endif // VM_AST_H_ 1668 #endif // VM_AST_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_descriptors_test.cc » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698