| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 template<typename Char> | 168 template<typename Char> |
| 169 Lexer<Char>::Lexer(UnicodeCache* unicode_cache, | 169 Lexer<Char>::Lexer(UnicodeCache* unicode_cache, |
| 170 Handle<String> source, | 170 Handle<String> source, |
| 171 int start_position, | 171 int start_position, |
| 172 int end_position) | 172 int end_position) |
| 173 : LexerBase(unicode_cache), | 173 : LexerBase(unicode_cache), |
| 174 isolate_(source->GetIsolate()), | 174 isolate_(source->GetIsolate()), |
| 175 // TODO(dcarney): don't need to allocate here, used stored positions | 175 source_handle_(FlattenGetString(source)), |
| 176 source_handle_(isolate_->factory()->NewSubString( | |
| 177 source, start_position, end_position)), | |
| 178 source_ptr_(NULL), | 176 source_ptr_(NULL), |
| 179 start_position_(start_position), | 177 start_position_(start_position), |
| 180 end_position_(end_position), | 178 end_position_(end_position), |
| 181 buffer_(NULL), | 179 buffer_(NULL), |
| 182 buffer_end_(NULL), | 180 buffer_end_(NULL), |
| 183 start_(NULL), | 181 start_(NULL), |
| 184 cursor_(NULL), | 182 cursor_(NULL), |
| 185 last_octal_end_(NULL) { | 183 last_octal_end_(NULL) { |
| 186 ASSERT(source->IsFlat()); | |
| 187 fprintf(stderr, "%s %d %d %d %d %d\n", | |
| 188 __func__, start_position_, end_position_, | |
| 189 source->length(), source_handle_->length(), | |
| 190 source->IsOneByteRepresentation()); | |
| 191 UpdateBufferBasedOnHandle(); | 184 UpdateBufferBasedOnHandle(); |
| 192 current_.beg_pos = current_.end_pos = next_.beg_pos = next_.end_pos = 0; | 185 current_.beg_pos = current_.end_pos = next_.beg_pos = next_.end_pos = 0; |
| 193 isolate_->lexer_gc_handler()->AddLexer(this); | 186 isolate_->lexer_gc_handler()->AddLexer(this); |
| 187 // TODO(dcarney): move this to UpdateBufferBasedOnHandle |
| 188 cursor_ = buffer_ + start_position; |
| 189 buffer_end_ = buffer_ + end_position; |
| 190 start_ = cursor_; |
| 191 has_line_terminator_before_next_ = false; |
| 192 has_multiline_comment_before_next_ = false; |
| 194 } | 193 } |
| 195 | 194 |
| 196 | 195 |
| 197 template<typename Char> | 196 template<typename Char> |
| 198 Lexer<Char>::~Lexer() { | 197 Lexer<Char>::~Lexer() { |
| 199 if (!source_handle_.is_null()) { | 198 if (!source_handle_.is_null()) { |
| 200 isolate_->lexer_gc_handler()->RemoveLexer(this); | 199 isolate_->lexer_gc_handler()->RemoveLexer(this); |
| 201 } | 200 } |
| 202 } | 201 } |
| 203 | 202 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // FIXME: implement | 668 // FIXME: implement |
| 670 UNREACHABLE(); | 669 UNREACHABLE(); |
| 671 return Handle<String>(); | 670 return Handle<String>(); |
| 672 } | 671 } |
| 673 | 672 |
| 674 template class Lexer<uint8_t>; | 673 template class Lexer<uint8_t>; |
| 675 template class Lexer<uint16_t>; | 674 template class Lexer<uint16_t>; |
| 676 template class Lexer<int8_t>; | 675 template class Lexer<int8_t>; |
| 677 | 676 |
| 678 } } // v8::internal | 677 } } // v8::internal |
| OLD | NEW |