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

Side by Side Diff: src/full-codegen.cc

Issue 9348057: Split AST Declaration class, in preparation for new module declaration forms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Jakob's comments. Created 8 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 | « src/full-codegen.h ('k') | src/hydrogen.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void BreakableStatementChecker::Check(Statement* stmt) { 44 void BreakableStatementChecker::Check(Statement* stmt) {
45 Visit(stmt); 45 Visit(stmt);
46 } 46 }
47 47
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::VisitDeclaration(Declaration* decl) { 54 void BreakableStatementChecker::VisitVariableDeclaration(
55 VariableDeclaration* decl) {
55 } 56 }
56 57
57 58
58 void BreakableStatementChecker::VisitBlock(Block* stmt) { 59 void BreakableStatementChecker::VisitBlock(Block* stmt) {
59 } 60 }
60 61
61 62
62 void BreakableStatementChecker::VisitExpressionStatement( 63 void BreakableStatementChecker::VisitExpressionStatement(
63 ExpressionStatement* stmt) { 64 ExpressionStatement* stmt) {
64 // Check if expression is breakable. 65 // Check if expression is breakable.
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 517
517 518
518 void FullCodeGenerator::DoTest(const TestContext* context) { 519 void FullCodeGenerator::DoTest(const TestContext* context) {
519 DoTest(context->condition(), 520 DoTest(context->condition(),
520 context->true_label(), 521 context->true_label(),
521 context->false_label(), 522 context->false_label(),
522 context->fall_through()); 523 context->fall_through());
523 } 524 }
524 525
525 526
527 void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
528 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun());
529 }
530
531
526 void FullCodeGenerator::VisitDeclarations( 532 void FullCodeGenerator::VisitDeclarations(
527 ZoneList<Declaration*>* declarations) { 533 ZoneList<Declaration*>* declarations) {
528 int length = declarations->length(); 534 int save_global_count = global_count_;
529 int global_count = 0; 535 global_count_ = 0;
530 for (int i = 0; i < length; i++) { 536
531 Declaration* decl = declarations->at(i); 537 AstVisitor::VisitDeclarations(declarations);
532 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun(), &global_count);
533 }
534 538
535 // Batch declare global functions and variables. 539 // Batch declare global functions and variables.
536 if (global_count > 0) { 540 if (global_count_ > 0) {
537 Handle<FixedArray> array = 541 Handle<FixedArray> array =
538 isolate()->factory()->NewFixedArray(2 * global_count, TENURED); 542 isolate()->factory()->NewFixedArray(2 * global_count_, TENURED);
543 int length = declarations->length();
539 for (int j = 0, i = 0; i < length; i++) { 544 for (int j = 0, i = 0; i < length; i++) {
540 Declaration* decl = declarations->at(i); 545 VariableDeclaration* decl = declarations->at(i)->AsVariableDeclaration();
541 Variable* var = decl->proxy()->var(); 546 if (decl != NULL) {
547 Variable* var = decl->proxy()->var();
542 548
543 if (var->IsUnallocated()) { 549 if (var->IsUnallocated()) {
544 array->set(j++, *(var->name())); 550 array->set(j++, *(var->name()));
545 if (decl->fun() == NULL) { 551 if (decl->fun() == NULL) {
546 if (var->binding_needs_init()) { 552 if (var->binding_needs_init()) {
547 // In case this binding needs initialization use the hole. 553 // In case this binding needs initialization use the hole.
548 array->set_the_hole(j++); 554 array->set_the_hole(j++);
555 } else {
556 array->set_undefined(j++);
557 }
549 } else { 558 } else {
550 array->set_undefined(j++); 559 Handle<SharedFunctionInfo> function =
560 Compiler::BuildFunctionInfo(decl->fun(), script());
561 // Check for stack-overflow exception.
562 if (function.is_null()) {
563 SetStackOverflow();
564 return;
565 }
566 array->set(j++, *function);
551 } 567 }
552 } else {
553 Handle<SharedFunctionInfo> function =
554 Compiler::BuildFunctionInfo(decl->fun(), script());
555 // Check for stack-overflow exception.
556 if (function.is_null()) {
557 SetStackOverflow();
558 return;
559 }
560 array->set(j++, *function);
561 } 568 }
562 } 569 }
563 } 570 }
564 // Invoke the platform-dependent code generator to do the actual 571 // Invoke the platform-dependent code generator to do the actual
565 // declaration the global functions and variables. 572 // declaration the global functions and variables.
566 DeclareGlobals(array); 573 DeclareGlobals(array);
567 } 574 }
575
576 global_count_ = save_global_count;
568 } 577 }
569 578
570 579
571 int FullCodeGenerator::DeclareGlobalsFlags() { 580 int FullCodeGenerator::DeclareGlobalsFlags() {
572 ASSERT(DeclareGlobalsLanguageMode::is_valid(language_mode())); 581 ASSERT(DeclareGlobalsLanguageMode::is_valid(language_mode()));
573 return DeclareGlobalsEvalFlag::encode(is_eval()) | 582 return DeclareGlobalsEvalFlag::encode(is_eval()) |
574 DeclareGlobalsNativeFlag::encode(is_native()) | 583 DeclareGlobalsNativeFlag::encode(is_native()) |
575 DeclareGlobalsLanguageMode::encode(language_mode()); 584 DeclareGlobalsLanguageMode::encode(language_mode());
576 } 585 }
577 586
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 } 1335 }
1327 1336
1328 return false; 1337 return false;
1329 } 1338 }
1330 1339
1331 1340
1332 #undef __ 1341 #undef __
1333 1342
1334 1343
1335 } } // namespace v8::internal 1344 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698