OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 Scanner::Location MessageLocation() const; | 107 Scanner::Location MessageLocation() const; |
108 bool IsReferenceError() const; | 108 bool IsReferenceError() const; |
109 const char* BuildMessage() const; | 109 const char* BuildMessage() const; |
110 Vector<const char*> BuildArgs() const; | 110 Vector<const char*> BuildArgs() const; |
111 | 111 |
112 int symbol_count() { | 112 int symbol_count() { |
113 return (store_.length() > PreparseDataConstants::kHeaderSize) | 113 return (store_.length() > PreparseDataConstants::kHeaderSize) |
114 ? store_[PreparseDataConstants::kSymbolCountOffset] | 114 ? store_[PreparseDataConstants::kSymbolCountOffset] |
115 : 0; | 115 : 0; |
116 } | 116 } |
117 int function_count() { | |
118 int functions_size = | |
119 static_cast<int>(store_[PreparseDataConstants::kFunctionsSizeOffset]); | |
120 if (functions_size < 0) return 0; | |
ulan
2014/04/04 12:10:59
Shouldn't these checks be ASSERTs instead?
What do
marja
2014/04/04 12:13:18
It's just invalid data then. The length field is t
| |
121 if (functions_size % FunctionEntry::kSize != 0) return 0; | |
122 return functions_size / FunctionEntry::kSize; | |
123 } | |
117 // The following functions should only be called if SanityCheck has | 124 // The following functions should only be called if SanityCheck has |
118 // returned true. | 125 // returned true. |
119 bool has_error() { return store_[PreparseDataConstants::kHasErrorOffset]; } | 126 bool has_error() { return store_[PreparseDataConstants::kHasErrorOffset]; } |
120 unsigned magic() { return store_[PreparseDataConstants::kMagicOffset]; } | 127 unsigned magic() { return store_[PreparseDataConstants::kMagicOffset]; } |
121 unsigned version() { return store_[PreparseDataConstants::kVersionOffset]; } | 128 unsigned version() { return store_[PreparseDataConstants::kVersionOffset]; } |
122 | 129 |
123 private: | 130 private: |
124 friend class v8::ScriptCompiler; | 131 friend class v8::ScriptCompiler; |
125 Vector<unsigned> store_; | 132 Vector<unsigned> store_; |
126 unsigned char* symbol_data_; | 133 unsigned char* symbol_data_; |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 private: | 845 private: |
839 static const int kLiteralTypeSlot = 0; | 846 static const int kLiteralTypeSlot = 0; |
840 static const int kElementsSlot = 1; | 847 static const int kElementsSlot = 1; |
841 | 848 |
842 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 849 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
843 }; | 850 }; |
844 | 851 |
845 } } // namespace v8::internal | 852 } } // namespace v8::internal |
846 | 853 |
847 #endif // V8_PARSER_H_ | 854 #endif // V8_PARSER_H_ |
OLD | NEW |