| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "typing.h" | 5 #include "typing.h" |
| 6 | 6 |
| 7 #include "frames.h" | 7 #include "frames.h" |
| 8 #include "frames-inl.h" | 8 #include "frames-inl.h" |
| 9 #include "parser.h" // for CompileTimeValue; TODO(rossberg): should move | 9 #include "parser.h" // for CompileTimeValue; TODO(rossberg): should move |
| 10 #include "scopes.h" | 10 #include "scopes.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 void AstTyper::VisitLiteral(Literal* expr) { | 386 void AstTyper::VisitLiteral(Literal* expr) { |
| 387 Type* type = Type::Constant(expr->value(), zone()); | 387 Type* type = Type::Constant(expr->value(), zone()); |
| 388 NarrowType(expr, Bounds(type)); | 388 NarrowType(expr, Bounds(type)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 | 391 |
| 392 void AstTyper::VisitStringLiteral(StringLiteral* expr) { |
| 393 VisitLiteral(expr); |
| 394 } |
| 395 |
| 396 |
| 397 void AstTyper::VisitNumberLiteral(NumberLiteral* expr) { |
| 398 VisitLiteral(expr); |
| 399 } |
| 400 |
| 401 |
| 392 void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) { | 402 void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 393 NarrowType(expr, Bounds(Type::RegExp(zone()))); | 403 NarrowType(expr, Bounds(Type::RegExp(zone()))); |
| 394 } | 404 } |
| 395 | 405 |
| 396 | 406 |
| 397 void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) { | 407 void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) { |
| 398 ZoneList<ObjectLiteral::Property*>* properties = expr->properties(); | 408 ZoneList<ObjectLiteral::Property*>* properties = expr->properties(); |
| 399 for (int i = 0; i < properties->length(); ++i) { | 409 for (int i = 0; i < properties->length(); ++i) { |
| 400 ObjectLiteral::Property* prop = properties->at(i); | 410 ObjectLiteral::Property* prop = properties->at(i); |
| 401 | 411 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 427 | 437 |
| 428 | 438 |
| 429 void AstTyper::VisitAssignment(Assignment* expr) { | 439 void AstTyper::VisitAssignment(Assignment* expr) { |
| 430 // Collect type feedback. | 440 // Collect type feedback. |
| 431 Property* prop = expr->target()->AsProperty(); | 441 Property* prop = expr->target()->AsProperty(); |
| 432 if (prop != NULL) { | 442 if (prop != NULL) { |
| 433 TypeFeedbackId id = expr->AssignmentFeedbackId(); | 443 TypeFeedbackId id = expr->AssignmentFeedbackId(); |
| 434 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); | 444 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); |
| 435 if (!expr->IsUninitialized()) { | 445 if (!expr->IsUninitialized()) { |
| 436 if (prop->key()->IsPropertyName()) { | 446 if (prop->key()->IsPropertyName()) { |
| 437 Literal* lit_key = prop->key()->AsLiteral(); | 447 StringLiteral* lit_key = prop->key()->AsStringLiteral(); |
| 438 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 448 ASSERT(lit_key != NULL); |
| 439 Handle<String> name = Handle<String>::cast(lit_key->value()); | 449 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 440 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); | 450 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); |
| 441 } else { | 451 } else { |
| 442 KeyedAccessStoreMode store_mode; | 452 KeyedAccessStoreMode store_mode; |
| 443 oracle()->KeyedAssignmentReceiverTypes( | 453 oracle()->KeyedAssignmentReceiverTypes( |
| 444 id, expr->GetReceiverTypes(), &store_mode); | 454 id, expr->GetReceiverTypes(), &store_mode); |
| 445 expr->set_store_mode(store_mode); | 455 expr->set_store_mode(store_mode); |
| 446 } | 456 } |
| 447 } | 457 } |
| 448 } | 458 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 475 NarrowType(expr, Bounds(Type::None(zone()))); | 485 NarrowType(expr, Bounds(Type::None(zone()))); |
| 476 } | 486 } |
| 477 | 487 |
| 478 | 488 |
| 479 void AstTyper::VisitProperty(Property* expr) { | 489 void AstTyper::VisitProperty(Property* expr) { |
| 480 // Collect type feedback. | 490 // Collect type feedback. |
| 481 TypeFeedbackId id = expr->PropertyFeedbackId(); | 491 TypeFeedbackId id = expr->PropertyFeedbackId(); |
| 482 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); | 492 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); |
| 483 if (!expr->IsUninitialized()) { | 493 if (!expr->IsUninitialized()) { |
| 484 if (expr->key()->IsPropertyName()) { | 494 if (expr->key()->IsPropertyName()) { |
| 485 Literal* lit_key = expr->key()->AsLiteral(); | 495 StringLiteral* lit_key = expr->key()->AsStringLiteral(); |
| 486 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 496 ASSERT(lit_key != NULL); |
| 487 Handle<String> name = Handle<String>::cast(lit_key->value()); | 497 Handle<String> name = lit_key->string(); |
| 488 bool is_prototype; | 498 bool is_prototype; |
| 489 oracle()->PropertyReceiverTypes( | 499 oracle()->PropertyReceiverTypes( |
| 490 id, name, expr->GetReceiverTypes(), &is_prototype); | 500 id, name, expr->GetReceiverTypes(), &is_prototype); |
| 491 expr->set_is_function_prototype(is_prototype); | 501 expr->set_is_function_prototype(is_prototype); |
| 492 } else { | 502 } else { |
| 493 bool is_string; | 503 bool is_string; |
| 494 oracle()->KeyedPropertyReceiverTypes( | 504 oracle()->KeyedPropertyReceiverTypes( |
| 495 id, expr->GetReceiverTypes(), &is_string); | 505 id, expr->GetReceiverTypes(), &is_string); |
| 496 expr->set_is_string_access(is_string); | 506 expr->set_is_string_access(is_string); |
| 497 } | 507 } |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 780 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 771 } | 781 } |
| 772 | 782 |
| 773 | 783 |
| 774 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 784 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 775 RECURSE(Visit(stmt->body())); | 785 RECURSE(Visit(stmt->body())); |
| 776 } | 786 } |
| 777 | 787 |
| 778 | 788 |
| 779 } } // namespace v8::internal | 789 } } // namespace v8::internal |
| OLD | NEW |