]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/JSFunction.h
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
5 * Copyright (C) 2007 Maks Orlovich
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.
27 #include "InternalFunction.h"
28 #include "JSVariableObject.h"
29 #include "SymbolTable.h"
35 class FunctionBodyNode
;
36 class FunctionPrototype
;
40 class JSFunction
: public InternalFunction
{
42 friend class Interpreter
;
44 typedef InternalFunction Base
;
46 JSFunction(PassRefPtr
<Structure
> structure
)
47 : InternalFunction(structure
)
48 , m_scopeChain(NoScopeChain())
53 JSFunction(ExecState
*, const Identifier
&, FunctionBodyNode
*, ScopeChainNode
*);
56 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
57 virtual void put(ExecState
*, const Identifier
& propertyName
, JSValuePtr
, PutPropertySlot
&);
58 virtual bool deleteProperty(ExecState
*, const Identifier
& propertyName
);
60 JSObject
* construct(ExecState
*, const ArgList
&);
61 JSValuePtr
call(ExecState
*, JSValuePtr thisValue
, const ArgList
&);
63 void setScope(const ScopeChain
& scopeChain
) { m_scopeChain
= scopeChain
; }
64 ScopeChain
& scope() { return m_scopeChain
; }
66 void setBody(FunctionBodyNode
* body
) { m_body
= body
; }
67 void setBody(PassRefPtr
<FunctionBodyNode
> body
) { m_body
= body
; }
68 FunctionBodyNode
* body() const { return m_body
.get(); }
72 static const ClassInfo info
;
74 static PassRefPtr
<Structure
> createStructure(JSValuePtr prototype
)
76 return Structure::create(prototype
, TypeInfo(ObjectType
, ImplementsHasInstance
));
80 virtual const ClassInfo
* classInfo() const { return &info
; }
82 virtual ConstructType
getConstructData(ConstructData
&);
83 virtual CallType
getCallData(CallData
&);
85 static JSValuePtr
argumentsGetter(ExecState
*, const Identifier
&, const PropertySlot
&);
86 static JSValuePtr
callerGetter(ExecState
*, const Identifier
&, const PropertySlot
&);
87 static JSValuePtr
lengthGetter(ExecState
*, const Identifier
&, const PropertySlot
&);
89 RefPtr
<FunctionBodyNode
> m_body
;
90 ScopeChain m_scopeChain
;
93 JSFunction
* asFunction(JSValuePtr
);
95 inline JSFunction
* asFunction(JSValuePtr value
)
97 ASSERT(asObject(value
)->inherits(&JSFunction::info
));
98 return static_cast<JSFunction
*>(asObject(value
));
103 #endif // JSFunction_h