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

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

Issue 12225141: Minor cleanup (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')
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_PARSER_H_ 5 #ifndef VM_PARSER_H_
6 #define VM_PARSER_H_ 6 #define VM_PARSER_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/ast.h" 10 #include "vm/ast.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 default_parameter_values_ = default_parameter_values.raw(); 66 default_parameter_values_ = default_parameter_values.raw();
67 } 67 }
68 68
69 LocalVariable* saved_current_context_var() const { 69 LocalVariable* saved_current_context_var() const {
70 return saved_current_context_var_; 70 return saved_current_context_var_;
71 } 71 }
72 void set_saved_current_context_var(LocalVariable* saved_current_context_var) { 72 void set_saved_current_context_var(LocalVariable* saved_current_context_var) {
73 ASSERT(saved_current_context_var != NULL); 73 ASSERT(saved_current_context_var != NULL);
74 saved_current_context_var_ = saved_current_context_var; 74 saved_current_context_var_ = saved_current_context_var;
75 } 75 }
76 bool has_saved_current_context_var() const {
77 return saved_current_context_var_ != NULL;
78 }
76 79
77 LocalVariable* saved_entry_context_var() const { 80 LocalVariable* saved_entry_context_var() const {
78 return saved_entry_context_var_; 81 return saved_entry_context_var_;
79 } 82 }
80 void set_saved_entry_context_var(LocalVariable* saved_entry_context_var) { 83 void set_saved_entry_context_var(LocalVariable* saved_entry_context_var) {
81 ASSERT(saved_entry_context_var != NULL); 84 ASSERT(saved_entry_context_var != NULL);
82 saved_entry_context_var_ = saved_entry_context_var; 85 saved_entry_context_var_ = saved_entry_context_var;
83 } 86 }
84 87
85 // Returns NULL if this function does not save the arguments descriptor on 88 // Returns NULL if this function does not save the arguments descriptor on
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 int num_copied_params_; 123 int num_copied_params_;
121 int num_stack_locals_; 124 int num_stack_locals_;
122 125
123 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); 126 DISALLOW_COPY_AND_ASSIGN(ParsedFunction);
124 }; 127 };
125 128
126 129
127 class Parser : public ValueObject { 130 class Parser : public ValueObject {
128 public: 131 public:
129 Parser(const Script& script, const Library& library); 132 Parser(const Script& script, const Library& library);
130 Parser(const Script& script, const Function& function, intptr_t token_pos); 133 Parser(const Script& script, ParsedFunction* function, intptr_t token_pos);
131 134
132 // Parse the top level of a whole script file and register declared classes 135 // Parse the top level of a whole script file and register declared classes
133 // in the given library. 136 // in the given library.
134 static void ParseCompilationUnit(const Library& library, 137 static void ParseCompilationUnit(const Library& library,
135 const Script& script); 138 const Script& script);
136 139
137 static void ParseFunction(ParsedFunction* parsed_function); 140 static void ParseFunction(ParsedFunction* parsed_function);
138 141
139 // Format and print a message with source location. 142 // Format and print a message with source location.
140 // A null script means no source and a negative token_pos means no position. 143 // A null script means no source and a negative token_pos means no position.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // function. 195 // function.
193 // The function level of the current parsing scope reflects the function 196 // The function level of the current parsing scope reflects the function
194 // nesting. The function level is zero while parsing the body of the 197 // nesting. The function level is zero while parsing the body of the
195 // current_function(), but is greater than zero while parsing the body of 198 // current_function(), but is greater than zero while parsing the body of
196 // local functions nested in current_function(). 199 // local functions nested in current_function().
197 200
198 // The class being parsed. 201 // The class being parsed.
199 const Class& current_class() const; 202 const Class& current_class() const;
200 void set_current_class(const Class& value); 203 void set_current_class(const Class& value);
201 204
205 // ParsedFunction accessor.
206 ParsedFunction* parsed_function() const {
207 return parsed_function_;
208 }
209
202 // Parsing a library or a regular source script. 210 // Parsing a library or a regular source script.
203 bool is_library_source() const { 211 bool is_library_source() const {
204 return (script_.kind() == RawScript::kScriptTag) || 212 return (script_.kind() == RawScript::kScriptTag) ||
205 (script_.kind() == RawScript::kLibraryTag); 213 (script_.kind() == RawScript::kLibraryTag);
206 } 214 }
207 215
208 bool is_part_source() const { 216 bool is_part_source() const {
209 return script_.kind() == RawScript::kSourceTag; 217 return script_.kind() == RawScript::kSourceTag;
210 } 218 }
211 219
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 625
618 // The member currently being parsed during "top level" parsing. 626 // The member currently being parsed during "top level" parsing.
619 MemberDesc* current_member_; 627 MemberDesc* current_member_;
620 628
621 // Parser mode to allow/disallow function literals. This is used in 629 // Parser mode to allow/disallow function literals. This is used in
622 // constructor initializer expressions to handle ambiguous grammar. 630 // constructor initializer expressions to handle ambiguous grammar.
623 bool SetAllowFunctionLiterals(bool value); 631 bool SetAllowFunctionLiterals(bool value);
624 bool allow_function_literals_; 632 bool allow_function_literals_;
625 633
626 // The function currently being compiled. 634 // The function currently being compiled.
627 const Function& current_function_; 635 ParsedFunction* parsed_function_;
628 636
629 // The function currently being parsed. 637 // The function currently being parsed.
630 Function& innermost_function_; 638 Function& innermost_function_;
631 639
632 // The class currently being parsed, or the owner class of the 640 // The class currently being parsed, or the owner class of the
633 // function currently being parsed. It is used for primary identifier lookups. 641 // function currently being parsed. It is used for primary identifier lookups.
634 Class& current_class_; 642 Class& current_class_;
635 643
636 // The current library (and thus class dictionary) used to resolve names. 644 // The current library (and thus class dictionary) used to resolve names.
637 const Library& library_; 645 const Library& library_;
638 646
639 // List of try blocks seen so far, this is used to generate inlined finally 647 // List of try blocks seen so far, this is used to generate inlined finally
640 // code at all points in the try block where an exit from the block is 648 // code at all points in the try block where an exit from the block is
641 // done using 'return', 'break' or 'continue' statements. 649 // done using 'return', 'break' or 'continue' statements.
642 TryBlocks* try_blocks_list_; 650 TryBlocks* try_blocks_list_;
643 651
644 // Allocate temporary only once per function.
645 LocalVariable* expression_temp_;
646
647 // Allocate saved current context only if needed.
648 LocalVariable* saved_current_context_;
649
650 DISALLOW_COPY_AND_ASSIGN(Parser); 652 DISALLOW_COPY_AND_ASSIGN(Parser);
651 }; 653 };
652 654
653 } // namespace dart 655 } // namespace dart
654 656
655 #endif // VM_PARSER_H_ 657 #endif // VM_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698