OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 // AST, so the AST should not continue to be used in the case of failure. | 982 // AST, so the AST should not continue to be used in the case of failure. |
983 bool Rewriter::Rewrite(CompilationInfo* info) { | 983 bool Rewriter::Rewrite(CompilationInfo* info) { |
984 FunctionLiteral* function = info->function(); | 984 FunctionLiteral* function = info->function(); |
985 ASSERT(function != NULL); | 985 ASSERT(function != NULL); |
986 Scope* scope = function->scope(); | 986 Scope* scope = function->scope(); |
987 ASSERT(scope != NULL); | 987 ASSERT(scope != NULL); |
988 if (scope->is_function_scope()) return true; | 988 if (scope->is_function_scope()) return true; |
989 | 989 |
990 ZoneList<Statement*>* body = function->body(); | 990 ZoneList<Statement*>* body = function->body(); |
991 if (!body->is_empty()) { | 991 if (!body->is_empty()) { |
992 Variable* result = scope->NewTemporary(Factory::result_symbol()); | 992 Variable* result = scope->NewTemporary( |
| 993 info->isolate()->factory()->result_symbol()); |
993 Processor processor(result); | 994 Processor processor(result); |
994 processor.Process(body); | 995 processor.Process(body); |
995 if (processor.HasStackOverflow()) return false; | 996 if (processor.HasStackOverflow()) return false; |
996 | 997 |
997 if (processor.result_assigned()) { | 998 if (processor.result_assigned()) { |
998 VariableProxy* result_proxy = new VariableProxy(result); | 999 VariableProxy* result_proxy = new VariableProxy(result); |
999 body->Add(new ReturnStatement(result_proxy)); | 1000 body->Add(new ReturnStatement(result_proxy)); |
1000 } | 1001 } |
1001 } | 1002 } |
1002 | 1003 |
(...skipping 11 matching lines...) Expand all Loading... |
1014 if (FLAG_optimize_ast && !body->is_empty()) { | 1015 if (FLAG_optimize_ast && !body->is_empty()) { |
1015 AstOptimizer optimizer; | 1016 AstOptimizer optimizer; |
1016 optimizer.Optimize(body); | 1017 optimizer.Optimize(body); |
1017 if (optimizer.HasStackOverflow()) return false; | 1018 if (optimizer.HasStackOverflow()) return false; |
1018 } | 1019 } |
1019 return true; | 1020 return true; |
1020 } | 1021 } |
1021 | 1022 |
1022 | 1023 |
1023 } } // namespace v8::internal | 1024 } } // namespace v8::internal |
OLD | NEW |