Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Unified Diff: runtime/vm/parser.cc

Issue 9664062: Support allocating and calling closures in the new non-optimizing compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 59a9c8898558844a714837056a2be4b8d1ab8819..076d9780b944c1e6d05d84c71ccc0ab98ade4a54 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -112,6 +112,42 @@ static ThrowNode* CreateEvalConstConstructorThrow(intptr_t token_pos,
}
+void ParsedFunction::AllocateVariables() {
+ LocalScope* scope = node_sequence()->scope();
+ const int fixed_parameter_count = function().num_fixed_parameters();
+ const int optional_parameter_count = function().num_optional_parameters();
+ const int parameter_count = fixed_parameter_count + optional_parameter_count;
+ // Compute start indices to parameters and locals, and the number of
+ // parameters to copy.
+ if (optional_parameter_count == 0) {
+ // Parameter i will be at fp[1 + parameter_count - i] and local variable
+ // j will be at fp[-1 - j].
+ first_parameter_index_ = 1 + parameter_count;
+ first_local_index_ = -1;
+ copied_parameter_count_ = 0;
+ } else {
+ // Parameter i will be at fp[-1 - i] and local variable j will be at
+ // fp[-1 - parameter_count - j].
+ first_parameter_index_ = -1;
+ first_local_index_ = -1 - parameter_count;
+ copied_parameter_count_ = parameter_count;
+ }
+
+ // Allocate parameters and local variables, either in the local frame or
+ // in the context(s).
+ LocalScope* context_owner = NULL; // No context needed yet.
+ int next_free_frame_index =
+ scope->AllocateVariables(first_parameter_index_,
+ parameter_count,
+ first_local_index_,
+ scope,
+ &context_owner);
+ // Frame indices are relative to the frame pointer and are decreasing.
+ ASSERT(next_free_frame_index <= first_local_index_);
+ local_count_ = first_local_index_ - next_free_frame_index;
srdjan 2012/03/12 22:55:49 + copied_parameter_count_;
Kevin Millikin (Google) 2012/03/13 08:59:50 Consistent terminology will help. Maybe the name
+}
+
+
struct Parser::Block : public ZoneAllocated {
Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq)
: parent(outer_block), scope(local_scope), statements(seq) {
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/parser.h ('k') | runtime/vm/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698