Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 template<class> friend class AstNodeFactory; | 1204 template<class> friend class AstNodeFactory; |
| 1205 | 1205 |
| 1206 EmptyStatement() {} | 1206 EmptyStatement() {} |
| 1207 }; | 1207 }; |
| 1208 | 1208 |
| 1209 | 1209 |
| 1210 class Literal: public Expression { | 1210 class Literal: public Expression { |
| 1211 public: | 1211 public: |
| 1212 DECLARE_NODE_TYPE(Literal) | 1212 DECLARE_NODE_TYPE(Literal) |
| 1213 | 1213 |
| 1214 // Check if this literal is identical to the other literal. | |
| 1215 bool IsIdenticalTo(const Literal* other) const { | |
| 1216 return handle_.is_identical_to(other->handle_); | |
| 1217 } | |
| 1218 | |
| 1219 virtual bool IsPropertyName() { | 1214 virtual bool IsPropertyName() { |
| 1220 if (handle_->IsSymbol()) { | 1215 if (handle_->IsSymbol()) { |
| 1221 uint32_t ignored; | 1216 uint32_t ignored; |
| 1222 return !String::cast(*handle_)->AsArrayIndex(&ignored); | 1217 return !String::cast(*handle_)->AsArrayIndex(&ignored); |
| 1223 } | 1218 } |
| 1224 return false; | 1219 return false; |
| 1225 } | 1220 } |
| 1226 | 1221 |
| 1227 Handle<String> AsPropertyName() { | 1222 Handle<String> AsPropertyName() { |
| 1228 ASSERT(IsPropertyName()); | 1223 ASSERT(IsPropertyName()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1241 ASSERT(!handle_.is_null()); | 1236 ASSERT(!handle_.is_null()); |
| 1242 return handle_->IsTrue(); | 1237 return handle_->IsTrue(); |
| 1243 } | 1238 } |
| 1244 bool IsFalse() const { | 1239 bool IsFalse() const { |
| 1245 ASSERT(!handle_.is_null()); | 1240 ASSERT(!handle_.is_null()); |
| 1246 return handle_->IsFalse(); | 1241 return handle_->IsFalse(); |
| 1247 } | 1242 } |
| 1248 | 1243 |
| 1249 Handle<Object> handle() const { return handle_; } | 1244 Handle<Object> handle() const { return handle_; } |
| 1250 | 1245 |
| 1246 // Support for using Literal as a HashMap key. NOTE: Currently, this works | |
| 1247 // only for string and number literals! | |
| 1248 uint32_t Hash() { return ToString()->Hash(); } | |
| 1249 | |
| 1250 static bool Match(void* literal1, void* literal2) { | |
| 1251 Handle<String> s1 = reinterpret_cast<Literal*>(literal1)->ToString(); | |
| 1252 Handle<String> s2 = reinterpret_cast<Literal*>(literal2)->ToString(); | |
|
rossberg
2012/03/08 16:51:39
Could be static_cast.
Sven Panne
2012/03/09 08:24:46
Although the real difference between those casts i
| |
| 1253 return s1->Equals(*s2); | |
| 1254 } | |
| 1255 | |
| 1251 protected: | 1256 protected: |
| 1252 template<class> friend class AstNodeFactory; | 1257 template<class> friend class AstNodeFactory; |
| 1253 | 1258 |
| 1254 Literal(Isolate* isolate, Handle<Object> handle) | 1259 Literal(Isolate* isolate, Handle<Object> handle) |
| 1255 : Expression(isolate), | 1260 : Expression(isolate), |
| 1256 handle_(handle) { } | 1261 handle_(handle) { } |
| 1257 | 1262 |
| 1258 private: | 1263 private: |
| 1264 Handle<String> ToString(); | |
| 1265 | |
| 1259 Handle<Object> handle_; | 1266 Handle<Object> handle_; |
| 1260 }; | 1267 }; |
| 1261 | 1268 |
| 1262 | 1269 |
| 1263 // Base class for literals that needs space in the corresponding JSFunction. | 1270 // Base class for literals that needs space in the corresponding JSFunction. |
| 1264 class MaterializedLiteral: public Expression { | 1271 class MaterializedLiteral: public Expression { |
| 1265 public: | 1272 public: |
| 1266 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1273 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1267 | 1274 |
| 1268 int literal_index() { return literal_index_; } | 1275 int literal_index() { return literal_index_; } |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2953 private: | 2960 private: |
| 2954 Isolate* isolate_; | 2961 Isolate* isolate_; |
| 2955 Zone* zone_; | 2962 Zone* zone_; |
| 2956 Visitor visitor_; | 2963 Visitor visitor_; |
| 2957 }; | 2964 }; |
| 2958 | 2965 |
| 2959 | 2966 |
| 2960 } } // namespace v8::internal | 2967 } } // namespace v8::internal |
| 2961 | 2968 |
| 2962 #endif // V8_AST_H_ | 2969 #endif // V8_AST_H_ |
| OLD | NEW |