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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 static RawTokenStream* New(intptr_t length); | 1914 static RawTokenStream* New(intptr_t length); |
1915 static RawTokenStream* New(const Scanner::GrowableTokenStream& tokens, | 1915 static RawTokenStream* New(const Scanner::GrowableTokenStream& tokens, |
1916 const String& private_key); | 1916 const String& private_key); |
1917 | 1917 |
1918 // The class Iterator encapsulates iteration over the tokens | 1918 // The class Iterator encapsulates iteration over the tokens |
1919 // in a TokenStream object. | 1919 // in a TokenStream object. |
1920 class Iterator : ValueObject { | 1920 class Iterator : ValueObject { |
1921 public: | 1921 public: |
1922 Iterator(const TokenStream& tokens, intptr_t token_pos); | 1922 Iterator(const TokenStream& tokens, intptr_t token_pos); |
1923 | 1923 |
| 1924 void SetStream(const TokenStream& tokens, intptr_t token_pos); |
1924 bool IsValid() const; | 1925 bool IsValid() const; |
1925 | 1926 |
1926 inline Token::Kind CurrentTokenKind() const { | 1927 inline Token::Kind CurrentTokenKind() const { |
1927 return cur_token_kind_; | 1928 return cur_token_kind_; |
1928 } | 1929 } |
1929 | 1930 |
1930 Token::Kind LookaheadTokenKind(intptr_t num_tokens); | 1931 Token::Kind LookaheadTokenKind(intptr_t num_tokens); |
1931 | 1932 |
1932 intptr_t CurrentPosition() const; | 1933 intptr_t CurrentPosition() const; |
1933 void SetCurrentPosition(intptr_t value); | 1934 void SetCurrentPosition(intptr_t value); |
1934 | 1935 |
1935 void Advance(); | 1936 void Advance(); |
1936 | 1937 |
1937 RawObject* CurrentToken() const; | 1938 RawObject* CurrentToken() const; |
1938 RawString* CurrentLiteral() const; | 1939 RawString* CurrentLiteral() const; |
1939 RawString* MakeLiteralToken(const Object& obj) const; | 1940 RawString* MakeLiteralToken(const Object& obj) const; |
1940 | 1941 |
1941 private: | 1942 private: |
1942 // Read token from the token stream (could be a simple token or an index | 1943 // Read token from the token stream (could be a simple token or an index |
1943 // into the token objects array for IDENT or literal tokens). | 1944 // into the token objects array for IDENT or literal tokens). |
1944 intptr_t ReadToken() { | 1945 intptr_t ReadToken() { |
1945 int64_t value = stream_.ReadUnsigned(); | 1946 int64_t value = stream_.ReadUnsigned(); |
1946 ASSERT((value >= 0) && (value <= kIntptrMax)); | 1947 ASSERT((value >= 0) && (value <= kIntptrMax)); |
1947 return static_cast<intptr_t>(value); | 1948 return static_cast<intptr_t>(value); |
1948 } | 1949 } |
1949 | 1950 |
1950 const TokenStream& tokens_; | 1951 TokenStream& tokens_; |
1951 const ExternalUint8Array& data_; | 1952 ExternalUint8Array& data_; |
1952 ReadStream stream_; | 1953 ReadStream stream_; |
1953 Array& token_objects_; | 1954 Array& token_objects_; |
1954 Object& obj_; | 1955 Object& obj_; |
1955 intptr_t cur_token_pos_; | 1956 intptr_t cur_token_pos_; |
1956 Token::Kind cur_token_kind_; | 1957 Token::Kind cur_token_kind_; |
1957 intptr_t cur_token_obj_index_; | 1958 intptr_t cur_token_obj_index_; |
1958 }; | 1959 }; |
1959 | 1960 |
1960 private: | 1961 private: |
1961 void SetPrivateKey(const String& value) const; | 1962 void SetPrivateKey(const String& value) const; |
(...skipping 4967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6929 | 6930 |
6930 | 6931 |
6931 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6932 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6932 intptr_t index) { | 6933 intptr_t index) { |
6933 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6934 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6934 } | 6935 } |
6935 | 6936 |
6936 } // namespace dart | 6937 } // namespace dart |
6937 | 6938 |
6938 #endif // VM_OBJECT_H_ | 6939 #endif // VM_OBJECT_H_ |
OLD | NEW |