OLD | NEW |
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 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 *depth = depth_acc; | 2988 *depth = depth_acc; |
2989 } | 2989 } |
2990 | 2990 |
2991 | 2991 |
2992 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter, | 2992 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter, |
2993 bool* ok) { | 2993 bool* ok) { |
2994 // Special handling of getter and setter syntax: | 2994 // Special handling of getter and setter syntax: |
2995 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } | 2995 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } |
2996 // We have already read the "get" or "set" keyword. | 2996 // We have already read the "get" or "set" keyword. |
2997 Token::Value next = Next(); | 2997 Token::Value next = Next(); |
2998 // TODO(820): Allow NUMBER and STRING as well (and handle array indices). | 2998 bool is_keyword = Token::IsKeyword(next); |
2999 if (next == Token::IDENTIFIER || Token::IsKeyword(next)) { | 2999 if (next == Token::IDENTIFIER || next == Token::NUMBER || |
3000 Handle<String> name = GetSymbol(CHECK_OK); | 3000 next == Token::STRING || is_keyword) { |
| 3001 Handle<String> name; |
| 3002 if (is_keyword) { |
| 3003 name = Factory::LookupAsciiSymbol(Token::String(next)); |
| 3004 } else { |
| 3005 name = GetSymbol(CHECK_OK); |
| 3006 } |
3001 FunctionLiteral* value = | 3007 FunctionLiteral* value = |
3002 ParseFunctionLiteral(name, | 3008 ParseFunctionLiteral(name, |
3003 RelocInfo::kNoPosition, | 3009 RelocInfo::kNoPosition, |
3004 DECLARATION, | 3010 DECLARATION, |
3005 CHECK_OK); | 3011 CHECK_OK); |
| 3012 // Allow any number of parameters for compatiabilty with JSC. |
| 3013 // Specification only allows zero parameters for get and one for set. |
3006 ObjectLiteral::Property* property = | 3014 ObjectLiteral::Property* property = |
3007 new ObjectLiteral::Property(is_getter, value); | 3015 new ObjectLiteral::Property(is_getter, value); |
3008 return property; | 3016 return property; |
3009 } else { | 3017 } else { |
3010 ReportUnexpectedToken(next); | 3018 ReportUnexpectedToken(next); |
3011 *ok = false; | 3019 *ok = false; |
3012 return NULL; | 3020 return NULL; |
3013 } | 3021 } |
3014 } | 3022 } |
3015 | 3023 |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4698 Handle<String> source = Handle<String>(String::cast(script->source())); | 4706 Handle<String> source = Handle<String>(String::cast(script->source())); |
4699 result = parser.ParseProgram(source, info->is_global()); | 4707 result = parser.ParseProgram(source, info->is_global()); |
4700 } | 4708 } |
4701 } | 4709 } |
4702 | 4710 |
4703 info->SetFunction(result); | 4711 info->SetFunction(result); |
4704 return (result != NULL); | 4712 return (result != NULL); |
4705 } | 4713 } |
4706 | 4714 |
4707 } } // namespace v8::internal | 4715 } } // namespace v8::internal |
OLD | NEW |