source: webkit/trunk/JavaScriptCore/kjs/function.h@ 10701

Last change on this file since 10701 was 10634, checked in by mjs, 20 years ago

JavaScriptCore:

Reviewed by John.

I also moved SharedPtr and the assertion code from WebCore into a
new kxmlcore directory.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/collector.cpp: (KJS::Collector::allocate): (KJS::Collector::collect):
  • kjs/config.h:
  • kjs/fast_malloc.cpp: Removed.
  • kjs/fast_malloc.h: Removed.
  • kjs/function.cpp:
  • kjs/function.h:
  • kjs/function_object.cpp:
  • kjs/identifier.cpp: (KJS::Identifier::add):
  • kjs/internal.cpp:
  • kjs/internal.h:
  • kjs/nodes.h:
  • kjs/nodes2string.cpp:
  • kjs/property_map.cpp: (KJS::PropertyMap::~PropertyMap): (KJS::PropertyMap::rehash):
  • kjs/scope_chain.h:
  • kjs/shared_ptr.h: Removed.
  • kjs/string_object.cpp: (StringObjectFuncImp::callAsFunction):
  • kjs/ustring.cpp: (KJS::UString::Rep::createCopying): (KJS::UString::Rep::destroy): (KJS::UString::expandCapacity): (KJS::UString::expandPreCapacity): (KJS::UString::UString): (KJS::UString::spliceSubstringsWithSeparators): (KJS::UString::append): (KJS::UString::operator=): (KJS::UString::detach):
  • kjs/ustring.h:
  • kxmlcore/Assertions.h: Added.
  • kxmlcore/Assertions.mm: Added.
  • kxmlcore/FastMalloc.cpp: Added. (KXMLCore::LgFloor): (KXMLCore::SizeClass): (KXMLCore::ByteSizeForClass): (KXMLCore::InitSizeClasses): (KXMLCore::MetaDataAlloc): (KXMLCore::PageHeapAllocator::Init): (KXMLCore::PageHeapAllocator::New): (KXMLCore::PageHeapAllocator::Delete): (KXMLCore::PageHeapAllocator::inuse): (KXMLCore::pages): (KXMLCore::AllocationSize): (KXMLCore::Event): (KXMLCore::NewSpan): (KXMLCore::DeleteSpan): (KXMLCore::DLL_Init): (KXMLCore::DLL_Remove): (KXMLCore::DLL_IsEmpty): (KXMLCore::DLL_Length): (KXMLCore::DLL_Print): (KXMLCore::DLL_Prepend): (KXMLCore::DLL_InsertOrdered): (KXMLCore::): (KXMLCore::TCMalloc_PageHeap::GetDescriptor): (KXMLCore::TCMalloc_PageHeap::SystemBytes): (KXMLCore::TCMalloc_PageHeap::FreeBytes): (KXMLCore::TCMalloc_PageHeap::RecordSpan): (KXMLCore::TCMalloc_PageHeap::TCMalloc_PageHeap): (KXMLCore::TCMalloc_PageHeap::New): (KXMLCore::TCMalloc_PageHeap::Split): (KXMLCore::TCMalloc_PageHeap::Carve): (KXMLCore::TCMalloc_PageHeap::Delete): (KXMLCore::TCMalloc_PageHeap::RegisterSizeClass): (KXMLCore::TCMalloc_PageHeap::Dump): (KXMLCore::TCMalloc_PageHeap::GrowHeap): (KXMLCore::TCMalloc_PageHeap::Check): (KXMLCore::TCMalloc_PageHeap::CheckList): (KXMLCore::TCMalloc_ThreadCache_FreeList::Init): (KXMLCore::TCMalloc_ThreadCache_FreeList::length): (KXMLCore::TCMalloc_ThreadCache_FreeList::empty): (KXMLCore::TCMalloc_ThreadCache_FreeList::lowwatermark): (KXMLCore::TCMalloc_ThreadCache_FreeList::clear_lowwatermark): (KXMLCore::TCMalloc_ThreadCache_FreeList::Push): (KXMLCore::TCMalloc_ThreadCache_FreeList::Pop): (KXMLCore::TCMalloc_ThreadCache::freelist_length): (KXMLCore::TCMalloc_ThreadCache::Size): (KXMLCore::TCMalloc_Central_FreeList::length): (KXMLCore::TCMalloc_Central_FreeList::Init): (KXMLCore::TCMalloc_Central_FreeList::Insert): (KXMLCore::TCMalloc_Central_FreeList::Remove): (KXMLCore::TCMalloc_Central_FreeList::Populate): (KXMLCore::TCMalloc_ThreadCache::SampleAllocation): (KXMLCore::TCMalloc_ThreadCache::Init): (KXMLCore::TCMalloc_ThreadCache::Cleanup): (KXMLCore::TCMalloc_ThreadCache::Allocate): (KXMLCore::TCMalloc_ThreadCache::Deallocate): (KXMLCore::TCMalloc_ThreadCache::FetchFromCentralCache): (KXMLCore::TCMalloc_ThreadCache::ReleaseToCentralCache): (KXMLCore::TCMalloc_ThreadCache::Scavenge): (KXMLCore::TCMalloc_ThreadCache::GetCache): (KXMLCore::TCMalloc_ThreadCache::GetCacheIfPresent): (KXMLCore::TCMalloc_ThreadCache::PickNextSample): (KXMLCore::TCMalloc_ThreadCache::InitModule): (KXMLCore::TCMalloc_ThreadCache::InitTSD): (KXMLCore::TCMalloc_ThreadCache::CreateCacheIfNecessary): (KXMLCore::TCMalloc_ThreadCache::DeleteCache): (KXMLCore::TCMalloc_ThreadCache::RecomputeThreadCacheSize): (KXMLCore::TCMalloc_ThreadCache::Print): (KXMLCore::ExtractStats): (KXMLCore::DumpStats): (KXMLCore::PrintStats): (KXMLCore::DumpStackTraces): (KXMLCore::TCMallocImplementation::GetStats): (KXMLCore::TCMallocImplementation::ReadStackTraces): (KXMLCore::TCMallocImplementation::GetNumericProperty): (KXMLCore::TCMallocImplementation::SetNumericProperty): (KXMLCore::DoSampledAllocation): (KXMLCore::do_malloc): (KXMLCore::do_free): (KXMLCore::do_memalign): (KXMLCore::TCMallocGuard::TCMallocGuard): (KXMLCore::TCMallocGuard::~TCMallocGuard): (KXMLCore::malloc): (KXMLCore::free): (KXMLCore::calloc): (KXMLCore::cfree): (KXMLCore::realloc): (KXMLCore::memalign): (KXMLCore::posix_memalign): (KXMLCore::valloc): (KXMLCore::pvalloc): (KXMLCore::malloc_stats): (KXMLCore::mallopt): (KXMLCore::mallinfo):
  • kxmlcore/FastMalloc.h: Added. (KXMLCore::FastAllocated::operator new): (KXMLCore::FastAllocated::operator delete): (KXMLCore::FastAllocated::operator new[]): (KXMLCore::FastAllocated::operator delete[]):
  • kxmlcore/SharedPtr.h: Added. (KXMLCore::SharedPtr::SharedPtr): (KXMLCore::SharedPtr::~SharedPtr): (KXMLCore::SharedPtr::isNull): (KXMLCore::SharedPtr::notNull): (KXMLCore::SharedPtr::reset): (KXMLCore::SharedPtr::get): (KXMLCore::SharedPtr::operator*): (KXMLCore::SharedPtr::operator->): (KXMLCore::SharedPtr::operator!): (KXMLCore::SharedPtr::operator bool): (KXMLCore::::operator): (KXMLCore::operator==): (KXMLCore::operator!=): (KXMLCore::static_pointer_cast): (KXMLCore::const_pointer_cast):
  • kxmlcore/TCPageMap.h: Added. (TCMalloc_PageMap1::TCMalloc_PageMap1): (TCMalloc_PageMap1::Ensure): (TCMalloc_PageMap1::get): (TCMalloc_PageMap1::set): (TCMalloc_PageMap2::TCMalloc_PageMap2): (TCMalloc_PageMap2::get): (TCMalloc_PageMap2::set): (TCMalloc_PageMap2::Ensure): (TCMalloc_PageMap3::NewNode): (TCMalloc_PageMap3::TCMalloc_PageMap3): (TCMalloc_PageMap3::get): (TCMalloc_PageMap3::set): (TCMalloc_PageMap3::Ensure):
  • kxmlcore/TCSpinLock.h: Added. (TCMalloc_SpinLock::Init): (TCMalloc_SpinLock::Finalize): (TCMalloc_SpinLock::Lock): (TCMalloc_SpinLock::Unlock): (TCMalloc_SlowLock): (TCMalloc_SpinLockHolder::TCMalloc_SpinLockHolder): (TCMalloc_SpinLockHolder::~TCMalloc_SpinLockHolder):
  • kxmlcore/TCSystemAlloc.cpp: Added. (TrySbrk): (TryMmap): (TryDevMem): (TCMalloc_SystemAlloc):
  • kxmlcore/TCSystemAlloc.h: Added.

WebCore:

Reviewed by John.

I also moved SharedPtr and the assertion code from WebCore into a
new kxmlcore directory.

  • ForwardingHeaders/kjs/shared_ptr.h: Removed.
  • ForwardingHeaders/kxmlcore/Assertions.h: Added.
  • ForwardingHeaders/kxmlcore/FastMalloc.h: Added.
  • ForwardingHeaders/kxmlcore/SharedPtr.h: Added.
  • ForwardingHeaders/misc/main_thread_malloc.h: Removed.
  • WebCore.xcodeproj/project.pbxproj:
  • khtml/css/css_base.h:
  • khtml/css/css_computedstyle.cpp:
  • khtml/css/css_ruleimpl.h:
  • khtml/css/css_valueimpl.h:
  • khtml/css/cssstyleselector.h:
  • khtml/ecma/domparser.h:
  • khtml/ecma/kjs_css.h:
  • khtml/ecma/kjs_dom.cpp:
  • khtml/ecma/kjs_dom.h:
  • khtml/ecma/kjs_events.h:
  • khtml/ecma/kjs_html.cpp:
  • khtml/ecma/kjs_html.h:
  • khtml/ecma/kjs_range.h:
  • khtml/ecma/kjs_traversal.h:
  • khtml/ecma/kjs_views.cpp:
  • khtml/ecma/kjs_views.h:
  • khtml/ecma/kjs_window.cpp:
  • khtml/ecma/xmlhttprequest.h:
  • khtml/editing/SelectionController.cpp:
  • khtml/editing/append_node_command.cpp:
  • khtml/editing/apply_style_command.cpp:
  • khtml/editing/break_blockquote_command.cpp:
  • khtml/editing/composite_edit_command.cpp:
  • khtml/editing/delete_from_text_node_command.cpp:
  • khtml/editing/delete_selection_command.cpp:
  • khtml/editing/edit_command.cpp:
  • khtml/editing/htmlediting.cpp:
  • khtml/editing/insert_into_text_node_command.cpp:
  • khtml/editing/insert_line_break_command.cpp:
  • khtml/editing/insert_node_before_command.cpp:
  • khtml/editing/insert_paragraph_separator_command.cpp:
  • khtml/editing/insert_text_command.cpp:
  • khtml/editing/join_text_nodes_command.cpp:
  • khtml/editing/markup.cpp:
  • khtml/editing/merge_identical_elements_command.cpp:
  • khtml/editing/move_selection_command.cpp:
  • khtml/editing/rebalance_whitespace_command.cpp:
  • khtml/editing/remove_css_property_command.cpp:
  • khtml/editing/remove_node_attribute_command.cpp:
  • khtml/editing/remove_node_command.cpp:
  • khtml/editing/remove_node_preserving_children_command.cpp:
  • khtml/editing/replace_selection_command.cpp:
  • khtml/editing/set_node_attribute_command.cpp:
  • khtml/editing/split_element_command.cpp:
  • khtml/editing/split_text_node_command.cpp:
  • khtml/editing/split_text_node_containing_element.cpp:
  • khtml/editing/typing_command.cpp:
  • khtml/editing/visible_position.cpp:
  • khtml/editing/visible_position.h:
  • khtml/editing/wrap_contents_in_dummy_span_command.cpp:
  • khtml/html/html_imageimpl.h:
  • khtml/html/html_tableimpl.h:
  • khtml/html/htmlparser.cpp:
  • khtml/khtmlpart_p.h:
  • khtml/misc/arena.cpp: (ArenaAllocate): (FreeArenaList): (ArenaFinish):
  • khtml/misc/hashtable.h: (khtml::HashTable::~HashTable): (khtml::::allocateTable): (khtml::::rehash): (khtml::::clear): (khtml::::HashTable):
  • khtml/misc/loader.cpp:
  • khtml/misc/main_thread_malloc.cpp: Removed.
  • khtml/misc/main_thread_malloc.h: Removed.
  • khtml/misc/shared.h:
  • khtml/rendering/render_style.h:
  • khtml/xml/dom2_eventsimpl.h:
  • khtml/xml/dom2_rangeimpl.h:
  • khtml/xml/dom2_traversalimpl.h:
  • khtml/xml/dom2_viewsimpl.h:
  • khtml/xml/dom_docimpl.h:
  • khtml/xml/dom_elementimpl.cpp: (NamedAttrMapImpl::clearAttributes): (NamedAttrMapImpl::operator=): (NamedAttrMapImpl::addAttribute): (NamedAttrMapImpl::removeAttribute):
  • khtml/xml/dom_elementimpl.h:
  • khtml/xml/dom_nodeimpl.cpp:
  • khtml/xml/dom_nodeimpl.h:
  • khtml/xml/dom_position.cpp:
  • khtml/xml/dom_stringimpl.h:
  • kwq/DOM-CSS.mm:
  • kwq/DOM.mm:
  • kwq/DOMEvents.mm:
  • kwq/DOMHTML.mm:
  • kwq/DOMInternal.mm:
  • kwq/DOMViews.mm:
  • kwq/KWQAccObject.mm:
  • kwq/KWQAccObjectCache.mm:
  • kwq/KWQArrayImpl.h:
  • kwq/KWQArrayImpl.mm: (KWQArrayImpl::KWQArrayPrivate::KWQArrayPrivate): (KWQArrayImpl::KWQArrayPrivate::~KWQArrayPrivate): (KWQArrayImpl::resize):
  • kwq/KWQAssertions.h: Removed.
  • kwq/KWQAssertions.m: Removed.
  • kwq/KWQButton.mm:
  • kwq/KWQCString.mm:
  • kwq/KWQClipboard.h:
  • kwq/KWQClipboard.mm:
  • kwq/KWQColor.mm:
  • kwq/KWQComboBox.mm:
  • kwq/KWQEditCommand.mm:
  • kwq/KWQExceptions.h:
  • kwq/KWQFileButton.mm:
  • kwq/KWQFontFamily.h:
  • kwq/KWQFormData.mm:
  • kwq/KWQKHTMLPart.h:
  • kwq/KWQKHTMLPart.mm:
  • kwq/KWQKPartsBrowserInterface.mm:
  • kwq/KWQKURL.mm:
  • kwq/KWQListBox.mm:
  • kwq/KWQListImpl.mm:
  • kwq/KWQLogging.h:
  • kwq/KWQLogging.m:
  • kwq/KWQMapImpl.h:
  • kwq/KWQMapImpl.mm:
  • kwq/KWQObject.mm:
  • kwq/KWQPageState.mm:
  • kwq/KWQPainter.mm:
  • kwq/KWQResourceLoader.mm:
  • kwq/KWQSignal.mm:
  • kwq/KWQSlot.mm:
  • kwq/KWQString.h:
  • kwq/KWQString.mm: (ALLOC_QCHAR): (QString::setBufferFromCFString): (allocatePageNode):
  • kwq/KWQTextArea.mm:
  • kwq/KWQTextCodec.mm:
  • kwq/KWQTextEdit.mm:
  • kwq/KWQTextField.mm:
  • kwq/KWQTimer.mm:
  • kwq/KWQValueListImpl.h:
  • kwq/KWQValueListImpl.mm:
  • kwq/WebCoreBridge.mm:
  • kwq/WebCoreCookieAdapter.m:
  • kwq/WebCoreGraphicsBridge.m:
  • kwq/WebCoreImageRendererFactory.m:
  • kwq/WebCoreKeyGenerator.m:
  • kwq/WebCoreTextRendererFactory.mm:
  • kwq/WebCoreViewFactory.m:
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten ([email protected])
5 * Copyright (C) 2003 Apple Computer, Inc.
6 *
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.
11 *
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.
16 *
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 Steet, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef _KJS_FUNCTION_H_
25#define _KJS_FUNCTION_H_
26
27#include "internal.h"
28#include "array_instance.h"
29
30namespace KJS {
31
32 class Parameter;
33 class ActivationImp;
34
35 /**
36 * @short Implementation class for internal Functions.
37 */
38 class FunctionImp : public InternalFunctionImp {
39 friend class ActivationImp;
40 public:
41 FunctionImp(ExecState *exec, const Identifier &n = Identifier::null());
42 virtual ~FunctionImp();
43
44 virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
45 virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
46 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
47
48 virtual bool implementsCall() const;
49 virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
50
51 void addParameter(const Identifier &n);
52 Identifier getParameterName(int index);
53 // parameters in string representation, e.g. (a, b, c)
54 UString parameterString() const;
55 virtual CodeType codeType() const = 0;
56
57 virtual Completion execute(ExecState *exec) = 0;
58 Identifier name() const { return ident; }
59
60 virtual const ClassInfo *classInfo() const { return &info; }
61 static const ClassInfo info;
62 protected:
63 Parameter *param;
64 Identifier ident;
65
66 private:
67 static ValueImp *argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
68 static ValueImp *lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
69
70 void processParameters(ExecState *exec, const List &);
71 virtual void processVarDecls(ExecState *exec);
72 };
73
74 class DeclaredFunctionImp : public FunctionImp {
75 public:
76 DeclaredFunctionImp(ExecState *exec, const Identifier &n,
77 FunctionBodyNode *b, const ScopeChain &sc);
78
79 bool implementsConstruct() const;
80 ObjectImp *construct(ExecState *exec, const List &args);
81
82 virtual Completion execute(ExecState *exec);
83 CodeType codeType() const { return FunctionCode; }
84 SharedPtr<FunctionBodyNode> body;
85
86 virtual const ClassInfo *classInfo() const { return &info; }
87 static const ClassInfo info;
88 private:
89 virtual void processVarDecls(ExecState *exec);
90 };
91
92 class IndexToNameMap {
93 public:
94 IndexToNameMap(FunctionImp *func, const List &args);
95 ~IndexToNameMap();
96
97 Identifier& operator[](int index);
98 Identifier& operator[](const Identifier &indexIdentifier);
99 bool isMapped(const Identifier &index) const;
100 void IndexToNameMap::unMap(const Identifier &index);
101
102 private:
103 IndexToNameMap(); // prevent construction w/o parameters
104 int size;
105 Identifier * _map;
106 };
107
108 class ArgumentsImp : public ObjectImp {
109 public:
110 ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act);
111 virtual void mark();
112 virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
113 virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
114 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
115 virtual const ClassInfo *classInfo() const { return &info; }
116 static const ClassInfo info;
117 private:
118 static ValueImp *mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
119
120 ActivationImp *_activationObject;
121 mutable IndexToNameMap indexToNameMap;
122 };
123
124 class ActivationImp : public ObjectImp {
125 public:
126 ActivationImp(FunctionImp *function, const List &arguments);
127
128 virtual bool getOwnPropertySlot(ExecState *exec, const Identifier &, PropertySlot&);
129 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
130
131 virtual const ClassInfo *classInfo() const { return &info; }
132 static const ClassInfo info;
133
134 virtual void mark();
135
136 bool isActivation() { return true; }
137 private:
138 static PropertySlot::GetValueFunc getArgumentsGetter();
139 static ValueImp *argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
140 void createArgumentsObject(ExecState *exec) const;
141
142 FunctionImp *_function;
143 List _arguments;
144 mutable ArgumentsImp *_argumentsObject;
145 };
146
147 class GlobalFuncImp : public InternalFunctionImp {
148 public:
149 GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
150 virtual bool implementsCall() const;
151 virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
152 virtual CodeType codeType() const;
153 enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
154 DecodeURI, DecodeURIComponent, EncodeURI, EncodeURIComponent
155#ifndef NDEBUG
156 , KJSPrint
157#endif
158};
159 private:
160 int id;
161 };
162
163
164
165} // namespace
166
167#endif
Note: See TracBrowser for help on using the repository browser.