Ignore:
Timestamp:
Jul 11, 2008, 5:29:24 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-11 Sam Weinig <[email protected]>

Rubber-stamped by Darin Adler.

Move call function to CallData.cpp and construct to ConstructData.cpp.

  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • kjs/AllInOneFile.cpp:
  • kjs/CallData.cpp: Copied from kjs/JSValue.cpp.
  • kjs/ConstructData.cpp: Copied from kjs/JSValue.cpp.
  • kjs/JSValue.cpp:
File:
1 copied

Legend:

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

    r35136 r35142  
    11/*
    2  *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    3  *  Copyright (C) 2001 Peter Kelly ([email protected])
    4  *  Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
    53 *
    6  *  This library is free software; you can redistribute it and/or
    7  *  modify it under the terms of the GNU Library General Public
    8  *  License as published by the Free Software Foundation; either
    9  *  version 2 of the License, or (at your option) any later version.
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
    1012 *
    11  *  This library is distributed in the hope that it will be useful,
    12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14  *  Library General Public License for more details.
    15  *
    16  *  You should have received a copy of the GNU Library General Public License
    17  *  along with this library; see the file COPYING.LIB.  If not, write to
    18  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    19  *  Boston, MA 02110-1301, USA.
    20  *
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
     14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
     17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2124 */
    2225
    2326#include "config.h"
    24 #include "JSValue.h"
     27#include "CallData.h"
    2528
    2629#include "JSFunction.h"
    27 #include <wtf/MathExtras.h>
    2830
    2931namespace KJS {
    3032
    31 static const double D32 = 4294967296.0;
    32 
    33 // ECMA 9.4
    34 double JSValue::toInteger(ExecState* exec) const
    35 {
    36     int32_t i;
    37     if (getTruncatedInt32(i))
    38         return i;
    39     double d = toNumber(exec);
    40     return isnan(d) ? 0.0 : trunc(d);
    41 }
    42 
    43 double JSValue::toIntegerPreserveNaN(ExecState* exec) const
    44 {
    45     int32_t i;
    46     if (getTruncatedInt32(i))
    47         return i;
    48     return trunc(toNumber(exec));
    49 }
    50 
    51 int32_t JSValue::toInt32SlowCase(double d, bool& ok)
    52 {
    53     ok = true;
    54 
    55     if (d >= -D32 / 2 && d < D32 / 2)
    56         return static_cast<int32_t>(d);
    57 
    58     if (isnan(d) || isinf(d)) {
    59         ok = false;
    60         return 0;
    61     }
    62 
    63     double d32 = fmod(trunc(d), D32);
    64     if (d32 >= D32 / 2)
    65         d32 -= D32;
    66     else if (d32 < -D32 / 2)
    67         d32 += D32;
    68     return static_cast<int32_t>(d32);
    69 }
    70 
    71 int32_t JSValue::toInt32SlowCase(ExecState* exec, bool& ok) const
    72 {
    73     return JSValue::toInt32SlowCase(toNumber(exec), ok);
    74 }
    75 
    76 uint32_t JSValue::toUInt32SlowCase(double d, bool& ok)
    77 {
    78     ok = true;
    79 
    80     if (d >= 0.0 && d < D32)
    81         return static_cast<uint32_t>(d);
    82 
    83     if (isnan(d) || isinf(d)) {
    84         ok = false;
    85         return 0;
    86     }
    87 
    88     double d32 = fmod(trunc(d), D32);
    89     if (d32 < 0)
    90         d32 += D32;
    91     return static_cast<uint32_t>(d32);
    92 }
    93 
    94 uint32_t JSValue::toUInt32SlowCase(ExecState* exec, bool& ok) const
    95 {
    96     return JSValue::toUInt32SlowCase(toNumber(exec), ok);
    97 }
    98 
    99 float JSValue::toFloat(ExecState* exec) const
    100 {
    101     return static_cast<float>(toNumber(exec));
    102 }
    103 
    104 // Declared in CallData.h
    10533JSValue* call(ExecState* exec, JSValue* functionObject, CallType callType, const CallData& callData, JSValue* thisValue, const ArgList& args)
    10634{
     
    11240}
    11341
    114 // Declared in ConstructData.h
    115 JSObject* construct(ExecState* exec, JSValue* object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
    116 {
    117     if (constructType == ConstructTypeNative)
    118         return constructData.native.function(exec, static_cast<JSObject*>(object), args);
    119     ASSERT(constructType == ConstructTypeJS);
    120     // FIXME: Can this be done more efficiently using the constructData?
    121     return static_cast<JSFunction*>(object)->construct(exec, args);
    122 }
    123 
    12442} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.