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 #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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 int first_parameter_index_; | 99 int first_parameter_index_; |
100 int first_stack_local_index_; | 100 int first_stack_local_index_; |
101 int copied_parameter_count_; | 101 int copied_parameter_count_; |
102 int stack_local_count_; | 102 int stack_local_count_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 104 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
105 }; | 105 }; |
106 | 106 |
107 | 107 |
108 // The class TokenStreamIterator encapsulates iteration over the TokenStream | |
109 // object. The parser uses this to iterate over tokens while parsing a script | |
110 // or a function. | |
111 class TokenStreamIterator : ValueObject { | |
112 public: | |
113 TokenStreamIterator(const TokenStream& tokens, intptr_t token_pos) | |
114 : tokens_(tokens), token_position_(token_pos) { } | |
115 | |
116 intptr_t NumberOfTokens() const { return tokens_.Length(); } | |
117 bool IsValid() const; | |
118 | |
119 inline Token::Kind CurrentTokenKind() const; | |
120 Token::Kind LookaheadTokenKind(intptr_t num_tokens) const; | |
121 | |
122 intptr_t CurrentPosition() const { return token_position_; } | |
123 void SetCurrentPosition(intptr_t value) { token_position_ = value; } | |
124 | |
125 void Advance() { token_position_ += 1; } | |
126 | |
127 RawObject* CurrentToken() const; | |
128 RawString* CurrentLiteral() const; | |
129 | |
130 private: | |
131 const TokenStream& tokens_; | |
132 intptr_t token_position_; | |
133 }; | |
134 | |
135 | |
136 class Parser : ValueObject { | 108 class Parser : ValueObject { |
137 public: | 109 public: |
138 Parser(const Script& script, const Library& library); | 110 Parser(const Script& script, const Library& library); |
139 Parser(const Script& script, const Function& function, intptr_t token_pos); | 111 Parser(const Script& script, const Function& function, intptr_t token_pos); |
140 | 112 |
141 // Parse the top level of a whole script file and register declared classes | 113 // Parse the top level of a whole script file and register declared classes |
142 // and interfaces in the given library. | 114 // and interfaces in the given library. |
143 static void ParseCompilationUnit(const Library& library, | 115 static void ParseCompilationUnit(const Library& library, |
144 const Script& script); | 116 const Script& script); |
145 | 117 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 541 |
570 // Allocate temporary only once per function. | 542 // Allocate temporary only once per function. |
571 LocalVariable* expression_temp_; | 543 LocalVariable* expression_temp_; |
572 | 544 |
573 DISALLOW_COPY_AND_ASSIGN(Parser); | 545 DISALLOW_COPY_AND_ASSIGN(Parser); |
574 }; | 546 }; |
575 | 547 |
576 } // namespace dart | 548 } // namespace dart |
577 | 549 |
578 #endif // VM_PARSER_H_ | 550 #endif // VM_PARSER_H_ |
OLD | NEW |