Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: src/parser.cc

Issue 6334106: Improve ScanJsonNumber. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/conversions.cc ('k') | src/scanner.h » ('j') | src/scanner.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3923 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 } else { 3934 } else {
3935 return Factory::NewStringFromTwoByte(scanner_.literal_uc16_string()); 3935 return Factory::NewStringFromTwoByte(scanner_.literal_uc16_string());
3936 } 3936 }
3937 } 3937 }
3938 3938
3939 3939
3940 // Parse any JSON value. 3940 // Parse any JSON value.
3941 Handle<Object> JsonParser::ParseJsonValue() { 3941 Handle<Object> JsonParser::ParseJsonValue() {
3942 Token::Value token = scanner_.Next(); 3942 Token::Value token = scanner_.Next();
3943 switch (token) { 3943 switch (token) {
3944 case Token::STRING: { 3944 case Token::STRING:
3945 return GetString(); 3945 return GetString();
3946 } 3946 case Token::NUMBER:
3947 case Token::NUMBER: { 3947 return Factory::NewNumber(scanner_.number());
3948 ASSERT(scanner_.is_literal_ascii());
3949 double value = StringToDouble(scanner_.literal_ascii_string(),
3950 NO_FLAGS, // Hex, octal or trailing junk.
3951 OS::nan_value());
3952 return Factory::NewNumber(value);
3953 }
3954 case Token::FALSE_LITERAL: 3948 case Token::FALSE_LITERAL:
3955 return Factory::false_value(); 3949 return Factory::false_value();
3956 case Token::TRUE_LITERAL: 3950 case Token::TRUE_LITERAL:
3957 return Factory::true_value(); 3951 return Factory::true_value();
3958 case Token::NULL_LITERAL: 3952 case Token::NULL_LITERAL:
3959 return Factory::null_value(); 3953 return Factory::null_value();
3960 case Token::LBRACE: 3954 case Token::LBRACE:
3961 return ParseJsonObject(); 3955 return ParseJsonObject();
3962 case Token::LBRACK: 3956 case Token::LBRACK:
3963 return ParseJsonArray(); 3957 return ParseJsonArray();
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 Handle<String> source = Handle<String>(String::cast(script->source())); 5020 Handle<String> source = Handle<String>(String::cast(script->source()));
5027 result = parser.ParseProgram(source, info->is_global()); 5021 result = parser.ParseProgram(source, info->is_global());
5028 } 5022 }
5029 } 5023 }
5030 5024
5031 info->SetFunction(result); 5025 info->SetFunction(result);
5032 return (result != NULL); 5026 return (result != NULL);
5033 } 5027 }
5034 5028
5035 } } // namespace v8::internal 5029 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/conversions.cc ('k') | src/scanner.h » ('j') | src/scanner.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698