Revision: 6150
Author: [email protected]
Date: Tue Jan 4 04:07:16 2011
Log: Fix compile-problem in (currently) unused stand-alone preparser
function.
Allow object initializers to define getters using string and number
literals.
Review URL: http://codereview.chromium.org/5985010
http://code.google.com/p/v8/source/detail?r=6150
Modified:
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/preparser-api.cc
/branches/bleeding_edge/src/preparser.cc
/branches/bleeding_edge/src/preparser.h
=======================================
--- /branches/bleeding_edge/src/parser.cc Wed Dec 22 12:14:19 2010
+++ /branches/bleeding_edge/src/parser.cc Tue Jan 4 04:07:16 2011
@@ -2995,14 +2995,22 @@
// { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... }
// We have already read the "get" or "set" keyword.
Token::Value next = Next();
- // TODO(820): Allow NUMBER and STRING as well (and handle array indices).
- if (next == Token::IDENTIFIER || Token::IsKeyword(next)) {
- Handle<String> name = GetSymbol(CHECK_OK);
+ bool is_keyword = Token::IsKeyword(next);
+ if (next == Token::IDENTIFIER || next == Token::NUMBER ||
+ next == Token::STRING || is_keyword) {
+ Handle<String> name;
+ if (is_keyword) {
+ name = Factory::LookupAsciiSymbol(Token::String(next));
+ } else {
+ name = GetSymbol(CHECK_OK);
+ }
FunctionLiteral* value =
ParseFunctionLiteral(name,
RelocInfo::kNoPosition,
DECLARATION,
CHECK_OK);
+ // Allow any number of parameters for compatiabilty with JSC.
+ // Specification only allows zero parameters for get and one for set.
ObjectLiteral::Property* property =
new ObjectLiteral::Property(is_getter, value);
return property;
=======================================
--- /branches/bleeding_edge/src/preparser-api.cc Wed Dec 8 02:06:40 2010
+++ /branches/bleeding_edge/src/preparser-api.cc Tue Jan 4 04:07:16 2011
@@ -155,7 +155,6 @@
public:
void Initialize(UC16CharacterStream* source) {
source_ = source;
- literal_flags_ = kLiteralString | kLiteralIdentifier;
Init();
// Skip initial whitespace allowing HTML comment ends just like
// after a newline and scan first token.
=======================================
--- /branches/bleeding_edge/src/preparser.cc Wed Dec 22 12:14:19 2010
+++ /branches/bleeding_edge/src/preparser.cc Tue Jan 4 04:07:16 2011
@@ -950,13 +950,17 @@
ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
if ((is_getter || is_setter) && peek() != i::Token::COLON) {
i::Token::Value name = Next();
+ bool is_keyword = i::Token::IsKeyword(name);
if (name != i::Token::IDENTIFIER &&
name != i::Token::NUMBER &&
name != i::Token::STRING &&
- !i::Token::IsKeyword(name)) {
+ !is_keyword) {
*ok = false;
return kUnknownExpression;
}
+ if (!is_keyword) {
+ LogSymbol();
+ }
ParseFunctionLiteral(CHECK_OK);
if (peek() != i::Token::RBRACE) {
Expect(i::Token::COMMA, CHECK_OK);
@@ -1120,24 +1124,24 @@
}
-PreParser::Identifier PreParser::GetIdentifierSymbol() {
+void PreParser::LogSymbol() {
int identifier_pos = scanner_->location().beg_pos;
if (scanner_->is_literal_ascii()) {
log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
} else {
log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string());
}
+}
+
+
+PreParser::Identifier PreParser::GetIdentifierSymbol() {
+ LogSymbol();
return kUnknownIdentifier;
}
PreParser::Expression PreParser::GetStringSymbol() {
- int identifier_pos = scanner_->location().beg_pos;
- if (scanner_->is_literal_ascii()) {
- log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
- } else {
- log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string());
- }
+ LogSymbol();
return kUnknownExpression;
}
=======================================
--- /branches/bleeding_edge/src/preparser.h Tue Dec 7 03:01:02 2010
+++ /branches/bleeding_edge/src/preparser.h Tue Jan 4 04:07:16 2011
@@ -216,8 +216,11 @@
Identifier ParseIdentifierName(bool* ok);
Identifier ParseIdentifierOrGetOrSet(bool* is_get, bool* is_set, bool*
ok);
+ // Logs the currently parsed literal as a symbol in the preparser data.
+ void LogSymbol();
+ // Log the currently parsed identifier.
Identifier GetIdentifierSymbol();
- unsigned int HexDigitValue(char digit);
+ // Log the currently parsed string literal.
Expression GetStringSymbol();
i::Token::Value peek() {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev