| 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/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
| (...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2941 } | 2941 } |
| 2942 | 2942 |
| 2943 // Make statement: if (flag == 1) { flag = 0; } else { next; }. | 2943 // Make statement: if (flag == 1) { flag = 0; } else { next; }. |
| 2944 { | 2944 { |
| 2945 Expression* compare = NULL; | 2945 Expression* compare = NULL; |
| 2946 // Make compare expresion: flag == 1. | 2946 // Make compare expresion: flag == 1. |
| 2947 { | 2947 { |
| 2948 Expression* const1 = factory()->NewLiteral(smi1, RelocInfo::kNoPosition); | 2948 Expression* const1 = factory()->NewLiteral(smi1, RelocInfo::kNoPosition); |
| 2949 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); | 2949 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); |
| 2950 compare = factory()->NewCompareOperation( | 2950 compare = factory()->NewCompareOperation( |
| 2951 Token::EQ, flag_proxy, const1, RelocInfo::kNoPosition); | 2951 Token::EQ, flag_proxy, const1, pos); |
| 2952 } | 2952 } |
| 2953 Statement* clear_flag = NULL; | 2953 Statement* clear_flag = NULL; |
| 2954 // Make statement: flag = 0. | 2954 // Make statement: flag = 0. |
| 2955 { | 2955 { |
| 2956 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); | 2956 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); |
| 2957 Expression* const0 = factory()->NewLiteral(smi0, RelocInfo::kNoPosition); | 2957 Expression* const0 = factory()->NewLiteral(smi0, RelocInfo::kNoPosition); |
| 2958 Assignment* assignment = factory()->NewAssignment( | 2958 Assignment* assignment = factory()->NewAssignment( |
| 2959 Token::ASSIGN, flag_proxy, const0, RelocInfo::kNoPosition); | 2959 Token::ASSIGN, flag_proxy, const0, RelocInfo::kNoPosition); |
| 2960 clear_flag = factory()->NewExpressionStatement(assignment, pos); | 2960 clear_flag = factory()->NewExpressionStatement(assignment, pos); |
| 2961 } | 2961 } |
| 2962 Statement* clear_flag_or_next = factory()->NewIfStatement( | 2962 Statement* clear_flag_or_next = factory()->NewIfStatement( |
| 2963 compare, clear_flag, next, RelocInfo::kNoPosition); | 2963 compare, clear_flag, next, RelocInfo::kNoPosition); |
| 2964 inner_block->AddStatement(clear_flag_or_next, zone()); | 2964 inner_block->AddStatement(clear_flag_or_next, zone()); |
| 2965 } | 2965 } |
| 2966 | 2966 |
| 2967 | 2967 |
| 2968 // Make statement: if (cond) { } else { break; }. | 2968 // Make statement: if (cond) { } else { break; }. |
| 2969 { | 2969 { |
| 2970 Statement* empty = factory()->NewEmptyStatement(RelocInfo::kNoPosition); | 2970 Statement* empty = factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| 2971 BreakableStatement* t = LookupBreakTarget(Handle<String>(), CHECK_OK); | 2971 BreakableStatement* t = LookupBreakTarget(Handle<String>(), CHECK_OK); |
| 2972 Statement* stop = factory()->NewBreakStatement(t, RelocInfo::kNoPosition); | 2972 Statement* stop = factory()->NewBreakStatement(t, RelocInfo::kNoPosition); |
| 2973 Statement* if_not_cond_break = factory()->NewIfStatement( | 2973 Statement* if_not_cond_break = factory()->NewIfStatement( |
| 2974 cond, empty, stop, RelocInfo::kNoPosition); | 2974 cond, empty, stop, cond->position()); |
| 2975 inner_block->AddStatement(if_not_cond_break, zone()); | 2975 inner_block->AddStatement(if_not_cond_break, zone()); |
| 2976 } | 2976 } |
| 2977 | 2977 |
| 2978 inner_block->AddStatement(body, zone()); | 2978 inner_block->AddStatement(body, zone()); |
| 2979 | 2979 |
| 2980 // For each let variable x: | 2980 // For each let variable x: |
| 2981 // make statement: temp_x = x; | 2981 // make statement: temp_x = x; |
| 2982 for (int i = 0; i < names->length(); i++) { | 2982 for (int i = 0; i < names->length(); i++) { |
| 2983 VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i)); | 2983 VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i)); |
| 2984 int pos = scanner()->location().end_pos; | 2984 int pos = scanner()->location().end_pos; |
| (...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4781 ASSERT(info()->isolate()->has_pending_exception()); | 4781 ASSERT(info()->isolate()->has_pending_exception()); |
| 4782 } else { | 4782 } else { |
| 4783 result = ParseProgram(); | 4783 result = ParseProgram(); |
| 4784 } | 4784 } |
| 4785 } | 4785 } |
| 4786 info()->SetFunction(result); | 4786 info()->SetFunction(result); |
| 4787 return (result != NULL); | 4787 return (result != NULL); |
| 4788 } | 4788 } |
| 4789 | 4789 |
| 4790 } } // namespace v8::internal | 4790 } } // namespace v8::internal |
| OLD | NEW |