Changeset 1623 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jul 21, 2002, 10:38:39 PM (23 years ago)
Author:
darin
Message:

JavaScriptCore:

  • kjs/*: Roll KDE 3.0.2 changes in. Also switch to not using APPLE_CHANGES for some of the changes that we definitely want to contribute upstream.

WebCore:

  • khtml/*: Roll KDE 3.0.2 changes in. Also switch to not using APPLE_CHANGES for some of the changes that we definitely want to contribute upstream.
  • WebCore.pbproj/project.pbxproj: Add KWQStyle.mm, remove KWQStyle.h, moving contents into qstyle.h.
  • kwq/KWQApplication.mm: (QApplication::globalStrut): Remove _logNotYetImplemented().
  • kwq/KWQButton.mm: (QButton::QButton): Use plain release, not autorelease.
  • kwq/KWQComboBox.mm: (QComboBox::init): Use plain release, not autorelease.
  • kwq/KWQListBox.mm: (QListBox::QListBox): Use plain release, not autorelease.
  • kwq/KWQPainter.mm: (QPainter::drawArc): Use plain release, not autorelease.
  • kwq/KWQKHTMLPartBrowserExtension.mm: Remove import of KWQKHTMLPartImpl.h, now that it's always part of khtml_part.h.
  • kwq/KWQKHTMLPartImpl.cpp: Simplify.
  • kwq/KWQKHTMLPartImpl.h: Add wrapper to allow multiple inclusion. Don't include khtml_part.h any more, since that file now includes this one to minimize changes to KDE code that needs to get to functions in here.
  • kwq/KWQKHTMLPartImpl.mm: (KHTMLPart::onURL), (KHTMLPart::nodeActivated), (KHTMLPart::setStatusBarText): Moved here from khtml_part.cpp.
  • kwq/KWQLoaderImpl.mm: Include khtml_part.h instead of KWQKHTMLPartImpl.h.
  • kwq/KWQPushButton.mm: (buttonFontMetrics), (QPushButton::fontMetrics): Added. Used by the form code to size buttons.
  • kwq/KWQStyle.mm: Added. (QStyle::sizeFromContents): Added. Used by the form code to size buttons.
  • kwq/KWQStyle.h: Removed.
  • kwq/qt/qstyle.h: Moved contents of KWQStyle.h in here.
  • kwq/qt/qwidget.h: Include <qstyle.h> rather than KWQStyle.h.
  • kwq/WebCoreBridge.mm: (-[WebCoreBridge isFrameSet]): Call straight to impl.
  • kwq/kdeui/klineedit.h: Add KLineEdit::frameWidth().
  • kwq/qt/qnamespace.h: Remove GUIStyle, MacStyle, and WindowsStyle.
  • kwq/qt/qpaintdevice.h: Add QInternal, QInternal::Printer, and QPaintDevice::devType().
  • kwq/qt/qpainter.h: Add QPainter::device().
  • kwq/qt/qpushbutton.h: Add QPushButton::fontMetrics().
Location:
trunk/JavaScriptCore/kjs
Files:
22 edited

Legend:

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

    r1024 r1623  
    361361            Value jObj = thisObj.get(exec,UString::from(j));
    362362            int cmp;
    363             if ( useSortFunction )
    364               {
     363            if (jObj.type() == UndefinedType) {
     364              cmp = 1;
     365            } else if (minObj.type() == UndefinedType) {
     366              cmp = -1;
     367            } else if (useSortFunction) {
    365368                List l;
    366369                l.append(jObj);
     
    368371                Object thisObj = exec->interpreter()->globalObject();
    369372                cmp = sortFunction.call(exec,thisObj, l ).toInt32(exec);
    370               }
    371             else
     373            } else {
    372374              cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
     375            }
    373376            if ( cmp < 0 )
    374377              {
  • trunk/JavaScriptCore/kjs/function.cpp

    r1326 r1623  
    22/*
    33 *  This file is part of the KDE libraries
    4  *  Copyright (C) 1999-2000 Harri Porten ([email protected])
     4 *  Copyright (C) 1999-2002 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
    66 *
     
    3232
    3333#include <stdio.h>
     34#include <errno.h>
     35#include <stdlib.h>
    3436#include <assert.h>
    3537#include <string.h>
     
    3739using namespace KJS;
    3840
    39 // ------------------------------ FunctionImp ----------------------------------
     41// ----------------------------- FunctionImp ----------------------------------
    4042
    4143const ClassInfo FunctionImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
     
    100102
    101103    Object func(this);
    102     int cont = dbg->callEvent(exec,sid,lineno,func,args);
     104    bool cont = dbg->callEvent(exec,sid,lineno,func,args);
    103105    if (!cont) {
    104106      dbg->imp()->abort();
     
    108110
    109111  // enter a new execution context
    110   ContextImp *ctx = new ContextImp(globalObj, exec, thisObj,
    111                                    codeType(), exec->context().imp(), this, args);
    112   ExecState *newExec = new ExecState(exec->interpreter(),ctx);
    113   newExec->setException(exec->exception()); // could be null
     112  ContextImp ctx(globalObj, exec, thisObj, codeType(),
     113                 exec->context().imp(), this, args);
     114  ExecState newExec(exec->interpreter(), &ctx);
     115  newExec.setException(exec->exception()); // could be null
    114116
    115117  // In order to maintain our "arguments" property, we maintain a list of arguments
     
    118120  // Note: this does not appear to be part of the spec
    119121  if (codeType() == FunctionCode) {
    120     assert(ctx->activationObject().inherits(&ActivationImp::info));
    121     Object argsObj = static_cast<ActivationImp*>(ctx->activationObject().imp())->argumentsObject();
    122     put(newExec,"arguments", argsObj, DontDelete|DontEnum|ReadOnly);
    123     pushArgs(newExec,argsObj);
     122    assert(ctx.activationObject().inherits(&ActivationImp::info));
     123    Object argsObj = static_cast<ActivationImp*>(ctx.activationObject().imp())->argumentsObject();
     124    put(&newExec, "arguments", argsObj, DontDelete|DontEnum|ReadOnly);
     125    pushArgs(&newExec, argsObj);
    124126  }
    125127
    126128  // assign user supplied arguments to parameters
    127   processParameters(newExec,args);
     129  processParameters(&newExec, args);
    128130  // add variable declarations (initialized to undefined)
    129   processVarDecls(newExec);
    130 
    131   Completion comp = execute(newExec);
     131  processVarDecls(&newExec);
     132
     133  Completion comp = execute(&newExec);
    132134
    133135  // if an exception occured, propogate it back to the previous execution object
    134   if (newExec->hadException())
    135     exec->setException(newExec->exception());
     136  if (newExec.hadException())
     137    exec->setException(newExec.exception());
    136138  if (codeType() == FunctionCode)
    137     popArgs(newExec);
    138   delete newExec;
    139   delete ctx;
     139    popArgs(&newExec);
    140140
    141141#ifdef KJS_VERBOSE
     
    431431  }
    432432  case ParseInt: {
    433     String str = args[0].toString(exec);
     433    CString cstr = args[0].toString(exec).cstring();
    434434    int radix = args[1].toInt32(exec);
    435     if (radix == 0)
    436       radix = 10;
    437     else if (radix < 2 || radix > 36) {
     435
     436    char* endptr;
     437    errno = 0;
     438    long value = strtol(cstr.c_str(), &endptr, radix);
     439    if (errno != 0 || endptr == cstr.c_str())
    438440      res = Number(NaN);
    439       return res;
    440     }
    441     /* TODO: use radix */
    442     // Can't use toULong(), we want to accept floating point values too
    443     double value = str.value().toDouble( true /*tolerant*/ );
    444     if ( isNaN(value) )
    445         res = Number(NaN);
    446441    else
    447         res = Number(static_cast<long>(value)); // remove floating-point part
    448     break;
    449   }
    450   case ParseFloat: {
    451     String str = args[0].toString(exec);
    452     res = Number(str.value().toDouble( true /*tolerant*/ ));
    453     break;
    454   }
     442      res = Number(value);
     443    break;
     444  }
     445  case ParseFloat:
     446    res = Number(args[0].toString(exec).toDouble( true /*tolerant*/ ));
     447    break;
    455448  case IsNaN:
    456449    res = Boolean(isNaN(args[0].toNumber(exec)));
    457450    break;
    458451  case IsFinite: {
    459     Number n = args[0].toNumber(exec);
    460     res = Boolean(!n.isNaN() && !n.isInf());
     452    double n = args[0].toNumber(exec);
     453    res = Boolean(!isNaN(n) && !isInf(n));
    461454    break;
    462455  }
     
    485478    UString s, str = args[0].toString(exec);
    486479    int k = 0, len = str.size();
     480    UChar u;
    487481    while (k < len) {
    488482      const UChar *c = str.data() + k;
    489       UChar u;
    490483      if (*c == UChar('%') && k <= len - 6 && *(c+1) == UChar('u')) {
    491484        u = Lexer::convertUnicode((c+2)->unicode(), (c+3)->unicode(),
  • trunk/JavaScriptCore/kjs/internal.cpp

    r1371 r1623  
    22/*
    33 *  This file is part of the KDE libraries
    4  *  Copyright (C) 1999-2001 Harri Porten ([email protected])
     4 *  Copyright (C) 1999-2002 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
    66 *
     
    837837
    838838  // Constructors (Object, Array, etc.)
    839 
    840   ObjectObjectImp *objectObj = new ObjectObjectImp(globExec,objProto,funcProto);
    841   b_Object = Object(objectObj);
    842   FunctionObjectImp *funcObj = new FunctionObjectImp(globExec,funcProto);
    843   b_Function = Object(funcObj);
    844   ArrayObjectImp *arrayObj = new ArrayObjectImp(globExec,funcProto,arrayProto);
    845   b_Array = Object(arrayObj);
    846   StringObjectImp *stringObj = new StringObjectImp(globExec,funcProto,stringProto);
    847   b_String = Object(stringObj);
    848   BooleanObjectImp *booleanObj = new BooleanObjectImp(globExec,funcProto,booleanProto);
    849   b_Boolean = Object(booleanObj);
    850   NumberObjectImp *numberObj = new NumberObjectImp(globExec,funcProto,numberProto);
    851   b_Number = Object(numberObj);
    852   DateObjectImp *dateObj = new DateObjectImp(globExec,funcProto,dateProto);
    853   b_Date = Object(dateObj);
    854   RegExpObjectImp *regexpObj = new RegExpObjectImp(globExec,regexpProto,funcProto);
    855   b_RegExp = Object(regexpObj);
    856   ErrorObjectImp *errorObj = new ErrorObjectImp(globExec,funcProto,errorProto);
    857   b_Error = Object(errorObj);
     839  b_Object = Object(new ObjectObjectImp(globExec, objProto, funcProto));
     840  b_Function = Object(new FunctionObjectImp(globExec, funcProto));
     841  b_Array = Object(new ArrayObjectImp(globExec, funcProto, arrayProto));
     842  b_String = Object(new StringObjectImp(globExec, funcProto, stringProto));
     843  b_Boolean = Object(new BooleanObjectImp(globExec, funcProto, booleanProto));
     844  b_Number = Object(new NumberObjectImp(globExec, funcProto, numberProto));
     845  b_Date = Object(new DateObjectImp(globExec, funcProto, dateProto));
     846  b_RegExp = Object(new RegExpObjectImp(globExec, funcProto, regexpProto));
     847  b_Error = Object(new ErrorObjectImp(globExec, funcProto, errorProto));
    858848
    859849  // Error object prototypes
     
    10171007  }
    10181008
    1019   // no program node means a syntax occurred
     1009  // no program node means a syntax error occurred
    10201010  if (!progNode) {
    10211011    Object err = Error::create(globExec,SyntaxError,errMsg.ascii(),errLine);
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r1024 r1623  
    300300
    301301#ifdef KJS_DEBUG_MEM
     302#include "lexer.h"
    302303void Interpreter::finalCheck()
    303304{
     
    312313  Node::finalCheck();
    313314  Collector::finalCheck();
     315  Lexer::globalClear();
     316  List::globalClear();
     317  UString::globalClear();
    314318}
    315319#endif
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r1024 r1623  
    9191  return currLexer;
    9292}
     93
     94#ifdef KJS_DEBUG_MEM
     95void Lexer::globalClear()
     96{
     97  delete currLexer;
     98  currLexer = 0L;
     99}
     100#endif
    93101
    94102void Lexer::setCode(const UChar *c, unsigned int len)
  • trunk/JavaScriptCore/kjs/lexer.h

    r1024 r1623  
    112112    static bool isDecimalDigit(unsigned short c);
    113113
     114#ifdef KJS_DEBUG_MEM
     115    /**
     116     * Clear statically allocated resources
     117     */
     118    static void globalClear();
     119#endif
    114120  private:
    115121
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r1024 r1623  
    141141Value MathFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
    142142{
    143   Value v = args[0];
    144   Number n = v.toNumber(exec);
    145   double arg = n.value();
    146 
    147   Value v2 = args[1];
    148   Number n2 = v2.toNumber(exec);
    149   double arg2 = n2.value();
     143  double arg = args[0].toNumber(exec);
     144  double arg2 = args[1].toNumber(exec);
    150145  double result;
    151146
     
    241236    if (isNaN(arg))
    242237      result = arg;
    243     if (isInf(arg) || isInf(-arg))
     238    else if (isInf(arg) || isInf(-arg))
    244239      result = arg;
    245240    else if (arg == -0.5)
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r1338 r1623  
    22/*
    33 *  This file is part of the KDE libraries
    4  *  Copyright (C) 1999-2001 Harri Porten ([email protected])
     4 *  Copyright (C) 1999-2002 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
    66 *
     
    7474
    7575#ifdef KJS_DEBUG_MEM
    76 std::list<Node *> Node::s_nodes;
     76std::list<Node *> * Node::s_nodes = 0L;
    7777#endif
    7878// ------------------------------ Node -----------------------------------------
     
    8383  refcount = 0;
    8484#ifdef KJS_DEBUG_MEM
    85   s_nodes.push_back( this );
     85  if (!s_nodes)
     86    s_nodes = new std::list<Node *>;
     87  s_nodes->push_back(this);
    8688#endif
    8789}
     
    9092{
    9193#ifdef KJS_DEBUG_MEM
    92   s_nodes.remove( this );
     94  s_nodes->remove( this );
    9395#endif
    9496}
     
    9799void Node::finalCheck()
    98100{
    99 #ifdef APPLE_CHANGES
    100101  fprintf( stderr, "Node::finalCheck(): list count       : %d\n", (int)s_nodes.size() );
    101 #else
    102   fprintf( stderr, "Node::finalCheck(): list count       : %d\n", s_nodes.size() );
    103 #endif
    104   std::list<Node *>::iterator it = s_nodes.begin();
    105   for ( uint i = 0; it != s_nodes.end() ; ++it, ++i )
    106102    fprintf( stderr, "[%d] Still having node %p (%s) (refcount %d)\n", i, (void*)*it, typeid( **it ).name(), (*it)->refcount );
     103  delete s_nodes;
     104  s_nodes = 0L;
    107105}
    108106#endif
     
    747745  }
    748746
     747#if KJS_MAX_STACK > 0
     748  static int depth = 0; // sum of all concurrent interpreters
     749  if (++depth > KJS_MAX_STACK) {
     750#ifndef NDEBUG
     751    printInfo(exec, "Exceeded maximum function call depth", v, line);
     752#endif
     753    return throwError(exec, RangeError, "Exceeded maximum call stack size.");
     754  }
     755#endif
     756
    749757  Value thisVal;
    750758  if (e.type() == ReferenceType)
     
    770778  Object thisObj = Object::dynamicCast(thisVal);
    771779  Value result = func.call(exec,thisObj, argList);
     780
     781#if KJS_MAX_STACK > 0
     782  --depth;
     783#endif
    772784
    773785  return result;
     
    31403152  KJS_CHECKEXCEPTION
    31413153
    3142 #ifdef APPLE_CHANGES
    31433154  Completion c1 = element->execute(exec);
    31443155  KJS_CHECKEXCEPTION;
     
    31573168 
    31583169  return c1;
    3159 #else
    3160   if (!elements)
    3161     return element->execute(exec);
    3162 
    3163   Completion c1 = elements->execute(exec);
    3164   KJS_CHECKEXCEPTION
    3165   if (c1.complType() != Normal)
    3166     return c1;
    3167 
    3168   Completion c2 = element->execute(exec);
    3169   KJS_CHECKEXCEPTION
    3170 
    3171   // The spec says to return c2 here, but it seems that mozilla returns c1 if
    3172   // c2 doesn't have a value
    3173   if (c2.complType() == Normal && c2.value().isNull())
    3174     return c1;
    3175   else
    3176     return c2;
    3177 #endif
    31783170}
    31793171
     
    31813173void SourceElementsNode::processFuncDecl(ExecState *exec)
    31823174{
    3183 #ifdef APPLE_CHANGES
    31843175  for (SourceElementsNode *node = this; node; node = node->elements) {
    31853176    node->element->processFuncDecl(exec);
    31863177  }
    3187 #else
    3188   if (elements)
    3189     elements->processFuncDecl(exec);
    3190 
    3191   element->processFuncDecl(exec);
    3192 #endif
    31933178}
    31943179
    31953180void SourceElementsNode::processVarDecls(ExecState *exec)
    31963181{
    3197 #ifdef APPLE_CHANGES
    31983182  for (SourceElementsNode *node = this; node; node = node->elements) {
    31993183    node->element->processVarDecls(exec);
    32003184  }
    3201 #else
    3202   if (elements)
    3203     elements->processVarDecls(exec);
    3204 
    3205   element->processVarDecls(exec);
    3206 #endif
    32073185}
    32083186
  • trunk/JavaScriptCore/kjs/nodes.h

    r1024 r1623  
    102102#ifdef KJS_DEBUG_MEM
    103103    // List of all nodes, for debugging purposes. Don't remove!
    104     static std::list<Node *> s_nodes;
     104    static std::list<Node *> *s_nodes;
    105105#endif
    106106    // disallow assignment
  • trunk/JavaScriptCore/kjs/object.h

    r1024 r1623  
    2828// Objects
    2929
     30// maximum global call stack size. Protects against accidental or
     31// malicious infinite recursions. Define to -1 if you want no limit.
     32#define KJS_MAX_STACK 1000
     33
    3034#include "value.h"
    3135#include "types.h"
  • trunk/JavaScriptCore/kjs/operations.cpp

    r1326 r1623  
    245245Value KJS::mult(ExecState *exec, const Value &v1, const Value &v2, char oper)
    246246{
    247   Number n1 = v1.toNumber(exec);
    248   Number n2 = v2.toNumber(exec);
     247  double n1 = v1.toNumber(exec);
     248  double n2 = v2.toNumber(exec);
    249249
    250250  double result;
    251251
    252252  if (oper == '*')
    253     result = n1.value() * n2.value();
     253    result = n1 * n2;
    254254  else if (oper == '/')
    255     result = n1.value() / n2.value();
     255    result = n1 / n2;
    256256  else
    257     result = fmod(n1.value(), n2.value());
     257    result = fmod(n1, n2);
    258258
    259259  return Number(result);
  • trunk/JavaScriptCore/kjs/regexp.cpp

    r1326 r1623  
    2929
    3030RegExp::RegExp(const UString &p, int f)
    31   : pattern(p), flags(f)
     31  : pattern(p), flgs(f)
    3232{
    3333#ifdef HAVE_PCREPOSIX
     
    3636  int errorOffset;
    3737
    38   if (flags & IgnoreCase)
     38  if (flgs & IgnoreCase)
    3939    pcreflags |= PCRE_CASELESS;
    4040
    41   if (flags & Multiline)
     41  if (flgs & Multiline)
    4242    pcreflags |= PCRE_MULTILINE;
    4343
  • trunk/JavaScriptCore/kjs/regexp.h

    r1024 r1623  
    4545    RegExp(const UString &p, int f = None);
    4646    ~RegExp();
     47    int flags() const { return flgs; }
    4748    UString match(const UString &s, int i = -1, int *pos = 0L, int **ovector = 0L);
    4849    // test is unused. The JS spec says that RegExp.test should use
     
    5253  private:
    5354    const UString &pattern;
    54     int flags;
     55    int flgs;
    5556
    5657#ifndef HAVE_PCREPOSIX
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r1326 r1623  
    150150
    151151RegExpObjectImp::RegExpObjectImp(ExecState *exec,
    152                                  RegExpPrototypeImp *regProto,
    153                                  FunctionPrototypeImp *funcProto)
     152                                 FunctionPrototypeImp *funcProto,
     153                                 RegExpPrototypeImp *regProto)
     154
    154155  : InternalFunctionImp(funcProto), lastOvector(0L), lastNrSubPatterns(0)
    155156{
     
    176177}
    177178
    178 Value RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
     179Object RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
    179180{
    180181  List list;
     
    187188      list.append(String(substring));
    188189    }
    189   return exec->interpreter()->builtinArray().construct(exec, list);
    190 }
    191 
    192 Value RegExpObjectImp::get(ExecState *, const UString &p) const
     190  Object arr = exec->interpreter()->builtinArray().construct(exec, list);
     191  arr.put(exec, "index", Number(lastOvector[0]));
     192  arr.put(exec, "input", String(lastString));
     193  return arr;
     194}
     195
     196Value RegExpObjectImp::get(ExecState *exec, const UString &p) const
    193197{
    194198  if (p[0] == '$' && lastOvector)
     
    206210    }
    207211  }
    208   return Undefined();
     212  return InternalFunctionImp::get(exec, p);
    209213}
    210214
     
    217221Object RegExpObjectImp::construct(ExecState *exec, const List &args)
    218222{
    219   String p = args[0].toString(exec);
    220   String f = args[1].toString(exec);
    221   UString flags = f.value();
     223  String p = args.isEmpty() ? UString("") : args[0].toString(exec);
     224  UString flags = args[1].toString(exec);
    222225
    223226  RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->interpreter()->builtinRegExpPrototype().imp());
     
    234237  dat->put(exec, "multiline", Boolean(multiline));
    235238
    236   dat->put(exec, "source", String(p.value()));
     239  dat->put(exec, "source", p);
    237240  dat->put(exec, "lastIndex", Number(0), DontDelete | DontEnum);
    238241
     
    255258
    256259// ECMA 15.10.3
    257 Value RegExpObjectImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
    258 {
    259   // TODO: implement constructor
    260   return Undefined();
    261 }
     260Value RegExpObjectImp::call(ExecState *exec, Object &/*thisObj*/,
     261                            const List &args)
     262{
     263  // TODO: handle RegExp argument case (15.10.3.1)
     264
     265  return construct(exec, args);
     266}
  • trunk/JavaScriptCore/kjs/regexp_object.h

    r1326 r1623  
    6565  public:
    6666    RegExpObjectImp(ExecState *exec,
    67                     RegExpPrototypeImp *regProto,
    68                     FunctionPrototypeImp *funcProto);
     67                    FunctionPrototypeImp *funcProto,
     68                    RegExpPrototypeImp *regProto);
    6969    virtual ~RegExpObjectImp();
    7070    virtual bool implementsConstruct() const;
     
    7676    int ** registerRegexp( const RegExp* re, const UString& s );
    7777    void setSubPatterns(int num) { lastNrSubPatterns = num; }
    78     Value arrayOfMatches(ExecState *exec, const UString &result) const;
     78    Object arrayOfMatches(ExecState *exec, const UString &result) const;
    7979  private:
    8080    UString lastString;
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r1326 r1623  
    5858  replace               StringProtoFuncImp::Replace     DontEnum|Function       2
    5959  search                StringProtoFuncImp::Search      DontEnum|Function       1
    60   slice                 StringProtoFuncImp::Slice       DontEnum|Function       0
    61   split                 StringProtoFuncImp::Split       DontEnum|Function       1
     60  slice                 StringProtoFuncImp::Slice       DontEnum|Function       2
     61  split                 StringProtoFuncImp::Split       DontEnum|Function       2
    6262  substr                StringProtoFuncImp::Substr      DontEnum|Function       2
    6363  substring             StringProtoFuncImp::Substring   DontEnum|Function       2
     
    197197  case Search: {
    198198    u = s;
    199     RegExp* reg = 0;
     199    RegExp *reg, *tmpReg = 0;
     200    RegExpImp *imp = 0;
    200201    if (a0.isA(ObjectType) && a0.toObject(exec).inherits(&RegExpImp::info))
    201202    {
    202       RegExpImp* imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
     203      imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
    203204      reg = imp->regExp();
    204205    }
     
    209210       *  replaced with the result of the expression new RegExp(regexp).
    210211       */
    211       reg = new RegExp(a0.toString(exec), RegExp::None);
     212      reg = tmpReg = new RegExp(a0.toString(exec), RegExp::None);
    212213    }
    213214    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
    214     int **ovector = regExpObj->registerRegexp( reg, u );
     215    int **ovector = regExpObj->registerRegexp(reg, u);
    215216    UString mstr = reg->match(u, -1, &pos, ovector);
    216     regExpObj->setSubPatterns(reg->subPatterns());
    217     if (a0.isA(StringType))
    218       delete reg;
    219217    if (id == Search) {
    220218      result = Number(pos);
    221       break;
    222     }
    223     if (mstr.isNull())
    224       result = Null();
    225     else
    226       result = regExpObj->arrayOfMatches(exec,mstr);
     219    } else {
     220      // Exec
     221      if ((reg->flags() & RegExp::Global) == 0) {
     222        // case without 'g' flag is handled like RegExp.prototype.exec
     223        if (mstr.isNull())
     224          return Null(); // no match
     225        regExpObj->setSubPatterns(reg->subPatterns());
     226        result = regExpObj->arrayOfMatches(exec,mstr);
     227      } else {
     228        // return array of matches
     229        List list;
     230        int lastIndex = 0;
     231        while (pos >= 0) {
     232          list.append(String(mstr));
     233          lastIndex = pos;
     234          pos += mstr.isEmpty() ? 1 : mstr.size();
     235          delete [] *ovector;
     236          mstr = reg->match(u, pos, &pos, ovector);
     237        }
     238        if (imp)
     239          imp->put(exec, "lastIndex", Number(lastIndex), DontDelete|DontEnum);
     240        result = exec->interpreter()->builtinArray().construct(exec, list);
     241      }
     242    }
     243    delete tmpReg;
     244    break;
    227245  }
    228     break;
    229246  case Replace:
    230247    u = s;
     
    329346        break;
    330347      }
    331       int *ovector;
    332       int mpos;
    333348      pos = 0;
    334       while (1) {
     349      while (pos < u.size()) {
    335350        // TODO: back references
     351        int mpos;
     352        int *ovector = 0L;
    336353        UString mstr = reg.match(u, pos, &mpos, &ovector);
     354        delete [] ovector; ovector = 0L;
    337355        if (mpos < 0)
    338356          break;
     
    344362        }
    345363      }
    346       delete [] ovector;
    347364    } else if (a0.type() != UndefinedType) {
    348365      u2 = a0.toString(exec);
  • trunk/JavaScriptCore/kjs/string_object.lut.h

    r901 r1623  
    1616   { "concat", StringProtoFuncImp::Concat, DontEnum|Function, 1, &stringTableEntries[26] },
    1717   { 0, 0, 0, 0, 0 },
    18    { "split", StringProtoFuncImp::Split, DontEnum|Function, 1, &stringTableEntries[28] },
     18   { "split", StringProtoFuncImp::Split, DontEnum|Function, 2, &stringTableEntries[28] },
    1919   { "anchor", StringProtoFuncImp::Anchor, DontEnum|Function, 1, 0 },
    2020   { "charCodeAt", StringProtoFuncImp::CharCodeAt, DontEnum|Function, 1, 0 },
     
    3232   { "fontsize", StringProtoFuncImp::Fontsize, DontEnum|Function, 1, 0 },
    3333   { "substr", StringProtoFuncImp::Substr, DontEnum|Function, 2, 0 },
    34    { "slice", StringProtoFuncImp::Slice, DontEnum|Function, 0, &stringTableEntries[30] },
     34   { "slice", StringProtoFuncImp::Slice, DontEnum|Function, 2, &stringTableEntries[30] },
    3535   { "substring", StringProtoFuncImp::Substring, DontEnum|Function, 2, 0 },
    3636   { "toLowerCase", StringProtoFuncImp::ToLowerCase, DontEnum|Function, 0, 0 },
  • trunk/JavaScriptCore/kjs/types.cpp

    r1024 r1623  
    270270}
    271271
     272#ifdef KJS_DEBUG_MEM
     273void List::globalClear()
     274{
     275  delete ListImp::emptyList;
     276  ListImp::emptyList = 0L;
     277}
     278#endif
     279
     280
    272281// ------------------------------ Completion -----------------------------------
    273282
  • trunk/JavaScriptCore/kjs/types.h

    r1024 r1623  
    230230     */
    231231    static const List empty();
     232#ifdef KJS_DEBUG_MEM
     233    static void globalClear();
     234#endif
    232235  };
    233236
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r1371 r1623  
    341341  return statBuffer;
    342342}
     343
     344#ifdef KJS_DEBUG_MEM
     345void UString::globalClear()
     346{
     347  delete [] statBuffer;
     348  statBuffer = 0L;
     349}
     350#endif
    343351
    344352UString &UString::operator=(const char *c)
  • trunk/JavaScriptCore/kjs/ustring.h

    r1549 r1623  
    403403     */
    404404    static UString null;
     405#ifdef KJS_DEBUG_MEM
     406    /**
     407     * Clear statically allocated resources.
     408     */
     409    static void globalClear();
     410#endif
    405411  private:
    406412    void attach(Rep *r);
  • trunk/JavaScriptCore/kjs/value.cpp

    r1326 r1623  
    4040using namespace KJS;
    4141
    42 // ------------------------------ ValueImp -------------------------------------
     42// ----------------------------- ValueImp -------------------------------------
    4343
    4444#if APPLE_CHANGES
     
    382382    return Undefined(0);
    383383
    384   return Undefined(static_cast<UndefinedImp*>(v.imp()));
     384  return Undefined();
    385385}
    386386
     
    414414    return Null(0);
    415415
    416   return Null(static_cast<NullImp*>(v.imp()));
     416  return Null();
    417417}
    418418
     
    542542int Number::intValue() const
    543543{
    544   assert(rep);
    545   return (int)((NumberImp*)rep)->value();
     544  return int(value());
    546545}
    547546
    548547bool Number::isNaN() const
    549548{
    550   return KJS::isNaN(((NumberImp*)rep)->value());
     549  return KJS::isNaN(value());
    551550}
    552551
    553552bool Number::isInf() const
    554553{
    555   return KJS::isInf(((NumberImp*)rep)->value());
    556 }
    557 
     554  return KJS::isInf(value());
     555}
     556
Note: See TracChangeset for help on using the changeset viewer.