| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 | 251 |
| 252 Handle<String> Parser::LookupSymbol(int symbol_id) { | 252 Handle<String> Parser::LookupSymbol(int symbol_id) { |
| 253 // Length of symbol cache is the number of identified symbols. | 253 // Length of symbol cache is the number of identified symbols. |
| 254 // If we are larger than that, or negative, it's not a cached symbol. | 254 // If we are larger than that, or negative, it's not a cached symbol. |
| 255 // This might also happen if there is no preparser symbol data, even | 255 // This might also happen if there is no preparser symbol data, even |
| 256 // if there is some preparser data. | 256 // if there is some preparser data. |
| 257 if (static_cast<unsigned>(symbol_id) | 257 if (static_cast<unsigned>(symbol_id) |
| 258 >= static_cast<unsigned>(symbol_cache_.length())) { | 258 >= static_cast<unsigned>(symbol_cache_.length())) { |
| 259 if (scanner().is_literal_ascii()) { | 259 if (scanner().is_literal_ascii()) { |
| 260 return isolate()->factory()->LookupOneByteSymbol( | 260 Handle<String> symbol = isolate()->factory()->LookupOneByteSymbol( |
| 261 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); | 261 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); |
| 262 if (scanner().is_literal_printable_ascii() && |
| 263 symbol->map() == isolate()->heap()->ascii_symbol_map()) { |
| 264 symbol->set_map(isolate()->heap()->printable_ascii_symbol_map()); |
| 265 } |
| 266 return symbol; |
| 262 } else { | 267 } else { |
| 263 return isolate()->factory()->LookupTwoByteSymbol( | 268 return isolate()->factory()->LookupTwoByteSymbol( |
| 264 scanner().literal_utf16_string()); | 269 scanner().literal_utf16_string()); |
| 265 } | 270 } |
| 266 } | 271 } |
| 267 return LookupCachedSymbol(symbol_id); | 272 return LookupCachedSymbol(symbol_id); |
| 268 } | 273 } |
| 269 | 274 |
| 270 | 275 |
| 271 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { | 276 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { |
| (...skipping 3331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3603 PrintF("# Variable %s ", name->ToAsciiArray()); | 3608 PrintF("# Variable %s ", name->ToAsciiArray()); |
| 3604 #endif | 3609 #endif |
| 3605 Interface* interface = Interface::NewUnknown(zone()); | 3610 Interface* interface = Interface::NewUnknown(zone()); |
| 3606 result = top_scope_->NewUnresolved( | 3611 result = top_scope_->NewUnresolved( |
| 3607 factory(), name, interface, scanner().location().beg_pos); | 3612 factory(), name, interface, scanner().location().beg_pos); |
| 3608 break; | 3613 break; |
| 3609 } | 3614 } |
| 3610 | 3615 |
| 3611 case Token::NUMBER: { | 3616 case Token::NUMBER: { |
| 3612 Consume(Token::NUMBER); | 3617 Consume(Token::NUMBER); |
| 3613 ASSERT(scanner().is_literal_ascii()); | 3618 ASSERT(scanner().is_literal_printable_ascii()); |
| 3614 double value = StringToDouble(isolate()->unicode_cache(), | 3619 double value = StringToDouble(isolate()->unicode_cache(), |
| 3615 scanner().literal_ascii_string(), | 3620 scanner().literal_ascii_string(), |
| 3616 ALLOW_HEX | ALLOW_OCTALS); | 3621 ALLOW_HEX | ALLOW_OCTALS); |
| 3617 result = factory()->NewNumberLiteral(value); | 3622 result = factory()->NewNumberLiteral(value); |
| 3618 break; | 3623 break; |
| 3619 } | 3624 } |
| 3620 | 3625 |
| 3621 case Token::STRING: { | 3626 case Token::STRING: { |
| 3622 Consume(Token::STRING); | 3627 Consume(Token::STRING); |
| 3623 Handle<String> symbol = GetSymbol(CHECK_OK); | 3628 Handle<String> symbol = GetSymbol(CHECK_OK); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4079 uint32_t index; | 4084 uint32_t index; |
| 4080 if (!string.is_null() && string->AsArrayIndex(&index)) { | 4085 if (!string.is_null() && string->AsArrayIndex(&index)) { |
| 4081 key = factory()->NewNumberLiteral(index); | 4086 key = factory()->NewNumberLiteral(index); |
| 4082 break; | 4087 break; |
| 4083 } | 4088 } |
| 4084 key = factory()->NewLiteral(string); | 4089 key = factory()->NewLiteral(string); |
| 4085 break; | 4090 break; |
| 4086 } | 4091 } |
| 4087 case Token::NUMBER: { | 4092 case Token::NUMBER: { |
| 4088 Consume(Token::NUMBER); | 4093 Consume(Token::NUMBER); |
| 4089 ASSERT(scanner().is_literal_ascii()); | 4094 ASSERT(scanner().is_literal_printable_ascii()); |
| 4090 double value = StringToDouble(isolate()->unicode_cache(), | 4095 double value = StringToDouble(isolate()->unicode_cache(), |
| 4091 scanner().literal_ascii_string(), | 4096 scanner().literal_ascii_string(), |
| 4092 ALLOW_HEX | ALLOW_OCTALS); | 4097 ALLOW_HEX | ALLOW_OCTALS); |
| 4093 key = factory()->NewNumberLiteral(value); | 4098 key = factory()->NewNumberLiteral(value); |
| 4094 break; | 4099 break; |
| 4095 } | 4100 } |
| 4096 default: | 4101 default: |
| 4097 if (Token::IsKeyword(next)) { | 4102 if (Token::IsKeyword(next)) { |
| 4098 Consume(next); | 4103 Consume(next); |
| 4099 Handle<String> string = GetSymbol(CHECK_OK); | 4104 Handle<String> string = GetSymbol(CHECK_OK); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4832 } | 4837 } |
| 4833 | 4838 |
| 4834 | 4839 |
| 4835 // This function reads an identifier name and determines whether or not it | 4840 // This function reads an identifier name and determines whether or not it |
| 4836 // is 'get' or 'set'. | 4841 // is 'get' or 'set'. |
| 4837 Handle<String> Parser::ParseIdentifierNameOrGetOrSet(bool* is_get, | 4842 Handle<String> Parser::ParseIdentifierNameOrGetOrSet(bool* is_get, |
| 4838 bool* is_set, | 4843 bool* is_set, |
| 4839 bool* ok) { | 4844 bool* ok) { |
| 4840 Handle<String> result = ParseIdentifierName(ok); | 4845 Handle<String> result = ParseIdentifierName(ok); |
| 4841 if (!*ok) return Handle<String>(); | 4846 if (!*ok) return Handle<String>(); |
| 4842 if (scanner().is_literal_ascii() && scanner().literal_length() == 3) { | 4847 if (scanner().is_literal_printable_ascii() && |
| 4848 scanner().literal_length() == 3) { |
| 4843 const char* token = scanner().literal_ascii_string().start(); | 4849 const char* token = scanner().literal_ascii_string().start(); |
| 4844 *is_get = strncmp(token, "get", 3) == 0; | 4850 *is_get = strncmp(token, "get", 3) == 0; |
| 4845 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 4851 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
| 4846 } | 4852 } |
| 4847 return result; | 4853 return result; |
| 4848 } | 4854 } |
| 4849 | 4855 |
| 4850 | 4856 |
| 4851 // ---------------------------------------------------------------------------- | 4857 // ---------------------------------------------------------------------------- |
| 4852 // Parser support | 4858 // Parser support |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5932 ASSERT(info->isolate()->has_pending_exception()); | 5938 ASSERT(info->isolate()->has_pending_exception()); |
| 5933 } else { | 5939 } else { |
| 5934 result = parser.ParseProgram(); | 5940 result = parser.ParseProgram(); |
| 5935 } | 5941 } |
| 5936 } | 5942 } |
| 5937 info->SetFunction(result); | 5943 info->SetFunction(result); |
| 5938 return (result != NULL); | 5944 return (result != NULL); |
| 5939 } | 5945 } |
| 5940 | 5946 |
| 5941 } } // namespace v8::internal | 5947 } } // namespace v8::internal |
| OLD | NEW |