KJS

scriptfunction.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 1999-2000 Harri Porten ([email protected])
4  * Copyright (C) 2003, 2006 Apple Computer, Inc.
5  *
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.
10  *
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  *
21  */
22 
23 #ifndef KJS_SCRIPTFUNCTION_H
24 #define KJS_SCRIPTFUNCTION_H
25 
26 #include "function.h"
27 
28 namespace KJS
29 {
30 
31 class ActivationImp;
32 class FunctionBodyNode;
33 
37 class KJS_EXPORT FunctionImp : public InternalFunctionImp
38 {
39  friend class ActivationImp;
40 public:
41  FunctionImp(ExecState *exec, const Identifier &n, FunctionBodyNode *b, const ScopeChain &sc);
42  virtual ~FunctionImp();
43 
44  using KJS::JSObject::getOwnPropertySlot;
45  virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &);
46  virtual bool getOwnPropertyDescriptor(ExecState *, const Identifier &, PropertyDescriptor &);
47  using KJS::JSObject::put;
48  virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
49  using KJS::JSObject::deleteProperty;
50  virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
51 
52  virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
53 
54  bool implementsConstruct() const;
55  using KJS::JSObject::construct;
56  JSObject *construct(ExecState *exec, const List &args);
57 
58  // Note: implemented in nodes2string.cpp
59  UString toSource() const;
60 
61  // Note: unlike body->paramName, this returns Identifier::null for parameters
62  // that will never get set, due to later param having the same name
63  Identifier getParameterName(size_t index);
64 
65  virtual const ClassInfo *classInfo() const
66  {
67  return &info;
68  }
69  static const ClassInfo info;
70 
71  RefPtr<FunctionBodyNode> body;
72 
99  const ScopeChain &scope() const
100  {
101  return _scope;
102  }
103  void setScope(const ScopeChain &s)
104  {
105  _scope = s;
106  }
107 
108  virtual void mark();
109 private:
110  void initialCompile(ExecState *newExec);
111 
112  ScopeChain _scope;
113 
114  static JSValue *argumentsGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot &);
115  static JSValue *callerGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot &);
116  static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot &);
117  static JSValue *nameGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot &);
118 
119  void passInParameters(ExecState *exec, const List &);
120 };
121 
122 // For compatibility...
124 } // namespace
125 
126 #endif
Implementation class for internal Functions.
Unicode string class.
Definition: ustring.h:153
JSValue is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in...
Definition: value.h:58
Native list type.
Definition: list.h:52
This AST node corresponds to the function body or top-level code in the AST, but is used to keep trac...
Definition: nodes.h:1276
Class Information.
Definition: object.h:48
const ScopeChain & scope() const
Returns the scope of this object.
Represents the current state of script execution.
Definition: ExecState.h:53
Represents an Identifier for a Javascript object.
Definition: identifier.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Sep 20 2020 22:59:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.