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

Side by Side Diff: runtime/vm/scopes.h

Issue 10579020: Support captured variables in debugger (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef VM_SCOPES_H_ 5 #ifndef VM_SCOPES_H_
6 #define VM_SCOPES_H_ 6 #define VM_SCOPES_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 bool Equals(const LocalVariable& other) const; 73 bool Equals(const LocalVariable& other) const;
74 74
75 // Map the frame index to a bit-vector index. Assumes the variable is 75 // Map the frame index to a bit-vector index. Assumes the variable is
76 // allocated to the frame. 76 // allocated to the frame.
77 // var_count is the total number of stack-allocated variables including 77 // var_count is the total number of stack-allocated variables including
78 // all parameters. 78 // all parameters.
79 int BitIndexIn(intptr_t var_count) const; 79 int BitIndexIn(intptr_t var_count) const;
80 80
81 // Name of the internal variable that is used to save the context chain
82 // on function entry.
83 static const char* kSavedContextVarName;
84
81 private: 85 private:
82 static const int kUnitializedIndex = INT_MIN; 86 static const int kUnitializedIndex = INT_MIN;
83 87
84 const intptr_t token_index_; 88 const intptr_t token_index_;
85 const String& name_; 89 const String& name_;
86 LocalScope* owner_; // Local scope declaring this variable. 90 LocalScope* owner_; // Local scope declaring this variable.
87 91
88 const AbstractType& type_; // Declaration type of local variable. 92 const AbstractType& type_; // Declaration type of local variable.
89 93
90 bool is_final_; // If true, this variable is readonly. 94 bool is_final_; // If true, this variable is readonly.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int context_level() const { 215 int context_level() const {
212 ASSERT(HasContextLevel()); 216 ASSERT(HasContextLevel());
213 return context_level_; 217 return context_level_;
214 } 218 }
215 void set_context_level(int context_level) { 219 void set_context_level(int context_level) {
216 ASSERT(!HasContextLevel()); 220 ASSERT(!HasContextLevel());
217 ASSERT(context_level != kUnitializedContextLevel); 221 ASSERT(context_level != kUnitializedContextLevel);
218 context_level_ = context_level; 222 context_level_ = context_level;
219 } 223 }
220 224
225 intptr_t begin_token_index() const { return begin_token_index_; }
226 void set_begin_token_index(intptr_t value) { begin_token_index_ = value; }
227
221 intptr_t end_token_index() const { return end_token_index_; } 228 intptr_t end_token_index() const { return end_token_index_; }
222 void set_end_token_index(intptr_t value) { end_token_index_ = value; } 229 void set_end_token_index(intptr_t value) { end_token_index_ = value; }
223 230
224 // The number of variables allocated in the context and belonging to this 231 // The number of variables allocated in the context and belonging to this
225 // scope and to its children at the same loop level. 232 // scope and to its children at the same loop level.
226 int num_context_variables() const { return num_context_variables_; } 233 int num_context_variables() const { return num_context_variables_; }
227 234
228 // Add a variable to the scope. Returns false if a variable with the 235 // Add a variable to the scope. Returns false if a variable with the
229 // same name is already present. 236 // same name is already present.
230 bool AddVariable(LocalVariable* variable); 237 bool AddVariable(LocalVariable* variable);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Two locals in different sibling scopes may share the same frame slot. 293 // Two locals in different sibling scopes may share the same frame slot.
287 // Return the index of the next available frame slot. 294 // Return the index of the next available frame slot.
288 int AllocateVariables(int first_parameter_index, 295 int AllocateVariables(int first_parameter_index,
289 int num_parameters, 296 int num_parameters,
290 int first_frame_index, 297 int first_frame_index,
291 LocalScope* loop_owner, 298 LocalScope* loop_owner,
292 LocalScope** context_owner); 299 LocalScope** context_owner);
293 300
294 // Creates variable info for the scope and all its nested scopes. 301 // Creates variable info for the scope and all its nested scopes.
295 // Must be called after AllocateVariables() has been called. 302 // Must be called after AllocateVariables() has been called.
296 RawLocalVarDescriptors* GetVarDescriptors(); 303 RawLocalVarDescriptors* GetVarDescriptors(const Function& func);
297 304
298 // Create a ContextScope object describing all captured variables referenced 305 // Create a ContextScope object describing all captured variables referenced
299 // from this scope and belonging to outer scopes. 306 // from this scope and belonging to outer scopes.
300 RawContextScope* PreserveOuterScope(int current_context_level) const; 307 RawContextScope* PreserveOuterScope(int current_context_level) const;
301 308
302 // Creates a LocalScope representing the outer scope of a local function to be 309 // Creates a LocalScope representing the outer scope of a local function to be
303 // compiled. This outer scope contains the variables captured by the function 310 // compiled. This outer scope contains the variables captured by the function
304 // as specified by the given ContextScope, which was created during the 311 // as specified by the given ContextScope, which was created during the
305 // compilation of the enclosing function. 312 // compilation of the enclosing function.
306 static LocalScope* RestoreOuterScope(const ContextScope& context_scope); 313 static LocalScope* RestoreOuterScope(const ContextScope& context_scope);
307 314
308 // Create a ContextScope object which will capture "this" for an implicit 315 // Create a ContextScope object which will capture "this" for an implicit
309 // closure object. 316 // closure object.
310 static RawContextScope* CreateImplicitClosureScope(const Function& func); 317 static RawContextScope* CreateImplicitClosureScope(const Function& func);
311 318
312 private: 319 private:
320 struct VarDesc {
321 const String* name;
322 RawLocalVarDescriptors::VarInfo info;
323 };
324
313 // Allocate the variable in the current context, possibly updating the current 325 // Allocate the variable in the current context, possibly updating the current
314 // context owner scope, if the variable is the first one to be allocated at 326 // context owner scope, if the variable is the first one to be allocated at
315 // this loop level. 327 // this loop level.
316 // The variable may belong to this scope or to any of its children, but at the 328 // The variable may belong to this scope or to any of its children, but at the
317 // same loop level. 329 // same loop level.
318 void AllocateContextVariable(LocalVariable* variable, 330 void AllocateContextVariable(LocalVariable* variable,
319 LocalScope** context_owner); 331 LocalScope** context_owner);
320 332
321 void CollectLocalVariables(GrowableArray<LocalVariable*>* vars); 333 void CollectLocalVariables(GrowableArray<VarDesc>* vars, int16_t* scope_id);
322 334
323 static const int kUnitializedContextLevel = INT_MIN; 335 static const int kUnitializedContextLevel = INT_MIN;
324 LocalScope* parent_; 336 LocalScope* parent_;
325 LocalScope* child_; 337 LocalScope* child_;
326 LocalScope* sibling_; 338 LocalScope* sibling_;
327 int function_level_; // Reflects the nesting level of local functions. 339 int function_level_; // Reflects the nesting level of local functions.
328 int loop_level_; // Reflects the loop nesting level. 340 int loop_level_; // Reflects the loop nesting level.
329 int context_level_; // Reflects the level of the runtime context. 341 int context_level_; // Reflects the level of the runtime context.
330 int num_context_variables_; // Only set if this scope is a context owner. 342 int num_context_variables_; // Only set if this scope is a context owner.
331 intptr_t end_token_index_; // Token index of end of scope. 343 intptr_t begin_token_index_; // Token index of beginning of scope.
344 intptr_t end_token_index_; // Token index of end of scope.
332 GrowableArray<LocalVariable*> variables_; 345 GrowableArray<LocalVariable*> variables_;
333 GrowableArray<SourceLabel*> labels_; 346 GrowableArray<SourceLabel*> labels_;
334 347
335 DISALLOW_COPY_AND_ASSIGN(LocalScope); 348 DISALLOW_COPY_AND_ASSIGN(LocalScope);
336 }; 349 };
337 350
338 } // namespace dart 351 } // namespace dart
339 352
340 #endif // VM_SCOPES_H_ 353 #endif // VM_SCOPES_H_
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698