Changeset 21027 in webkit for trunk/JavaScriptCore/kjs/nodes.h


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/nodes.h

    r15698 r21027  
    44 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
    6  *  Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
     6 *  Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    77 *
    88 *  This library is free software; you can redistribute it and/or
     
    101101
    102102    JSValue *throwError(ExecState *, ErrorType, const char *msg);
     103    JSValue* throwError(ExecState *, ErrorType, const char* msg, const char*);
    103104    JSValue *throwError(ExecState *, ErrorType, const char *msg, JSValue *, Node *);
    104105    JSValue *throwError(ExecState *, ErrorType, const char *msg, const Identifier &);
     
    109110    JSValue *throwUndefinedVariableError(ExecState *, const Identifier &);
    110111
    111     void setExceptionDetailsIfNeeded(ExecState*);
    112     void debugExceptionIfNeeded(ExecState*, JSValue*);
     112    void handleException(ExecState*);
     113    void handleException(ExecState*, JSValue*);
    113114
    114115    int m_line;
     
    454455  };
    455456
     457  class PostfixErrorNode : public Node {
     458  public:
     459    PostfixErrorNode(Node* e, Operator o) : m_expr(e), m_oper(o) {}
     460    JSValue* evaluate(ExecState*);
     461    virtual void streamTo(SourceStream&) const;
     462  private:
     463    RefPtr<Node> m_expr;
     464    Operator m_oper;
     465  };
     466
    456467  class DeleteResolveNode : public Node {
    457468  public:
     
    548559    RefPtr<Node> m_base;
    549560    Identifier m_ident;
     561    Operator m_oper;
     562  };
     563
     564  class PrefixErrorNode : public Node {
     565  public:
     566    PrefixErrorNode(Node* e, Operator o) : m_expr(e), m_oper(o) {}
     567    JSValue* evaluate(ExecState*);
     568    virtual void streamTo(SourceStream&) const;
     569  private:
     570    RefPtr<Node> m_expr;
    550571    Operator m_oper;
    551572  };
     
    721742    RefPtr<Node> m_base;
    722743    Identifier m_ident;
     744    Operator m_oper;
     745    RefPtr<Node> m_right;
     746  };
     747
     748  class AssignErrorNode : public Node {
     749  public:
     750    AssignErrorNode(Node* left, Operator oper, Node* right)
     751      : m_left(left), m_oper(oper), m_right(right) {}
     752    JSValue* evaluate(ExecState*);
     753    virtual void streamTo(SourceStream&) const;
     754  protected:
     755    RefPtr<Node> m_left;
    723756    Operator m_oper;
    724757    RefPtr<Node> m_right;
Note: See TracChangeset for help on using the changeset viewer.