]>
git.saurik.com Git - apple/javascriptcore.git/blob - kjs/internal.h
1 // -*- c-basic-offset: 2 -*-
3 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
4 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
30 #include "scope_chain.h"
34 #include <wtf/Noncopyable.h>
36 #define I18N_NOOP(s) s
40 class FunctionPrototype
;
42 // ---------------------------------------------------------------------------
44 // ---------------------------------------------------------------------------
46 class StringImp
: public JSCell
{
48 StringImp(const UString
& v
) : val(v
) { Collector::reportExtraMemoryCost(v
.cost()); }
49 enum HasOtherOwnerType
{ HasOtherOwner
};
50 StringImp(const UString
& value
, HasOtherOwnerType
) : val(value
) { }
51 const UString
& value() const { return val
; }
54 virtual JSType
type() const { return StringType
; }
56 virtual JSValue
* toPrimitive(ExecState
*, JSType preferred
= UnspecifiedType
) const;
57 virtual bool getPrimitiveNumber(ExecState
*, double& number
, JSValue
*& value
);
58 virtual bool toBoolean(ExecState
*exec
) const;
59 virtual double toNumber(ExecState
*exec
) const;
60 virtual JSObject
*toObject(ExecState
*exec
) const;
61 virtual UString
toString(ExecState
*) const;
66 class NumberImp
: public JSCell
{
67 friend class ConstantValues
;
68 friend JSValue
*jsNumberCell(double);
70 double value() const { return val
; }
72 virtual JSType
type() const { return NumberType
; }
74 virtual JSValue
* toPrimitive(ExecState
*, JSType preferred
= UnspecifiedType
) const;
75 virtual bool getPrimitiveNumber(ExecState
*, double& number
, JSValue
*& value
);
76 virtual bool toBoolean(ExecState
*exec
) const;
77 virtual double toNumber(ExecState
*exec
) const;
78 virtual UString
toString(ExecState
*exec
) const;
79 virtual JSObject
*toObject(ExecState
*exec
) const;
81 void* operator new(size_t size
)
83 return Collector::allocateNumber(size
);
86 NumberImp(double v
) : val(v
) { }
88 virtual bool getUInt32(uint32_t&) const;
89 virtual bool getTruncatedInt32(int32_t&) const;
90 virtual bool getTruncatedUInt32(uint32_t&) const;
96 // ---------------------------------------------------------------------------
98 // ---------------------------------------------------------------------------
100 struct AttachedGlobalObject
;
109 void abort() { isAborted
= true; }
110 bool aborted() const { return isAborted
; }
112 AttachedGlobalObject
* globalObjects
;
117 void printInfo(ExecState
*exec
, const char *s
, JSValue
*, int lineno
= -1);