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

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

Issue 14942010: Eliminate temporary locals for some expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/parser.cc ('k') | runtime/vm/symbols.h » ('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 14 matching lines...) Expand all
25 const String& name, 25 const String& name,
26 const AbstractType& type) 26 const AbstractType& type)
27 : token_pos_(token_pos), 27 : token_pos_(token_pos),
28 name_(name), 28 name_(name),
29 owner_(NULL), 29 owner_(NULL),
30 type_(type), 30 type_(type),
31 const_value_(NULL), 31 const_value_(NULL),
32 is_final_(false), 32 is_final_(false),
33 is_captured_(false), 33 is_captured_(false),
34 is_invisible_(false), 34 is_invisible_(false),
35 index_(LocalVariable::kUnitializedIndex) { 35 index_(LocalVariable::kUninitializedIndex) {
36 ASSERT(type.IsZoneHandle()); 36 ASSERT(type.IsZoneHandle());
37 ASSERT(type.IsFinalized()); 37 ASSERT(type.IsFinalized());
38 } 38 }
39 39
40 intptr_t token_pos() const { return token_pos_; } 40 intptr_t token_pos() const { return token_pos_; }
41 const String& name() const { return name_; } 41 const String& name() const { return name_; }
42 LocalScope* owner() const { return owner_; } 42 LocalScope* owner() const { return owner_; }
43 void set_owner(LocalScope* owner) { 43 void set_owner(LocalScope* owner) {
44 ASSERT(owner_ == NULL); 44 ASSERT(owner_ == NULL);
45 owner_ = owner; 45 owner_ = owner;
46 } 46 }
47 47
48 const AbstractType& type() const { return type_; } 48 const AbstractType& type() const { return type_; }
49 49
50 bool is_final() const { return is_final_; } 50 bool is_final() const { return is_final_; }
51 void set_is_final() { is_final_ = true; } 51 void set_is_final() { is_final_ = true; }
52 52
53 bool is_captured() const { return is_captured_; } 53 bool is_captured() const { return is_captured_; }
54 void set_is_captured() { is_captured_ = true; } 54 void set_is_captured() { is_captured_ = true; }
55 55
56 bool HasIndex() const { 56 bool HasIndex() const {
57 return index_ != kUnitializedIndex; 57 return index_ != kUninitializedIndex;
58 } 58 }
59 int index() const { 59 int index() const {
60 ASSERT(HasIndex()); 60 ASSERT(HasIndex());
61 return index_; 61 return index_;
62 } 62 }
63 63
64 // Assign an index to a local. 64 // Assign an index to a local.
65 void set_index(int index) { 65 void set_index(int index) {
66 ASSERT(!HasIndex()); 66 ASSERT(index != kUninitializedIndex);
67 ASSERT(index != kUnitializedIndex);
68 index_ = index; 67 index_ = index;
69 } 68 }
70 69
71 void set_invisible(bool value) { 70 void set_invisible(bool value) {
72 is_invisible_ = value; 71 is_invisible_ = value;
73 } 72 }
74 73
75 bool IsConst() const { 74 bool IsConst() const {
76 return const_value_ != NULL; 75 return const_value_ != NULL;
77 } 76 }
(...skipping 10 matching lines...) Expand all
88 87
89 bool Equals(const LocalVariable& other) const; 88 bool Equals(const LocalVariable& other) const;
90 89
91 // Map the frame index to a bit-vector index. Assumes the variable is 90 // Map the frame index to a bit-vector index. Assumes the variable is
92 // allocated to the frame. 91 // allocated to the frame.
93 // var_count is the total number of stack-allocated variables including 92 // var_count is the total number of stack-allocated variables including
94 // all parameters. 93 // all parameters.
95 int BitIndexIn(intptr_t var_count) const; 94 int BitIndexIn(intptr_t var_count) const;
96 95
97 private: 96 private:
98 static const int kUnitializedIndex = INT_MIN; 97 static const int kUninitializedIndex = INT_MIN;
99 98
100 const intptr_t token_pos_; 99 const intptr_t token_pos_;
101 const String& name_; 100 const String& name_;
102 LocalScope* owner_; // Local scope declaring this variable. 101 LocalScope* owner_; // Local scope declaring this variable.
103 102
104 const AbstractType& type_; // Declaration type of local variable. 103 const AbstractType& type_; // Declaration type of local variable.
105 104
106 const Instance* const_value_; // NULL or compile-time const value. 105 const Instance* const_value_; // NULL or compile-time const value.
107 106
108 bool is_final_; // If true, this variable is readonly. 107 bool is_final_; // If true, this variable is readonly.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 intptr_t end_token_pos_; // Token index of end of scope. 360 intptr_t end_token_pos_; // Token index of end of scope.
362 GrowableArray<LocalVariable*> variables_; 361 GrowableArray<LocalVariable*> variables_;
363 GrowableArray<SourceLabel*> labels_; 362 GrowableArray<SourceLabel*> labels_;
364 363
365 DISALLOW_COPY_AND_ASSIGN(LocalScope); 364 DISALLOW_COPY_AND_ASSIGN(LocalScope);
366 }; 365 };
367 366
368 } // namespace dart 367 } // namespace dart
369 368
370 #endif // VM_SCOPES_H_ 369 #endif // VM_SCOPES_H_
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698