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::SetNodeSequence(SequenceNode* node_sequence) { | |
116 ASSERT(node_sequence_ == NULL); | |
117 ASSERT(node_sequence != NULL); | |
118 node_sequence_ = node_sequence; | |
119 const int num_fixed_params = function().num_fixed_parameters(); | |
120 const int num_opt_params = function().num_optional_parameters(); | |
121 // Allocated ids for parameters. | |
122 intptr_t parameter_id = AstNode::kNoId; | |
123 for (intptr_t i = 0; i < num_fixed_params + num_opt_params; i++) { | |
124 parameter_id = AstNode::GetNextId(); | |
125 if (i == 0) { | |
126 node_sequence_->set_first_parameter_id(parameter_id); | |
127 } | |
128 } | |
129 node_sequence_->set_last_parameter_id(parameter_id); | |
regis
2012/04/18 23:59:13
It is strange to call set_last_parameter_id, but n
srdjan
2012/04/19 00:04:20
Discussed off-line: last parameter id is set to kN
| |
130 } | |
131 | |
115 void ParsedFunction::AllocateVariables() { | 132 void ParsedFunction::AllocateVariables() { |
116 LocalScope* scope = node_sequence()->scope(); | 133 LocalScope* scope = node_sequence()->scope(); |
117 const int fixed_parameter_count = function().num_fixed_parameters(); | 134 const int fixed_parameter_count = function().num_fixed_parameters(); |
118 const int optional_parameter_count = function().num_optional_parameters(); | 135 const int optional_parameter_count = function().num_optional_parameters(); |
119 const int parameter_count = fixed_parameter_count + optional_parameter_count; | 136 const int parameter_count = fixed_parameter_count + optional_parameter_count; |
120 // Compute start indices to parameters and locals, and the number of | 137 // Compute start indices to parameters and locals, and the number of |
121 // parameters to copy. | 138 // parameters to copy. |
122 if (optional_parameter_count == 0) { | 139 if (optional_parameter_count == 0) { |
123 // Parameter i will be at fp[1 + parameter_count - i] and local variable | 140 // Parameter i will be at fp[1 + parameter_count - i] and local variable |
124 // j will be at fp[-1 - j]. | 141 // j will be at fp[-1 - j]. |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 node_sequence = parser.ParseStaticConstGetter(func); | 676 node_sequence = parser.ParseStaticConstGetter(func); |
660 break; | 677 break; |
661 default: | 678 default: |
662 UNREACHABLE(); | 679 UNREACHABLE(); |
663 } | 680 } |
664 | 681 |
665 if (!HasReturnNode(node_sequence)) { | 682 if (!HasReturnNode(node_sequence)) { |
666 // Add implicit return node. | 683 // Add implicit return node. |
667 node_sequence->Add(new ReturnNode(parser.token_index_)); | 684 node_sequence->Add(new ReturnNode(parser.token_index_)); |
668 } | 685 } |
669 parsed_function->set_node_sequence(node_sequence); | 686 parsed_function->SetNodeSequence(node_sequence); |
670 | 687 |
671 // The instantiator may be required at run time for generic type checks or | 688 // The instantiator may be required at run time for generic type checks or |
672 // allocation of generic types. | 689 // allocation of generic types. |
673 if (parser.IsInstantiatorRequired()) { | 690 if (parser.IsInstantiatorRequired()) { |
674 // In the case of a local function, only set the instantiator if the | 691 // In the case of a local function, only set the instantiator if the |
675 // receiver was captured. | 692 // receiver was captured. |
676 const bool kTestOnly = true; | 693 const bool kTestOnly = true; |
677 LocalVariable* receiver = | 694 LocalVariable* receiver = |
678 parser.LookupReceiver(node_sequence->scope(), | 695 parser.LookupReceiver(node_sequence->scope(), |
679 kTestOnly); | 696 kTestOnly); |
(...skipping 7707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8387 void Parser::SkipQualIdent() { | 8404 void Parser::SkipQualIdent() { |
8388 ASSERT(IsIdentifier()); | 8405 ASSERT(IsIdentifier()); |
8389 ConsumeToken(); | 8406 ConsumeToken(); |
8390 if (CurrentToken() == Token::kPERIOD) { | 8407 if (CurrentToken() == Token::kPERIOD) { |
8391 ConsumeToken(); // Consume the kPERIOD token. | 8408 ConsumeToken(); // Consume the kPERIOD token. |
8392 ExpectIdentifier("identifier expected after '.'"); | 8409 ExpectIdentifier("identifier expected after '.'"); |
8393 } | 8410 } |
8394 } | 8411 } |
8395 | 8412 |
8396 } // namespace dart | 8413 } // namespace dart |
OLD | NEW |