| 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 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 void set_literal(const String& literal) const; | 3123 void set_literal(const String& literal) const; |
| 3124 void set_value(const Object& value) const; | 3124 void set_value(const Object& value) const; |
| 3125 | 3125 |
| 3126 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object); | 3126 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object); |
| 3127 friend class Class; | 3127 friend class Class; |
| 3128 }; | 3128 }; |
| 3129 | 3129 |
| 3130 | 3130 |
| 3131 class TokenStream : public Object { | 3131 class TokenStream : public Object { |
| 3132 public: | 3132 public: |
| 3133 RawArray* TokenObjects() const; | 3133 RawGrowableObjectArray* TokenObjects() const; |
| 3134 void SetTokenObjects(const Array& value) const; | 3134 void SetTokenObjects(const GrowableObjectArray& value) const; |
| 3135 | 3135 |
| 3136 RawExternalTypedData* GetStream() const; | 3136 RawExternalTypedData* GetStream() const; |
| 3137 void SetStream(const ExternalTypedData& stream) const; | 3137 void SetStream(const ExternalTypedData& stream) const; |
| 3138 | 3138 |
| 3139 RawString* GenerateSource() const; | 3139 RawString* GenerateSource() const; |
| 3140 RawString* GenerateSource(intptr_t start, intptr_t end) const; | 3140 RawString* GenerateSource(intptr_t start, intptr_t end) const; |
| 3141 intptr_t ComputeSourcePosition(intptr_t tok_pos) const; | 3141 intptr_t ComputeSourcePosition(intptr_t tok_pos) const; |
| 3142 | 3142 |
| 3143 RawString* PrivateKey() const; | 3143 RawString* PrivateKey() const; |
| 3144 | 3144 |
| 3145 static const intptr_t kBytesPerElement = 1; | 3145 static const intptr_t kBytesPerElement = 1; |
| 3146 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3146 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 3147 | 3147 |
| 3148 static intptr_t InstanceSize() { | 3148 static intptr_t InstanceSize() { |
| 3149 return RoundedAllocationSize(sizeof(RawTokenStream)); | 3149 return RoundedAllocationSize(sizeof(RawTokenStream)); |
| 3150 } | 3150 } |
| 3151 | 3151 |
| 3152 static RawTokenStream* New(intptr_t length); | 3152 static RawTokenStream* New(intptr_t length); |
| 3153 static RawTokenStream* New(const Scanner::GrowableTokenStream& tokens, | 3153 static RawTokenStream* New(const Scanner::GrowableTokenStream& tokens, |
| 3154 const String& private_key); | 3154 const String& private_key, |
| 3155 bool use_shared_tokens); |
| 3156 |
| 3157 static void OpenSharedTokenList(Isolate* isolate); |
| 3158 static void CloseSharedTokenList(Isolate* isolate); |
| 3155 | 3159 |
| 3156 // The class Iterator encapsulates iteration over the tokens | 3160 // The class Iterator encapsulates iteration over the tokens |
| 3157 // in a TokenStream object. | 3161 // in a TokenStream object. |
| 3158 class Iterator : ValueObject { | 3162 class Iterator : ValueObject { |
| 3159 public: | 3163 public: |
| 3160 enum StreamType { | 3164 enum StreamType { |
| 3161 kNoNewlines, | 3165 kNoNewlines, |
| 3162 kAllTokens | 3166 kAllTokens |
| 3163 }; | 3167 }; |
| 3164 | 3168 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3189 // into the token objects array for IDENT or literal tokens). | 3193 // into the token objects array for IDENT or literal tokens). |
| 3190 intptr_t ReadToken() { | 3194 intptr_t ReadToken() { |
| 3191 int64_t value = stream_.ReadUnsigned(); | 3195 int64_t value = stream_.ReadUnsigned(); |
| 3192 ASSERT((value >= 0) && (value <= kIntptrMax)); | 3196 ASSERT((value >= 0) && (value <= kIntptrMax)); |
| 3193 return static_cast<intptr_t>(value); | 3197 return static_cast<intptr_t>(value); |
| 3194 } | 3198 } |
| 3195 | 3199 |
| 3196 TokenStream& tokens_; | 3200 TokenStream& tokens_; |
| 3197 ExternalTypedData& data_; | 3201 ExternalTypedData& data_; |
| 3198 ReadStream stream_; | 3202 ReadStream stream_; |
| 3199 Array& token_objects_; | 3203 GrowableObjectArray& token_objects_; |
| 3200 Object& obj_; | 3204 Object& obj_; |
| 3201 intptr_t cur_token_pos_; | 3205 intptr_t cur_token_pos_; |
| 3202 Token::Kind cur_token_kind_; | 3206 Token::Kind cur_token_kind_; |
| 3203 intptr_t cur_token_obj_index_; | 3207 intptr_t cur_token_obj_index_; |
| 3204 Iterator::StreamType stream_type_; | 3208 Iterator::StreamType stream_type_; |
| 3205 }; | 3209 }; |
| 3206 | 3210 |
| 3207 private: | 3211 private: |
| 3208 void SetPrivateKey(const String& value) const; | 3212 void SetPrivateKey(const String& value) const; |
| 3209 | 3213 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3226 RawGrowableObjectArray* GenerateLineNumberArray() const; | 3230 RawGrowableObjectArray* GenerateLineNumberArray() const; |
| 3227 RawScript::Kind kind() const { | 3231 RawScript::Kind kind() const { |
| 3228 return static_cast<RawScript::Kind>(raw_ptr()->kind_); | 3232 return static_cast<RawScript::Kind>(raw_ptr()->kind_); |
| 3229 } | 3233 } |
| 3230 const char* GetKindAsCString() const; | 3234 const char* GetKindAsCString() const; |
| 3231 intptr_t line_offset() const { return raw_ptr()->line_offset_; } | 3235 intptr_t line_offset() const { return raw_ptr()->line_offset_; } |
| 3232 intptr_t col_offset() const { return raw_ptr()->col_offset_; } | 3236 intptr_t col_offset() const { return raw_ptr()->col_offset_; } |
| 3233 | 3237 |
| 3234 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } | 3238 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } |
| 3235 | 3239 |
| 3236 void Tokenize(const String& private_key) const; | 3240 void Tokenize(const String& private_key, |
| 3241 bool use_shared_tokens = true) const; |
| 3237 | 3242 |
| 3238 RawLibrary* FindLibrary() const; | 3243 RawLibrary* FindLibrary() const; |
| 3239 RawString* GetLine(intptr_t line_number, | 3244 RawString* GetLine(intptr_t line_number, |
| 3240 Heap::Space space = Heap::kNew) const; | 3245 Heap::Space space = Heap::kNew) const; |
| 3241 RawString* GetSnippet(intptr_t from_line, | 3246 RawString* GetSnippet(intptr_t from_line, |
| 3242 intptr_t from_column, | 3247 intptr_t from_column, |
| 3243 intptr_t to_line, | 3248 intptr_t to_line, |
| 3244 intptr_t to_column) const; | 3249 intptr_t to_column) const; |
| 3245 | 3250 |
| 3246 void SetLocationOffset(intptr_t line_offset, intptr_t col_offset) const; | 3251 void SetLocationOffset(intptr_t line_offset, intptr_t col_offset) const; |
| (...skipping 4958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8205 | 8210 |
| 8206 | 8211 |
| 8207 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8212 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8208 intptr_t index) { | 8213 intptr_t index) { |
| 8209 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8214 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8210 } | 8215 } |
| 8211 | 8216 |
| 8212 } // namespace dart | 8217 } // namespace dart |
| 8213 | 8218 |
| 8214 #endif // VM_OBJECT_H_ | 8219 #endif // VM_OBJECT_H_ |
| OLD | NEW |