| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #else // defined(__GNUC__) && (__GNUC__ >= 4) | 60 #else // defined(__GNUC__) && (__GNUC__ >= 4) |
| 61 #define V8EXPORT | 61 #define V8EXPORT |
| 62 #endif // defined(__GNUC__) && (__GNUC__ >= 4) | 62 #endif // defined(__GNUC__) && (__GNUC__ >= 4) |
| 63 | 63 |
| 64 #endif // _WIN32 | 64 #endif // _WIN32 |
| 65 | 65 |
| 66 | 66 |
| 67 namespace v8 { | 67 namespace v8 { |
| 68 | 68 |
| 69 | 69 |
| 70 class PreParserData { | 70 class V8EXPORT PreParserData { |
| 71 public: | 71 public: |
| 72 PreParserData(size_t size, const uint8_t* data) | 72 PreParserData(size_t size, const uint8_t* data) |
| 73 : data_(data), size_(size) { } | 73 : data_(data), size_(size) { } |
| 74 | 74 |
| 75 // Create a PreParserData value where stack_overflow reports true. | 75 // Create a PreParserData value where stack_overflow reports true. |
| 76 static PreParserData StackOverflow() { return PreParserData(0, NULL); } | 76 static PreParserData StackOverflow() { return PreParserData(0, NULL); } |
| 77 |
| 77 // Whether the pre-parser stopped due to a stack overflow. | 78 // Whether the pre-parser stopped due to a stack overflow. |
| 78 // If this is the case, size() and data() should not be used. | 79 // If this is the case, size() and data() should not be used. |
| 79 | |
| 80 bool stack_overflow() { return size_ == 0u; } | 80 bool stack_overflow() { return size_ == 0u; } |
| 81 | 81 |
| 82 // The size of the data in bytes. | 82 // The size of the data in bytes. |
| 83 size_t size() const { return size_; } | 83 size_t size() const { return size_; } |
| 84 | 84 |
| 85 // Pointer to the data. | 85 // Pointer to the data. |
| 86 const uint8_t* data() const { return data_; } | 86 const uint8_t* data() const { return data_; } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 const uint8_t* const data_; | 89 const uint8_t* const data_; |
| 90 const size_t size_; | 90 const size_t size_; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 | 93 |
| 94 // Interface for a stream of Unicode characters. | 94 // Interface for a stream of Unicode characters. |
| 95 class UnicodeInputStream { | 95 class V8EXPORT UnicodeInputStream { // NOLINT - Thinks V8EXPORT is class name. |
| 96 public: | 96 public: |
| 97 virtual ~UnicodeInputStream(); | 97 virtual ~UnicodeInputStream(); |
| 98 | 98 |
| 99 // Returns the next Unicode code-point in the input, or a negative value when | 99 // Returns the next Unicode code-point in the input, or a negative value when |
| 100 // there is no more input in the stream. | 100 // there is no more input in the stream. |
| 101 virtual int32_t Next() = 0; | 101 virtual int32_t Next() = 0; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 | 104 |
| 105 // Preparse a JavaScript program. The source code is provided as a | 105 // Preparse a JavaScript program. The source code is provided as a |
| 106 // UnicodeInputStream. The max_stack_size limits the amount of stack | 106 // UnicodeInputStream. The max_stack_size limits the amount of stack |
| 107 // space that the preparser is allowed to use. If the preparser uses | 107 // space that the preparser is allowed to use. If the preparser uses |
| 108 // more stack space than the limit provided, the result's stack_overflow() | 108 // more stack space than the limit provided, the result's stack_overflow() |
| 109 // method will return true. Otherwise the result contains preparser | 109 // method will return true. Otherwise the result contains preparser |
| 110 // data that can be used by the V8 parser to speed up parsing. | 110 // data that can be used by the V8 parser to speed up parsing. |
| 111 PreParserData V8EXPORT Preparse(UnicodeInputStream* input, | 111 PreParserData V8EXPORT Preparse(UnicodeInputStream* input, |
| 112 size_t max_stack_size); | 112 size_t max_stack_size); |
| 113 | 113 |
| 114 } // namespace v8. | 114 } // namespace v8. |
| 115 | 115 |
| 116 #endif // PREPARSER_H | 116 #endif // PREPARSER_H |
| OLD | NEW |