Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 141 } |
| 142 | 142 |
| 143 | 143 |
| 144 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { | 144 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { |
| 145 ASSERT(node_sequence_ == NULL); | 145 ASSERT(node_sequence_ == NULL); |
| 146 ASSERT(node_sequence != NULL); | 146 ASSERT(node_sequence != NULL); |
| 147 node_sequence_ = node_sequence; | 147 node_sequence_ = node_sequence; |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 void ParsedFunction::SetRegExpCompileData( | |
| 152 RegExpCompileData* regexp_compile_data) { | |
| 153 ASSERT(regexp_compile_data_ == NULL); | |
| 154 ASSERT(regexp_compile_data != NULL); | |
| 155 regexp_compile_data_ = regexp_compile_data; | |
| 156 } | |
| 157 | |
| 158 | |
| 151 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { | 159 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { |
| 152 ASSERT(prefix.is_deferred_load()); | 160 ASSERT(prefix.is_deferred_load()); |
| 153 ASSERT(!prefix.is_loaded()); | 161 ASSERT(!prefix.is_loaded()); |
| 154 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { | 162 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { |
| 155 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { | 163 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { |
| 156 return; | 164 return; |
| 157 } | 165 } |
| 158 } | 166 } |
| 159 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); | 167 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); |
| 160 } | 168 } |
| 161 | 169 |
| 162 | 170 |
| 163 void ParsedFunction::AllocateVariables() { | 171 void ParsedFunction::AllocateVariables() { |
| 172 ASSERT(!function().IsIrregexpFunction()); | |
| 164 LocalScope* scope = node_sequence()->scope(); | 173 LocalScope* scope = node_sequence()->scope(); |
| 165 const intptr_t num_fixed_params = function().num_fixed_parameters(); | 174 const intptr_t num_fixed_params = function().num_fixed_parameters(); |
| 166 const intptr_t num_opt_params = function().NumOptionalParameters(); | 175 const intptr_t num_opt_params = function().NumOptionalParameters(); |
| 167 const intptr_t num_params = num_fixed_params + num_opt_params; | 176 const intptr_t num_params = num_fixed_params + num_opt_params; |
| 168 // Compute start indices to parameters and locals, and the number of | 177 // Compute start indices to parameters and locals, and the number of |
| 169 // parameters to copy. | 178 // parameters to copy. |
| 170 if (num_opt_params == 0) { | 179 if (num_opt_params == 0) { |
| 171 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and | 180 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
| 172 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. | 181 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
| 173 first_parameter_index_ = kParamEndSlotFromFp + num_params; | 182 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 202 struct CatchParamDesc { | 211 struct CatchParamDesc { |
| 203 CatchParamDesc() | 212 CatchParamDesc() |
| 204 : token_pos(0), type(NULL), name(NULL), var(NULL) { } | 213 : token_pos(0), type(NULL), name(NULL), var(NULL) { } |
| 205 intptr_t token_pos; | 214 intptr_t token_pos; |
| 206 const AbstractType* type; | 215 const AbstractType* type; |
| 207 const String* name; | 216 const String* name; |
| 208 LocalVariable* var; | 217 LocalVariable* var; |
| 209 }; | 218 }; |
| 210 | 219 |
| 211 | 220 |
| 221 void ParsedFunction::AllocateIrregexpVariables(intptr_t num_stack_locals) { | |
| 222 ASSERT(function().IsIrregexpFunction()); | |
| 223 ASSERT(function().NumOptionalParameters() == 0); | |
| 224 const intptr_t num_params = function().num_fixed_parameters();; | |
|
Ivan Posva
2014/11/05 07:56:30
As far as I understand this code, the number of fi
zerny-google
2014/11/05 11:52:00
Yes. Added the assert.
| |
| 225 // Compute start indices to parameters and locals, and the number of | |
| 226 // parameters to copy. | |
| 227 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and | |
| 228 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. | |
| 229 first_parameter_index_ = kParamEndSlotFromFp + num_params; | |
| 230 first_stack_local_index_ = kFirstLocalSlotFromFp; | |
| 231 num_copied_params_ = 0; | |
| 232 | |
| 233 // Frame indices are relative to the frame pointer and are decreasing. | |
| 234 num_stack_locals_ = num_stack_locals; | |
| 235 } | |
| 236 | |
| 237 | |
| 212 struct Parser::Block : public ZoneAllocated { | 238 struct Parser::Block : public ZoneAllocated { |
| 213 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 239 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
| 214 : parent(outer_block), scope(local_scope), statements(seq) { | 240 : parent(outer_block), scope(local_scope), statements(seq) { |
| 215 ASSERT(scope != NULL); | 241 ASSERT(scope != NULL); |
| 216 ASSERT(statements != NULL); | 242 ASSERT(statements != NULL); |
| 217 } | 243 } |
| 218 Block* parent; // Enclosing block, or NULL if outermost. | 244 Block* parent; // Enclosing block, or NULL if outermost. |
| 219 LocalScope* scope; | 245 LocalScope* scope; |
| 220 SequenceNode* statements; | 246 SequenceNode* statements; |
| 221 }; | 247 }; |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 node_sequence = parser.ParseMethodExtractor(func); | 848 node_sequence = parser.ParseMethodExtractor(func); |
| 823 break; | 849 break; |
| 824 case RawFunction::kNoSuchMethodDispatcher: | 850 case RawFunction::kNoSuchMethodDispatcher: |
| 825 node_sequence = | 851 node_sequence = |
| 826 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); | 852 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); |
| 827 break; | 853 break; |
| 828 case RawFunction::kInvokeFieldDispatcher: | 854 case RawFunction::kInvokeFieldDispatcher: |
| 829 node_sequence = | 855 node_sequence = |
| 830 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); | 856 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); |
| 831 break; | 857 break; |
| 858 case RawFunction::kIrregexpFunction: | |
| 859 UNREACHABLE(); // Irregexp functions have their own parser. | |
| 832 default: | 860 default: |
| 833 UNREACHABLE(); | 861 UNREACHABLE(); |
| 834 } | 862 } |
| 835 | 863 |
| 836 if (!HasReturnNode(node_sequence)) { | 864 if (!HasReturnNode(node_sequence)) { |
| 837 // Add implicit return node. | 865 // Add implicit return node. |
| 838 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 866 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
| 839 } | 867 } |
| 840 if (parsed_function->has_expression_temp_var()) { | 868 if (parsed_function->has_expression_temp_var()) { |
| 841 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 869 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
| (...skipping 11062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11904 void Parser::SkipQualIdent() { | 11932 void Parser::SkipQualIdent() { |
| 11905 ASSERT(IsIdentifier()); | 11933 ASSERT(IsIdentifier()); |
| 11906 ConsumeToken(); | 11934 ConsumeToken(); |
| 11907 if (CurrentToken() == Token::kPERIOD) { | 11935 if (CurrentToken() == Token::kPERIOD) { |
| 11908 ConsumeToken(); // Consume the kPERIOD token. | 11936 ConsumeToken(); // Consume the kPERIOD token. |
| 11909 ExpectIdentifier("identifier expected after '.'"); | 11937 ExpectIdentifier("identifier expected after '.'"); |
| 11910 } | 11938 } |
| 11911 } | 11939 } |
| 11912 | 11940 |
| 11913 } // namespace dart | 11941 } // namespace dart |
| OLD | NEW |