Ignore:
Timestamp:
Jul 16, 2010, 11:32:42 AM (15 years ago)
Author:
[email protected]
Message:

2010-07-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

ES5 allows use of reserved words as IdentifierName
https://bugs.webkit.org/show_bug.cgi?id=42471

Modify the lexer to allow us to avoid identifying reserved
words in those contexts where they are valid identifiers, and
we know it's safe. Additionally tag the reserved word tokens
so we can easily identify them in those cases where we can't
guarantee that we've skipped reserved word identification.

  • parser/JSParser.cpp: (JSC::JSParser::next): (JSC::JSParser::parseProperty): (JSC::JSParser::parseMemberExpression):
  • parser/JSParser.h: (JSC::):
  • parser/Lexer.cpp: (JSC::Lexer::lex):
  • parser/Lexer.h: (JSC::Lexer::):

2010-07-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

ES5 allows use of reserved words as IdentifierName
https://bugs.webkit.org/show_bug.cgi?id=42471

Add tests to check for correct handling of reserved words with
the ES5 semantics.

  • fast/js/reserved-words-as-property-expected.txt: Added.
  • fast/js/reserved-words-as-property.html: Added.
  • fast/js/script-tests/reserved-words-as-property.js: Added. ():
  • fast/js/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.5_Object_Initializer/S11.1.5_A4.1-expected.txt:
  • fast/js/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.5_Object_Initializer/S11.1.5_A4.2-expected.txt: These tests are wrong, unsure how to get sputnik tests corrected.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/JSParser.h

    r63055 r63566  
    3535enum {
    3636    UnaryOpTokenFlag = 64,
    37     BinaryOpTokenPrecedenceShift = 7,
     37    KeywordTokenFlag = 128,
     38    BinaryOpTokenPrecedenceShift = 8,
    3839    BinaryOpTokenAllowsInPrecedenceAdditionalShift = 4,
    39     BinaryOpTokenPrecedenceMask = 15 << BinaryOpTokenPrecedenceShift
     40    BinaryOpTokenPrecedenceMask = 15 << BinaryOpTokenPrecedenceShift,
    4041};
    4142
     
    4445
    4546enum JSTokenType {
    46     NULLTOKEN,
     47    NULLTOKEN = KeywordTokenFlag,
    4748    TRUETOKEN,
    4849    FALSETOKEN,
     
    7071    DEBUGGER,
    7172    ELSE,
    72     OPENBRACE,
     73    OPENBRACE = 0,
    7374    CLOSEBRACE,
    7475    OPENPAREN,
     
    107108    AUTOPLUSPLUS = 4 | UnaryOpTokenFlag,
    108109    AUTOMINUSMINUS = 5 | UnaryOpTokenFlag,
    109     TYPEOF = 6 | UnaryOpTokenFlag,
    110     VOIDTOKEN = 7 | UnaryOpTokenFlag,
    111     DELETETOKEN = 8 | UnaryOpTokenFlag,
     110    TYPEOF = 6 | UnaryOpTokenFlag | KeywordTokenFlag,
     111    VOIDTOKEN = 7 | UnaryOpTokenFlag | KeywordTokenFlag,
     112    DELETETOKEN = 8 | UnaryOpTokenFlag | KeywordTokenFlag,
    112113    OR = 0 | BINARY_OP_PRECEDENCE(1),
    113114    AND = 1 | BINARY_OP_PRECEDENCE(2),
     
    123124    LE = 11 | BINARY_OP_PRECEDENCE(7),
    124125    GE = 12 | BINARY_OP_PRECEDENCE(7),
    125     INSTANCEOF = 13 | BINARY_OP_PRECEDENCE(7),
    126     INTOKEN = 14 | IN_OP_PRECEDENCE(7),
     126    INSTANCEOF = 13 | BINARY_OP_PRECEDENCE(7) | KeywordTokenFlag,
     127    INTOKEN = 14 | IN_OP_PRECEDENCE(7) | KeywordTokenFlag,
    127128    LSHIFT = 15 | BINARY_OP_PRECEDENCE(8),
    128129    RSHIFT = 16 | BINARY_OP_PRECEDENCE(8),
Note: See TracChangeset for help on using the changeset viewer.