Ignore:
Timestamp:
Nov 3, 2007, 9:28:51 AM (18 years ago)
Author:
Darin Adler
Message:

Reviewed by Maciej.

Two or three fixes get 7 more of the Mozilla tests passing.
This gets us down from 61 failing tests to 54.

  • kjs/interpreter.h: (KJS::Interpreter::builtinRegExp): Made this inline and gave it a more specific type. Some day we should probably do that for all of these -- might even get a bit of a speed boost from it.
  • kjs/interpreter.cpp: Removed Interpreter::builtinRegExp now that it's inline in the header.
  • kjs/regexp_object.h:
  • kjs/regexp_object.cpp: (KJS::RegExpProtoFunc::callAsFunction): Moved test and exec out of the switch statement into the RegExpImp object, so they can be shared with RegExpImp::callAsFunction. (KJS::RegExpImp::match): Added. Common code used by both test and exec. (KJS::RegExpImp::test): Added. (KJS::RegExpImp::exec): Added. (KJS::RegExpImp::implementsCall): Added. (KJS::RegExpImp::callAsFunction): Added. (KJS::RegExpObjectImpPrivate::RegExpObjectImpPrivate): Initialize lastInput to null rather than empty string -- we take advantage of the difference in RegExpImp::match. (KJS::RegExpObjectImp::input): Added. No reason to go through hash tables just to get at a field like this.
  • pcre/pcre_compile.c: (check_escape): Changed the \u handling to match the JavaScript specification. If there are not 4 hex digits after the \u, then it's processed as if it wasn't an escape sequence at all.
  • pcre/pcre_internal.h: Added IS_NEWLINE, with the appropriate definition for JavaScript (4 specific Unicode values).
  • pcre/pcre_exec.c: (match): Changed all call sites to use IS_NEWLINE. (pcre_exec): Ditto.
  • tests/mozilla/expected.html: Updated to expect 7 more successful tests.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/regexp_object.h

    r27393 r27405  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    3  *  This file is part of the KDE libraries
    42 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
     3 *  Copyright (C) 2003, 2007 Apple Inc. All Rights Reserved.
    54 *
    65 *  This library is free software; you can redistribute it and/or
     
    2726
    2827namespace KJS {
    29   class ExecState;
    30   class RegExpPrototype : public JSObject {
    31   public:
    32     RegExpPrototype(ExecState *exec,
    33                        ObjectPrototype *objProto,
    34                        FunctionPrototype *funcProto);
    35     virtual const ClassInfo *classInfo() const { return &info; }
    36     static const ClassInfo info;
    37   };
    3828
    39   class RegExpProtoFunc : public InternalFunctionImp {
    40   public:
    41     RegExpProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
     29    struct RegExpObjectImpPrivate;
    4230
    43     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
     31    class RegExpPrototype : public JSObject {
     32    public:
     33        RegExpPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
     34        virtual const ClassInfo* classInfo() const { return &info; }
     35        static const ClassInfo info;
     36    };
    4437
    45     enum { Compile, Exec, Test, ToString };
    46   private:
    47     int id;
    48   };
     38    class RegExpProtoFunc : public InternalFunctionImp {
     39    public:
     40        enum { Compile, Exec, Test, ToString };
    4941
    50   class RegExpImp : public JSObject {
    51   public:
    52     RegExpImp(RegExpPrototype* regexpProto);
    53     virtual ~RegExpImp();
    54     void setRegExp(RegExp* r) { m_regExp.set(r); }
    55     RegExp* regExp() const { return m_regExp.get(); }
     42        RegExpProtoFunc(ExecState*, FunctionPrototype*, int id, int len, const Identifier&);
     43        virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
    5644
    57     virtual const ClassInfo* classInfo() const { return &info; }
    58     static const ClassInfo info;
    59   private:
    60     OwnPtr<RegExp> m_regExp;
    61   };
     45    private:
     46        int id;
     47    };
    6248
    63   struct RegExpObjectImpPrivate;
     49    class RegExpImp : public JSObject {
     50    public:
     51        RegExpImp(RegExpPrototype*, RegExp*);
     52        virtual ~RegExpImp();
    6453
    65   class RegExpObjectImp : public InternalFunctionImp {
    66   public:
    67     enum { Dollar1, Dollar2, Dollar3, Dollar4, Dollar5, Dollar6, Dollar7, Dollar8, Dollar9,
    68            Input, Multiline, LastMatch, LastParen, LeftContext, RightContext };
    69    
    70     RegExpObjectImp(ExecState *exec,
    71                     FunctionPrototype *funcProto,
    72                     RegExpPrototype *regProto);
    73     virtual bool implementsConstruct() const;
    74     virtual JSObject *construct(ExecState *exec, const List &args);
    75     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
     54        void setRegExp(RegExp* r) { m_regExp.set(r); }
     55        RegExp* regExp() const { return m_regExp.get(); }
    7656
    77     virtual void put(ExecState *, const Identifier &, JSValue *, int attr = None);
    78     void putValueProperty(ExecState *, int token, JSValue *, int attr);
    79     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    80     JSValue *getValueProperty(ExecState *, int token) const;
    81     void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0);
    82     JSObject* arrayOfMatches(ExecState*) const;
    83    
    84     virtual const ClassInfo *classInfo() const { return &info; }
    85   private:
    86     JSValue *getBackref(unsigned) const;
    87     JSValue *getLastParen() const;
    88     JSValue *getLeftContext() const;
    89     JSValue *getRightContext() const;
     57        JSValue* test(ExecState*, const List& args);
     58        JSValue* exec(ExecState*, const List& args);
    9059
    91     OwnPtr<RegExpObjectImpPrivate> d;
    92    
    93     static const ClassInfo info;
    94   };
     60        virtual bool implementsCall() const;
     61        virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
     62        virtual const ClassInfo* classInfo() const { return &info; }
     63        static const ClassInfo info;
     64
     65    private:
     66        bool match(ExecState*, const List& args);
     67
     68        OwnPtr<RegExp> m_regExp;
     69    };
     70
     71    class RegExpObjectImp : public InternalFunctionImp {
     72    public:
     73        enum { Dollar1, Dollar2, Dollar3, Dollar4, Dollar5, Dollar6, Dollar7, Dollar8, Dollar9,
     74               Input, Multiline, LastMatch, LastParen, LeftContext, RightContext };
     75
     76        RegExpObjectImp(ExecState*, FunctionPrototype*, RegExpPrototype*);
     77
     78        virtual bool implementsConstruct() const;
     79        virtual JSObject* construct(ExecState*, const List&);
     80        virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
     81        virtual void put(ExecState*, const Identifier&, JSValue*, int attributes = None);
     82        void putValueProperty(ExecState*, int token, JSValue*, int attributes);
     83        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     84        JSValue* getValueProperty(ExecState*, int token) const;
     85        virtual const ClassInfo* classInfo() const { return &info; }
     86
     87        void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0);
     88        JSObject* arrayOfMatches(ExecState*) const;
     89        const UString& input() const;
     90
     91    private:
     92        JSValue* getBackref(unsigned) const;
     93        JSValue* getLastParen() const;
     94        JSValue* getLeftContext() const;
     95        JSValue* getRightContext() const;
     96
     97        OwnPtr<RegExpObjectImpPrivate> d;
     98
     99        static const ClassInfo info;
     100    };
    95101
    96102} // namespace
Note: See TracChangeset for help on using the changeset viewer.