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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 void BreakableStatementChecker::Check(Expression* expr) { | 49 void BreakableStatementChecker::Check(Expression* expr) { |
50 Visit(expr); | 50 Visit(expr); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 void BreakableStatementChecker::VisitVariableDeclaration( | 54 void BreakableStatementChecker::VisitVariableDeclaration( |
55 VariableDeclaration* decl) { | 55 VariableDeclaration* decl) { |
56 } | 56 } |
57 | 57 |
| 58 void BreakableStatementChecker::VisitFunctionDeclaration( |
| 59 FunctionDeclaration* decl) { |
| 60 } |
| 61 |
58 void BreakableStatementChecker::VisitModuleDeclaration( | 62 void BreakableStatementChecker::VisitModuleDeclaration( |
59 ModuleDeclaration* decl) { | 63 ModuleDeclaration* decl) { |
60 } | 64 } |
61 | 65 |
62 | 66 |
63 void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { | 67 void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { |
64 } | 68 } |
65 | 69 |
66 void BreakableStatementChecker::VisitModuleVariable(ModuleVariable* module) { | 70 void BreakableStatementChecker::VisitModuleVariable(ModuleVariable* module) { |
67 } | 71 } |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 global_count_ = 0; | 566 global_count_ = 0; |
563 | 567 |
564 AstVisitor::VisitDeclarations(declarations); | 568 AstVisitor::VisitDeclarations(declarations); |
565 | 569 |
566 // Batch declare global functions and variables. | 570 // Batch declare global functions and variables. |
567 if (global_count_ > 0) { | 571 if (global_count_ > 0) { |
568 Handle<FixedArray> array = | 572 Handle<FixedArray> array = |
569 isolate()->factory()->NewFixedArray(2 * global_count_, TENURED); | 573 isolate()->factory()->NewFixedArray(2 * global_count_, TENURED); |
570 int length = declarations->length(); | 574 int length = declarations->length(); |
571 for (int j = 0, i = 0; i < length; i++) { | 575 for (int j = 0, i = 0; i < length; i++) { |
572 VariableDeclaration* decl = declarations->at(i)->AsVariableDeclaration(); | 576 Declaration* decl = declarations->at(i); |
573 if (decl != NULL) { | 577 Variable* var = decl->proxy()->var(); |
574 Variable* var = decl->proxy()->var(); | |
575 | 578 |
576 if (var->IsUnallocated()) { | 579 if (var->IsUnallocated()) { |
577 array->set(j++, *(var->name())); | 580 array->set(j++, *(var->name())); |
578 if (decl->fun() == NULL) { | 581 FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration(); |
579 if (var->binding_needs_init()) { | 582 if (fun_decl == NULL) { |
580 // In case this binding needs initialization use the hole. | 583 if (var->binding_needs_init()) { |
581 array->set_the_hole(j++); | 584 // In case this binding needs initialization use the hole. |
582 } else { | 585 array->set_the_hole(j++); |
583 array->set_undefined(j++); | |
584 } | |
585 } else { | 586 } else { |
586 Handle<SharedFunctionInfo> function = | 587 array->set_undefined(j++); |
587 Compiler::BuildFunctionInfo(decl->fun(), script()); | |
588 // Check for stack-overflow exception. | |
589 if (function.is_null()) { | |
590 SetStackOverflow(); | |
591 return; | |
592 } | |
593 array->set(j++, *function); | |
594 } | 588 } |
| 589 } else { |
| 590 Handle<SharedFunctionInfo> function = |
| 591 Compiler::BuildFunctionInfo(fun_decl->fun(), script()); |
| 592 // Check for stack-overflow exception. |
| 593 if (function.is_null()) { |
| 594 SetStackOverflow(); |
| 595 return; |
| 596 } |
| 597 array->set(j++, *function); |
595 } | 598 } |
596 } | 599 } |
597 } | 600 } |
598 // Invoke the platform-dependent code generator to do the actual | 601 // Invoke the platform-dependent code generator to do the actual |
599 // declaration the global functions and variables. | 602 // declaration the global functions and variables. |
600 DeclareGlobals(array); | 603 DeclareGlobals(array); |
601 } | 604 } |
602 | 605 |
603 global_count_ = save_global_count; | 606 global_count_ = save_global_count; |
604 } | 607 } |
605 | 608 |
606 | 609 |
607 void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { | 610 void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { |
| 611 EmitDeclaration(decl->proxy(), decl->mode(), NULL); |
| 612 } |
| 613 |
| 614 |
| 615 void FullCodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
608 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); | 616 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); |
609 } | 617 } |
610 | 618 |
611 | 619 |
612 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* decl) { | 620 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* decl) { |
613 // TODO(rossberg) | 621 EmitDeclaration(decl->proxy(), decl->mode(), NULL); |
614 } | 622 } |
615 | 623 |
616 | 624 |
617 void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) { | 625 void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) { |
618 // TODO(rossberg) | 626 // TODO(rossberg) |
619 } | 627 } |
620 | 628 |
621 | 629 |
622 void FullCodeGenerator::VisitModuleVariable(ModuleVariable* module) { | 630 void FullCodeGenerator::VisitModuleVariable(ModuleVariable* module) { |
623 // TODO(rossberg) | 631 // TODO(rossberg) |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 } | 1400 } |
1393 | 1401 |
1394 return false; | 1402 return false; |
1395 } | 1403 } |
1396 | 1404 |
1397 | 1405 |
1398 #undef __ | 1406 #undef __ |
1399 | 1407 |
1400 | 1408 |
1401 } } // namespace v8::internal | 1409 } } // namespace v8::internal |
OLD | NEW |