Ignore:
Timestamp:
Apr 23, 2007, 1:38:46 AM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej.

  • fix <rdar://problem/4840688> REGRESSION (r10588, r10621): JavaScript won't parse modifications of non-references (breaks 300themovie.warnerbros.com, fedex.com)

Despite the ECMAScript specification's claim that you can treat these as syntax
errors, doing so creates some website incompatibilities. So this patch turns them back
into evaluation errors instead.

Test: fast/js/modify-non-references.html

  • kjs/grammar.y: Change makeAssignNode, makePrefixNode, and makePostfixNode so that they never fail to parse. Update rules that use them. Fix a little bit of indenting. Use new PostfixErrorNode, PrefixErrorNode, and AssignErrorNode classes.
  • kjs/nodes.h: Added an overload of throwError that takes a char* argument. Replaced setExceptionDetailsIfNeeded and debugExceptionIfNeeded with handleException, which does both. Added PostfixErrorNode, PrefixErrorNode, and AssignErrorNode classes.
  • kjs/nodes.cpp: Changed exception macros to use handleException; simpler and smaller code size than the two functions that we used before. (Node::throwError): Added the overload mentioned above. (Node::handleException): Added. Contains the code from both setExceptionDetailsIfNeeded and debugExceptionIfNeeded. (PostfixErrorNode::evaluate): Added. Throws an exception. (PrefixErrorNode::evaluate): Ditto. (AssignErrorNode::evaluate): Ditto. (ThrowNode::execute): Call handleException instead of debugExceptionIfNeeded; this effectively adds a call to setExceptionDetailsIfNeeded, which may help with getting the correct file and line number for these exceptions.
  • kjs/nodes2string.cpp: (PostfixErrorNode::streamTo): Added. (PrefixErrorNode::streamTo): Added. (AssignErrorNode::streamTo): Added.

LayoutTests:

Reviewed by Maciej.

  • test for <rdar://problem/4840688> REGRESSION (r10588, r10621): JavaScript won't parse modifications of non-references (breaks 300themovie.warnerbros.com, fedex.com)
  • fast/js/modify-non-references-expected.txt: Added.
  • fast/js/modify-non-references.html: Added.
  • fast/js/resources/modify-non-references.js: Added.
  • fast/js/assign-expected.txt: Updated for different exception text.
  • fast/js/postfix-syntax-expected.txt: Ditto.
  • fast/js/prefix-syntax-expected.txt: Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r18837 r21027  
    22 *  This file is part of the KDE libraries
    33 *  Copyright (C) 2002 Harri Porten ([email protected])
    4  *  Copyright (C) 2003 Apple Computer, Inc.
     4 *  Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    283283}
    284284
    285 void DeleteResolveNode::streamTo(SourceStream &s) const
    286 {
    287   s << "delete " << m_ident;
    288 }
    289 
    290 void DeleteBracketNode::streamTo(SourceStream &s) const
    291 {
    292   s << "delete " << m_base << "[" << m_subscript << "]";
    293 }
    294 
    295 void DeleteDotNode::streamTo(SourceStream &s) const
    296 {
    297   s << "delete " << m_base << "." << m_ident;
    298 }
    299 
    300 void DeleteValueNode::streamTo(SourceStream &s) const
    301 {
    302   s << "delete " << m_expr;
    303 }
    304 
    305 void VoidNode::streamTo(SourceStream &s) const
    306 {
    307   s << "void " << expr;
    308 }
    309 
    310 void TypeOfValueNode::streamTo(SourceStream &s) const
    311 {
    312   s << "typeof " << m_expr;
    313 }
    314 
    315 void TypeOfResolveNode::streamTo(SourceStream &s) const
    316 {
    317   s << "typeof " << m_ident;
    318 }
    319 
    320 void PrefixResolveNode::streamTo(SourceStream &s) const
    321 {
     285void PostfixErrorNode::streamTo(SourceStream& s) const
     286{
     287  s << m_expr;
    322288  if (m_oper == OpPlusPlus)
    323289    s << "++";
    324290  else
    325291    s << "--";
    326   s << m_ident;
    327 }
    328 
    329 void PrefixBracketNode::streamTo(SourceStream &s) const
     292}
     293
     294void DeleteResolveNode::streamTo(SourceStream &s) const
     295{
     296  s << "delete " << m_ident;
     297}
     298
     299void DeleteBracketNode::streamTo(SourceStream &s) const
     300{
     301  s << "delete " << m_base << "[" << m_subscript << "]";
     302}
     303
     304void DeleteDotNode::streamTo(SourceStream &s) const
     305{
     306  s << "delete " << m_base << "." << m_ident;
     307}
     308
     309void DeleteValueNode::streamTo(SourceStream &s) const
     310{
     311  s << "delete " << m_expr;
     312}
     313
     314void VoidNode::streamTo(SourceStream &s) const
     315{
     316  s << "void " << expr;
     317}
     318
     319void TypeOfValueNode::streamTo(SourceStream &s) const
     320{
     321  s << "typeof " << m_expr;
     322}
     323
     324void TypeOfResolveNode::streamTo(SourceStream &s) const
     325{
     326  s << "typeof " << m_ident;
     327}
     328
     329void PrefixResolveNode::streamTo(SourceStream &s) const
    330330{
    331331  if (m_oper == OpPlusPlus)
     
    333333  else
    334334    s << "--";
    335   s << m_base << "[" << m_subscript << "]";
    336 }
    337 
    338 void PrefixDotNode::streamTo(SourceStream &s) const
     335  s << m_ident;
     336}
     337
     338void PrefixBracketNode::streamTo(SourceStream &s) const
    339339{
    340340  if (m_oper == OpPlusPlus)
     
    342342  else
    343343    s << "--";
     344  s << m_base << "[" << m_subscript << "]";
     345}
     346
     347void PrefixDotNode::streamTo(SourceStream &s) const
     348{
     349  if (m_oper == OpPlusPlus)
     350    s << "++";
     351  else
     352    s << "--";
    344353  s << m_base << "." << m_ident;
     354}
     355
     356void PrefixErrorNode::streamTo(SourceStream& s) const
     357{
     358  if (m_oper == OpPlusPlus)
     359    s << "++";
     360  else
     361    s << "--";
     362  s << m_expr;
    345363}
    346364
     
    526544}
    527545
     546void AssignErrorNode::streamTo(SourceStream& s) const
     547{
     548  s << m_left;
     549  streamAssignmentOperatorTo(s, m_oper);
     550  s << m_right;
     551}
     552
    528553void CommaNode::streamTo(SourceStream &s) const
    529554{
Note: See TracChangeset for help on using the changeset viewer.