| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 UnhandledException& excp = UnhandledException::Handle(); | 105 UnhandledException& excp = UnhandledException::Handle(); |
| 106 excp ^= obj.raw(); | 106 excp ^= obj.raw(); |
| 107 const Instance& exception = Instance::ZoneHandle(excp.exception()); | 107 const Instance& exception = Instance::ZoneHandle(excp.exception()); |
| 108 const Instance& stack_trace = Instance::ZoneHandle(excp.stacktrace()); | 108 const Instance& stack_trace = Instance::ZoneHandle(excp.stacktrace()); |
| 109 return new ThrowNode(token_pos, | 109 return new ThrowNode(token_pos, |
| 110 new LiteralNode(token_pos, exception), | 110 new LiteralNode(token_pos, exception), |
| 111 new LiteralNode(token_pos, stack_trace)); | 111 new LiteralNode(token_pos, stack_trace)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 void ParsedFunction::AllocateVariables() { |
| 116 LocalScope* scope = node_sequence()->scope(); |
| 117 const int fixed_parameter_count = function().num_fixed_parameters(); |
| 118 const int optional_parameter_count = function().num_optional_parameters(); |
| 119 const int parameter_count = fixed_parameter_count + optional_parameter_count; |
| 120 // Compute start indices to parameters and locals, and the number of |
| 121 // parameters to copy. |
| 122 if (optional_parameter_count == 0) { |
| 123 // Parameter i will be at fp[1 + parameter_count - i] and local variable |
| 124 // j will be at fp[-1 - j]. |
| 125 first_parameter_index_ = 1 + parameter_count; |
| 126 first_stack_local_index_ = -1; |
| 127 copied_parameter_count_ = 0; |
| 128 } else { |
| 129 // Parameter i will be at fp[-1 - i] and local variable j will be at |
| 130 // fp[-1 - parameter_count - j]. |
| 131 first_parameter_index_ = -1; |
| 132 first_stack_local_index_ = -1 - parameter_count; |
| 133 copied_parameter_count_ = parameter_count; |
| 134 } |
| 135 |
| 136 // Allocate parameters and local variables, either in the local frame or |
| 137 // in the context(s). |
| 138 LocalScope* context_owner = NULL; // No context needed yet. |
| 139 int next_free_frame_index = |
| 140 scope->AllocateVariables(first_parameter_index_, |
| 141 parameter_count, |
| 142 first_stack_local_index_, |
| 143 scope, |
| 144 &context_owner); |
| 145 // Frame indices are relative to the frame pointer and are decreasing. |
| 146 ASSERT(next_free_frame_index <= first_stack_local_index_); |
| 147 stack_local_count_ = first_stack_local_index_ - next_free_frame_index; |
| 148 } |
| 149 |
| 150 |
| 115 struct Parser::Block : public ZoneAllocated { | 151 struct Parser::Block : public ZoneAllocated { |
| 116 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 152 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
| 117 : parent(outer_block), scope(local_scope), statements(seq) { | 153 : parent(outer_block), scope(local_scope), statements(seq) { |
| 118 ASSERT(scope != NULL); | 154 ASSERT(scope != NULL); |
| 119 ASSERT(statements != NULL); | 155 ASSERT(statements != NULL); |
| 120 } | 156 } |
| 121 Block* parent; // Enclosing block, or NULL if outermost. | 157 Block* parent; // Enclosing block, or NULL if outermost. |
| 122 LocalScope* scope; | 158 LocalScope* scope; |
| 123 SequenceNode* statements; | 159 SequenceNode* statements; |
| 124 }; | 160 }; |
| (...skipping 8042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8167 void Parser::SkipQualIdent() { | 8203 void Parser::SkipQualIdent() { |
| 8168 ASSERT(IsIdentifier()); | 8204 ASSERT(IsIdentifier()); |
| 8169 ConsumeToken(); | 8205 ConsumeToken(); |
| 8170 if (CurrentToken() == Token::kPERIOD) { | 8206 if (CurrentToken() == Token::kPERIOD) { |
| 8171 ConsumeToken(); // Consume the kPERIOD token. | 8207 ConsumeToken(); // Consume the kPERIOD token. |
| 8172 ExpectIdentifier("identifier expected after '.'"); | 8208 ExpectIdentifier("identifier expected after '.'"); |
| 8173 } | 8209 } |
| 8174 } | 8210 } |
| 8175 | 8211 |
| 8176 } // namespace dart | 8212 } // namespace dart |
| OLD | NEW |