OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/ast-this-access-visitor.h" | 10 #include "src/ast-this-access-visitor.h" |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 Handle<Object> exception; | 779 Handle<Object> exception; |
780 if (!obj.ToHandle(&exception)) return; | 780 if (!obj.ToHandle(&exception)) return; |
781 | 781 |
782 MessageLocation location(info->script(), stmt->position(), stmt->position()); | 782 MessageLocation location(info->script(), stmt->position(), stmt->position()); |
783 USE(info->isolate()->Throw(*exception, &location)); | 783 USE(info->isolate()->Throw(*exception, &location)); |
784 } | 784 } |
785 | 785 |
786 | 786 |
787 static bool CheckSuperConstructorCall(CompilationInfo* info) { | 787 static bool CheckSuperConstructorCall(CompilationInfo* info) { |
788 FunctionLiteral* function = info->function(); | 788 FunctionLiteral* function = info->function(); |
| 789 if (FLAG_experimental_classes) return true; |
789 if (!function->uses_super_constructor_call()) return true; | 790 if (!function->uses_super_constructor_call()) return true; |
790 | |
791 if (function->is_default_constructor()) return true; | 791 if (function->is_default_constructor()) return true; |
792 | 792 |
793 ZoneList<Statement*>* body = function->body(); | 793 ZoneList<Statement*>* body = function->body(); |
794 CHECK(body->length() > 0); | 794 CHECK(body->length() > 0); |
795 | 795 |
796 int super_call_index = 0; | 796 int super_call_index = 0; |
797 // Allow 'use strict' and similiar and empty statements. | 797 // Allow 'use strict' and similiar and empty statements. |
798 while (true) { | 798 while (true) { |
799 CHECK(super_call_index < body->length()); // We know there is a super call. | 799 CHECK(super_call_index < body->length()); // We know there is a super call. |
800 Statement* stmt = body->at(super_call_index); | 800 Statement* stmt = body->at(super_call_index); |
(...skipping 29 matching lines...) Expand all Loading... |
830 ZoneList<Expression*>* arguments = callExpr->arguments(); | 830 ZoneList<Expression*>* arguments = callExpr->arguments(); |
831 | 831 |
832 AstThisAccessVisitor this_access_visitor(info->zone()); | 832 AstThisAccessVisitor this_access_visitor(info->zone()); |
833 this_access_visitor.VisitExpressions(arguments); | 833 this_access_visitor.VisitExpressions(arguments); |
834 | 834 |
835 if (this_access_visitor.HasStackOverflow()) return false; | 835 if (this_access_visitor.HasStackOverflow()) return false; |
836 if (this_access_visitor.UsesThis()) { | 836 if (this_access_visitor.UsesThis()) { |
837 ThrowSuperConstructorCheckError(info, stmt); | 837 ThrowSuperConstructorCheckError(info, stmt); |
838 return false; | 838 return false; |
839 } | 839 } |
840 | |
841 return true; | 840 return true; |
842 } | 841 } |
843 | 842 |
844 | 843 |
845 bool Compiler::Analyze(CompilationInfo* info) { | 844 bool Compiler::Analyze(CompilationInfo* info) { |
846 DCHECK(info->function() != NULL); | 845 DCHECK(info->function() != NULL); |
847 if (!Rewriter::Rewrite(info)) return false; | 846 if (!Rewriter::Rewrite(info)) return false; |
848 if (!Scope::Analyze(info)) return false; | 847 if (!Scope::Analyze(info)) return false; |
849 if (!Renumber(info)) return false; | 848 if (!Renumber(info)) return false; |
850 DCHECK(info->scope() != NULL); | 849 DCHECK(info->scope() != NULL); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 AllowHandleDereference allow_deref; | 1578 AllowHandleDereference allow_deref; |
1580 bool tracing_on = info()->IsStub() | 1579 bool tracing_on = info()->IsStub() |
1581 ? FLAG_trace_hydrogen_stubs | 1580 ? FLAG_trace_hydrogen_stubs |
1582 : (FLAG_trace_hydrogen && | 1581 : (FLAG_trace_hydrogen && |
1583 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1582 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1584 return (tracing_on && | 1583 return (tracing_on && |
1585 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1584 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1586 } | 1585 } |
1587 | 1586 |
1588 } } // namespace v8::internal | 1587 } } // namespace v8::internal |
OLD | NEW |