source: webkit/trunk/JavaScriptCore/runtime/MathObject.cpp@ 38477

Last change on this file since 38477 was 38440, checked in by Darin Adler, 17 years ago

JavaScriptCore:

2008-11-15 Darin Adler <Darin Adler>

Rubber stamped by Geoff Garen.

  • do the long-planned StructureID -> Structure rename
  • API/JSCallbackConstructor.cpp: (JSC::JSCallbackConstructor::JSCallbackConstructor):
  • API/JSCallbackConstructor.h: (JSC::JSCallbackConstructor::createStructure):
  • API/JSCallbackFunction.h: (JSC::JSCallbackFunction::createStructure):
  • API/JSCallbackObject.h: (JSC::JSCallbackObject::createStructure):
  • API/JSCallbackObjectFunctions.h: (JSC::::JSCallbackObject):
  • API/JSValueRef.cpp: (JSValueIsInstanceOfConstructor):
  • GNUmakefile.am:
  • JavaScriptCore.exp:
  • JavaScriptCore.pri:
  • JavaScriptCore.scons:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • VM/CTI.cpp: (JSC::CTI::compileBinaryArithOp): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileGetByIdSelf): (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain): (JSC::CTI::privateCompilePutByIdReplace): (JSC::transitionWillNeedStorageRealloc): (JSC::CTI::privateCompilePutByIdTransition): (JSC::CTI::patchGetByIdSelf): (JSC::CTI::patchPutByIdReplace):
  • VM/CTI.h: (JSC::CTI::compileGetByIdSelf): (JSC::CTI::compileGetByIdProto): (JSC::CTI::compileGetByIdChain): (JSC::CTI::compilePutByIdReplace): (JSC::CTI::compilePutByIdTransition):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::printStructure): (JSC::CodeBlock::printStructures): (JSC::CodeBlock::dump): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures):
  • VM/CodeBlock.h:
  • VM/Instruction.h: (JSC::Instruction::Instruction): (JSC::Instruction::):
  • VM/Machine.cpp: (JSC::jsTypeStringForValue): (JSC::jsIsObjectType): (JSC::BytecodeInterpreter::resolveGlobal): (JSC::BytecodeInterpreter::BytecodeInterpreter): (JSC::cachePrototypeChain): (JSC::BytecodeInterpreter::tryCachePutByID): (JSC::BytecodeInterpreter::uncachePutByID): (JSC::BytecodeInterpreter::tryCacheGetByID): (JSC::BytecodeInterpreter::uncacheGetByID): (JSC::BytecodeInterpreter::privateExecute): (JSC::BytecodeInterpreter::tryCTICachePutByID): (JSC::BytecodeInterpreter::tryCTICacheGetByID): (JSC::BytecodeInterpreter::cti_op_instanceof): (JSC::BytecodeInterpreter::cti_op_construct_JSConstruct): (JSC::BytecodeInterpreter::cti_op_resolve_global): (JSC::BytecodeInterpreter::cti_op_is_undefined):
  • runtime/Arguments.h: (JSC::Arguments::createStructure):
  • runtime/ArrayConstructor.cpp: (JSC::ArrayConstructor::ArrayConstructor):
  • runtime/ArrayConstructor.h:
  • runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::ArrayPrototype):
  • runtime/ArrayPrototype.h:
  • runtime/BatchedTransitionOptimizer.h: (JSC::BatchedTransitionOptimizer::BatchedTransitionOptimizer): (JSC::BatchedTransitionOptimizer::~BatchedTransitionOptimizer):
  • runtime/BooleanConstructor.cpp: (JSC::BooleanConstructor::BooleanConstructor):
  • runtime/BooleanConstructor.h:
  • runtime/BooleanObject.cpp: (JSC::BooleanObject::BooleanObject):
  • runtime/BooleanObject.h:
  • runtime/BooleanPrototype.cpp: (JSC::BooleanPrototype::BooleanPrototype):
  • runtime/BooleanPrototype.h:
  • runtime/DateConstructor.cpp: (JSC::DateConstructor::DateConstructor):
  • runtime/DateConstructor.h:
  • runtime/DateInstance.cpp: (JSC::DateInstance::DateInstance):
  • runtime/DateInstance.h:
  • runtime/DatePrototype.cpp: (JSC::DatePrototype::DatePrototype):
  • runtime/DatePrototype.h: (JSC::DatePrototype::createStructure):
  • runtime/ErrorConstructor.cpp: (JSC::ErrorConstructor::ErrorConstructor):
  • runtime/ErrorConstructor.h:
  • runtime/ErrorInstance.cpp: (JSC::ErrorInstance::ErrorInstance):
  • runtime/ErrorInstance.h:
  • runtime/ErrorPrototype.cpp: (JSC::ErrorPrototype::ErrorPrototype):
  • runtime/ErrorPrototype.h:
  • runtime/FunctionConstructor.cpp: (JSC::FunctionConstructor::FunctionConstructor):
  • runtime/FunctionConstructor.h:
  • runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::FunctionPrototype): (JSC::FunctionPrototype::addFunctionProperties):
  • runtime/FunctionPrototype.h: (JSC::FunctionPrototype::createStructure):
  • runtime/GlobalEvalFunction.cpp: (JSC::GlobalEvalFunction::GlobalEvalFunction):
  • runtime/GlobalEvalFunction.h:
  • runtime/Identifier.h:
  • runtime/InternalFunction.cpp: (JSC::InternalFunction::InternalFunction):
  • runtime/InternalFunction.h: (JSC::InternalFunction::createStructure): (JSC::InternalFunction::InternalFunction):
  • runtime/JSActivation.cpp: (JSC::JSActivation::JSActivation):
  • runtime/JSActivation.h: (JSC::JSActivation::createStructure):
  • runtime/JSArray.cpp: (JSC::JSArray::JSArray):
  • runtime/JSArray.h: (JSC::JSArray::createStructure):
  • runtime/JSCell.h: (JSC::JSCell::JSCell): (JSC::JSCell::isObject): (JSC::JSCell::isString): (JSC::JSCell::structure): (JSC::JSValue::needsThisConversion):
  • runtime/JSFunction.cpp: (JSC::JSFunction::construct):
  • runtime/JSFunction.h: (JSC::JSFunction::JSFunction): (JSC::JSFunction::createStructure):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): (JSC::JSGlobalData::createLeaked):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObject.cpp: (JSC::markIfNeeded): (JSC::JSGlobalObject::reset):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::JSGlobalObject): (JSC::JSGlobalObject::argumentsStructure): (JSC::JSGlobalObject::arrayStructure): (JSC::JSGlobalObject::booleanObjectStructure): (JSC::JSGlobalObject::callbackConstructorStructure): (JSC::JSGlobalObject::callbackFunctionStructure): (JSC::JSGlobalObject::callbackObjectStructure): (JSC::JSGlobalObject::dateStructure): (JSC::JSGlobalObject::emptyObjectStructure): (JSC::JSGlobalObject::errorStructure): (JSC::JSGlobalObject::functionStructure): (JSC::JSGlobalObject::numberObjectStructure): (JSC::JSGlobalObject::prototypeFunctionStructure): (JSC::JSGlobalObject::regExpMatchesArrayStructure): (JSC::JSGlobalObject::regExpStructure): (JSC::JSGlobalObject::stringObjectStructure): (JSC::JSGlobalObject::createStructure): (JSC::Structure::prototypeForLookup):
  • runtime/JSNotAnObject.h: (JSC::JSNotAnObject::createStructure):
  • runtime/JSNumberCell.h: (JSC::JSNumberCell::createStructure): (JSC::JSNumberCell::JSNumberCell):
  • runtime/JSObject.cpp: (JSC::JSObject::mark): (JSC::JSObject::put): (JSC::JSObject::deleteProperty): (JSC::JSObject::defineGetter): (JSC::JSObject::defineSetter): (JSC::JSObject::getPropertyAttributes): (JSC::JSObject::getPropertyNames): (JSC::JSObject::removeDirect): (JSC::JSObject::createInheritorID):
  • runtime/JSObject.h: (JSC::JSObject::getDirect): (JSC::JSObject::getDirectLocation): (JSC::JSObject::hasCustomProperties): (JSC::JSObject::hasGetterSetterProperties): (JSC::JSObject::createStructure): (JSC::JSObject::JSObject): (JSC::JSObject::~JSObject): (JSC::JSObject::prototype): (JSC::JSObject::setPrototype): (JSC::JSObject::setStructure): (JSC::JSObject::inheritorID): (JSC::JSObject::inlineGetOwnPropertySlot): (JSC::JSObject::getOwnPropertySlotForWrite): (JSC::JSCell::fastGetOwnPropertySlot): (JSC::JSObject::putDirect): (JSC::JSObject::putDirectWithoutTransition): (JSC::JSObject::transitionTo):
  • runtime/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::next):
  • runtime/JSStaticScopeObject.h: (JSC::JSStaticScopeObject::JSStaticScopeObject): (JSC::JSStaticScopeObject::createStructure):
  • runtime/JSString.h: (JSC::JSString::JSString): (JSC::JSString::createStructure):
  • runtime/JSVariableObject.h: (JSC::JSVariableObject::JSVariableObject):
  • runtime/JSWrapperObject.h: (JSC::JSWrapperObject::JSWrapperObject):
  • runtime/MathObject.cpp: (JSC::MathObject::MathObject):
  • runtime/MathObject.h: (JSC::MathObject::createStructure):
  • runtime/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor::NativeErrorConstructor):
  • runtime/NativeErrorConstructor.h:
  • runtime/NativeErrorPrototype.cpp: (JSC::NativeErrorPrototype::NativeErrorPrototype):
  • runtime/NativeErrorPrototype.h:
  • runtime/NumberConstructor.cpp: (JSC::NumberConstructor::NumberConstructor):
  • runtime/NumberConstructor.h: (JSC::NumberConstructor::createStructure):
  • runtime/NumberObject.cpp: (JSC::NumberObject::NumberObject):
  • runtime/NumberObject.h:
  • runtime/NumberPrototype.cpp: (JSC::NumberPrototype::NumberPrototype):
  • runtime/NumberPrototype.h:
  • runtime/ObjectConstructor.cpp: (JSC::ObjectConstructor::ObjectConstructor):
  • runtime/ObjectConstructor.h:
  • runtime/ObjectPrototype.cpp: (JSC::ObjectPrototype::ObjectPrototype):
  • runtime/ObjectPrototype.h:
  • runtime/Operations.h: (JSC::equalSlowCaseInline):
  • runtime/PropertyNameArray.h: (JSC::PropertyNameArrayData::setCachedStructure): (JSC::PropertyNameArrayData::cachedStructure): (JSC::PropertyNameArrayData::setCachedPrototypeChain): (JSC::PropertyNameArrayData::cachedPrototypeChain): (JSC::PropertyNameArrayData::PropertyNameArrayData):
  • runtime/PrototypeFunction.cpp: (JSC::PrototypeFunction::PrototypeFunction):
  • runtime/PrototypeFunction.h:
  • runtime/RegExpConstructor.cpp: (JSC::RegExpConstructor::RegExpConstructor):
  • runtime/RegExpConstructor.h: (JSC::RegExpConstructor::createStructure):
  • runtime/RegExpObject.cpp: (JSC::RegExpObject::RegExpObject):
  • runtime/RegExpObject.h: (JSC::RegExpObject::createStructure):
  • runtime/RegExpPrototype.cpp: (JSC::RegExpPrototype::RegExpPrototype):
  • runtime/RegExpPrototype.h:
  • runtime/StringConstructor.cpp: (JSC::StringConstructor::StringConstructor):
  • runtime/StringConstructor.h:
  • runtime/StringObject.cpp: (JSC::StringObject::StringObject):
  • runtime/StringObject.h: (JSC::StringObject::createStructure):
  • runtime/StringObjectThatMasqueradesAsUndefined.h: (JSC::StringObjectThatMasqueradesAsUndefined::create): (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined): (JSC::StringObjectThatMasqueradesAsUndefined::createStructure):
  • runtime/StringPrototype.cpp: (JSC::StringPrototype::StringPrototype):
  • runtime/StringPrototype.h:
  • runtime/Structure.cpp: Copied from JavaScriptCore/runtime/StructureID.cpp. (JSC::Structure::dumpStatistics): (JSC::Structure::Structure): (JSC::Structure::~Structure): (JSC::Structure::startIgnoringLeaks): (JSC::Structure::stopIgnoringLeaks): (JSC::Structure::materializePropertyMap): (JSC::Structure::getEnumerablePropertyNames): (JSC::Structure::clearEnumerationCache): (JSC::Structure::growPropertyStorageCapacity): (JSC::Structure::addPropertyTransitionToExistingStructure): (JSC::Structure::addPropertyTransition): (JSC::Structure::removePropertyTransition): (JSC::Structure::changePrototypeTransition): (JSC::Structure::getterSetterTransition): (JSC::Structure::toDictionaryTransition): (JSC::Structure::fromDictionaryTransition): (JSC::Structure::addPropertyWithoutTransition): (JSC::Structure::removePropertyWithoutTransition): (JSC::Structure::createCachedPrototypeChain): (JSC::Structure::checkConsistency): (JSC::Structure::copyPropertyTable): (JSC::Structure::get): (JSC::Structure::put): (JSC::Structure::remove): (JSC::Structure::insertIntoPropertyMapHashTable): (JSC::Structure::createPropertyMapHashTable): (JSC::Structure::expandPropertyMapHashTable): (JSC::Structure::rehashPropertyMapHashTable): (JSC::Structure::getEnumerablePropertyNamesInternal):
  • runtime/Structure.h: Copied from JavaScriptCore/runtime/StructureID.h. (JSC::Structure::create): (JSC::Structure::previousID): (JSC::Structure::setCachedPrototypeChain): (JSC::Structure::cachedPrototypeChain): (JSC::Structure::): (JSC::Structure::get):
  • runtime/StructureChain.cpp: Copied from JavaScriptCore/runtime/StructureIDChain.cpp. (JSC::StructureChain::StructureChain): (JSC::structureChainsAreEqual):
  • runtime/StructureChain.h: Copied from JavaScriptCore/runtime/StructureIDChain.h. (JSC::StructureChain::create): (JSC::StructureChain::head):
  • runtime/StructureID.cpp: Removed.
  • runtime/StructureID.h: Removed.
  • runtime/StructureIDChain.cpp: Removed.
  • runtime/StructureIDChain.h: Removed.
  • runtime/StructureIDTransitionTable.h: Removed.
  • runtime/StructureTransitionTable.h: Copied from JavaScriptCore/runtime/StructureIDTransitionTable.h.

JavaScriptGlue:

2008-11-15 Darin Adler <Darin Adler>

Rubber stamped by Geoff Garen.

  • do the long-planned StructureID -> Structure rename
  • JSRun.cpp: (JSGlueGlobalObject::JSGlueGlobalObject): (JSRun::JSRun):
  • JSRun.h: (JSGlueGlobalObject::userObjectStructure):
  • JSUtils.cpp: (getThreadGlobalObject):
  • UserObjectImp.cpp: (UserObjectImp::UserObjectImp):
  • UserObjectImp.h: (UserObjectImp::createStructure):

WebCore:

2008-11-15 Darin Adler <Darin Adler>

Rubber stamped by Geoff Garen.

  • do the long-planned StructureID -> Structure rename
  • ForwardingHeaders/runtime/Structure.h: Copied from WebCore/ForwardingHeaders/runtime/StructureID.h.
  • ForwardingHeaders/runtime/StructureID.h: Removed.
  • bindings/js/JSAudioConstructor.cpp: (WebCore::JSAudioConstructor::JSAudioConstructor):
  • bindings/js/JSDOMBinding.cpp: (WebCore::getCachedDOMStructure): (WebCore::cacheDOMStructure):
  • bindings/js/JSDOMBinding.h: (WebCore::DOMObject::DOMObject): (WebCore::getDOMStructure):
  • bindings/js/JSDOMGlobalObject.cpp: (WebCore::JSDOMGlobalObject::JSDOMGlobalObject):
  • bindings/js/JSDOMGlobalObject.h:
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::JSDOMWindowBase):
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::JSDOMWindowShell): (WebCore::JSDOMWindowShell::setWindow):
  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::createStructure):
  • bindings/js/JSDedicatedWorkerConstructor.cpp: (WebCore::JSDedicatedWorkerConstructor::JSDedicatedWorkerConstructor):
  • bindings/js/JSHTMLAllCollection.h: (WebCore::JSHTMLAllCollection::JSHTMLAllCollection): (WebCore::JSHTMLAllCollection::createStructure):
  • bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::JSImageConstructor):
  • bindings/js/JSInspectedObjectWrapper.cpp: (WebCore::JSInspectedObjectWrapper::wrap): (WebCore::JSInspectedObjectWrapper::JSInspectedObjectWrapper):
  • bindings/js/JSInspectedObjectWrapper.h:
  • bindings/js/JSInspectorCallbackWrapper.cpp: (WebCore::leakInspectorCallbackWrapperStructure): (WebCore::JSInspectorCallbackWrapper::wrap): (WebCore::JSInspectorCallbackWrapper::JSInspectorCallbackWrapper):
  • bindings/js/JSInspectorCallbackWrapper.h:
  • bindings/js/JSMessageChannelConstructor.cpp: (WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor):
  • bindings/js/JSNamedNodesCollection.h: (WebCore::JSNamedNodesCollection::createStructure):
  • bindings/js/JSOptionConstructor.cpp: (WebCore::JSOptionConstructor::JSOptionConstructor):
  • bindings/js/JSQuarantinedObjectWrapper.cpp: (WebCore::JSQuarantinedObjectWrapper::JSQuarantinedObjectWrapper):
  • bindings/js/JSQuarantinedObjectWrapper.h: (WebCore::JSQuarantinedObjectWrapper::createStructure):
  • bindings/js/JSRGBColor.h: (WebCore::JSRGBColor::createStructure):
  • bindings/js/JSWorkerContext.cpp: (WebCore::createJSWorkerContextStructure): (WebCore::JSWorkerContext::JSWorkerContext): (WebCore::JSWorkerContext::createPrototype):
  • bindings/js/JSWorkerContext.h: (WebCore::JSWorkerContext::createStructure): (WebCore::JSWorkerContextPrototype::JSWorkerContextPrototype): (WebCore::JSWorkerContextPrototype::createStructure):
  • bindings/js/JSXMLHttpRequestConstructor.cpp: (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor):
  • bindings/js/JSXSLTProcessorConstructor.cpp: (WebCore::JSXSLTProcessorConstructor::JSXSLTProcessorConstructor):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/objc/objc_runtime.h: (JSC::Bindings::ObjcFallbackObjectImp::createStructure):
  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtConnectionObject::execute):
  • bridge/qt/qt_runtime.h: (JSC::Bindings::QtRuntimeMethod::createStructure):
  • bridge/runtime_array.h: (JSC::RuntimeArray::createStructure):
  • bridge/runtime_method.h: (JSC::RuntimeMethod::createStructure):
  • bridge/runtime_object.cpp: (JSC::RuntimeObjectImp::RuntimeObjectImp):
  • bridge/runtime_object.h: (JSC::RuntimeObjectImp::createStructure):

WebKitTools:

2008-11-15 Darin Adler <Darin Adler>

Rubber stamped by Geoff Garen.

  • do the long-planned StructureID -> Structure rename
  • Scripts/check-for-global-initializers: Update name of StructureID.o.
  • Scripts/do-webcore-rename: Renaming script that I used.
  • Property svn:eol-style set to native
File size: 9.4 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#include "config.h"
22#include "MathObject.h"
23
24#include "ObjectPrototype.h"
25#include "Operations.h"
26#include <time.h>
27#include <wtf/Assertions.h>
28#include <wtf/MathExtras.h>
29
30namespace JSC {
31
32ASSERT_CLASS_FITS_IN_CELL(MathObject);
33
34static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&);
35static JSValue* mathProtoFuncACos(ExecState*, JSObject*, JSValue*, const ArgList&);
36static JSValue* mathProtoFuncASin(ExecState*, JSObject*, JSValue*, const ArgList&);
37static JSValue* mathProtoFuncATan(ExecState*, JSObject*, JSValue*, const ArgList&);
38static JSValue* mathProtoFuncATan2(ExecState*, JSObject*, JSValue*, const ArgList&);
39static JSValue* mathProtoFuncCeil(ExecState*, JSObject*, JSValue*, const ArgList&);
40static JSValue* mathProtoFuncCos(ExecState*, JSObject*, JSValue*, const ArgList&);
41static JSValue* mathProtoFuncExp(ExecState*, JSObject*, JSValue*, const ArgList&);
42static JSValue* mathProtoFuncFloor(ExecState*, JSObject*, JSValue*, const ArgList&);
43static JSValue* mathProtoFuncLog(ExecState*, JSObject*, JSValue*, const ArgList&);
44static JSValue* mathProtoFuncMax(ExecState*, JSObject*, JSValue*, const ArgList&);
45static JSValue* mathProtoFuncMin(ExecState*, JSObject*, JSValue*, const ArgList&);
46static JSValue* mathProtoFuncPow(ExecState*, JSObject*, JSValue*, const ArgList&);
47static JSValue* mathProtoFuncRandom(ExecState*, JSObject*, JSValue*, const ArgList&);
48static JSValue* mathProtoFuncRound(ExecState*, JSObject*, JSValue*, const ArgList&);
49static JSValue* mathProtoFuncSin(ExecState*, JSObject*, JSValue*, const ArgList&);
50static JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, JSValue*, const ArgList&);
51static JSValue* mathProtoFuncTan(ExecState*, JSObject*, JSValue*, const ArgList&);
52
53}
54
55#include "MathObject.lut.h"
56
57namespace JSC {
58
59// ------------------------------ MathObject --------------------------------
60
61const ClassInfo MathObject::info = { "Math", 0, 0, ExecState::mathTable };
62
63/* Source for MathObject.lut.h
64@begin mathTable
65 abs mathProtoFuncAbs DontEnum|Function 1
66 acos mathProtoFuncACos DontEnum|Function 1
67 asin mathProtoFuncASin DontEnum|Function 1
68 atan mathProtoFuncATan DontEnum|Function 1
69 atan2 mathProtoFuncATan2 DontEnum|Function 2
70 ceil mathProtoFuncCeil DontEnum|Function 1
71 cos mathProtoFuncCos DontEnum|Function 1
72 exp mathProtoFuncExp DontEnum|Function 1
73 floor mathProtoFuncFloor DontEnum|Function 1
74 log mathProtoFuncLog DontEnum|Function 1
75 max mathProtoFuncMax DontEnum|Function 2
76 min mathProtoFuncMin DontEnum|Function 2
77 pow mathProtoFuncPow DontEnum|Function 2
78 random mathProtoFuncRandom DontEnum|Function 0
79 round mathProtoFuncRound DontEnum|Function 1
80 sin mathProtoFuncSin DontEnum|Function 1
81 sqrt mathProtoFuncSqrt DontEnum|Function 1
82 tan mathProtoFuncTan DontEnum|Function 1
83@end
84*/
85
86MathObject::MathObject(ExecState* exec, PassRefPtr<Structure> structure)
87 : JSObject(structure)
88{
89 putDirectWithoutTransition(Identifier(exec, "E"), jsNumber(exec, exp(1.0)), DontDelete | DontEnum | ReadOnly);
90 putDirectWithoutTransition(Identifier(exec, "LN2"), jsNumber(exec, log(2.0)), DontDelete | DontEnum | ReadOnly);
91 putDirectWithoutTransition(Identifier(exec, "LN10"), jsNumber(exec, log(10.0)), DontDelete | DontEnum | ReadOnly);
92 putDirectWithoutTransition(Identifier(exec, "LOG2E"), jsNumber(exec, 1.0 / log(2.0)), DontDelete | DontEnum | ReadOnly);
93 putDirectWithoutTransition(Identifier(exec, "LOG10E"), jsNumber(exec, 1.0 / log(10.0)), DontDelete | DontEnum | ReadOnly);
94 putDirectWithoutTransition(Identifier(exec, "PI"), jsNumber(exec, piDouble), DontDelete | DontEnum | ReadOnly);
95 putDirectWithoutTransition(Identifier(exec, "SQRT1_2"), jsNumber(exec, sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
96 putDirectWithoutTransition(Identifier(exec, "SQRT2"), jsNumber(exec, sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
97}
98
99// ECMA 15.8
100
101bool MathObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot)
102{
103 const HashEntry* entry = ExecState::mathTable(exec)->entry(exec, propertyName);
104
105 if (!entry)
106 return JSObject::getOwnPropertySlot(exec, propertyName, slot);
107
108 ASSERT(entry->attributes() & Function);
109 setUpStaticFunctionSlot(exec, entry, this, propertyName, slot);
110 return true;
111}
112
113// ------------------------------ Functions --------------------------------
114
115JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
116{
117 return jsNumber(exec, fabs(args.at(exec, 0)->toNumber(exec)));
118}
119
120JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
121{
122 return jsNumber(exec, acos(args.at(exec, 0)->toNumber(exec)));
123}
124
125JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
126{
127 return jsNumber(exec, asin(args.at(exec, 0)->toNumber(exec)));
128}
129
130JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
131{
132 return jsNumber(exec, atan(args.at(exec, 0)->toNumber(exec)));
133}
134
135JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
136{
137 return jsNumber(exec, atan2(args.at(exec, 0)->toNumber(exec), args.at(exec, 1)->toNumber(exec)));
138}
139
140JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
141{
142 return jsNumber(exec, ceil(args.at(exec, 0)->toNumber(exec)));
143}
144
145JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
146{
147 return jsNumber(exec, cos(args.at(exec, 0)->toNumber(exec)));
148}
149
150JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
151{
152 return jsNumber(exec, exp(args.at(exec, 0)->toNumber(exec)));
153}
154
155JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
156{
157 return jsNumber(exec, floor(args.at(exec, 0)->toNumber(exec)));
158}
159
160JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
161{
162 return jsNumber(exec, log(args.at(exec, 0)->toNumber(exec)));
163}
164
165JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
166{
167 unsigned argsCount = args.size();
168 double result = -Inf;
169 for (unsigned k = 0; k < argsCount; ++k) {
170 double val = args.at(exec, k)->toNumber(exec);
171 if (isnan(val)) {
172 result = NaN;
173 break;
174 }
175 if (val > result || (val == 0 && result == 0 && !signbit(val)))
176 result = val;
177 }
178 return jsNumber(exec, result);
179}
180
181JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
182{
183 unsigned argsCount = args.size();
184 double result = +Inf;
185 for (unsigned k = 0; k < argsCount; ++k) {
186 double val = args.at(exec, k)->toNumber(exec);
187 if (isnan(val)) {
188 result = NaN;
189 break;
190 }
191 if (val < result || (val == 0 && result == 0 && signbit(val)))
192 result = val;
193 }
194 return jsNumber(exec, result);
195}
196
197JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
198{
199 // ECMA 15.8.2.1.13
200
201 double arg = args.at(exec, 0)->toNumber(exec);
202 double arg2 = args.at(exec, 1)->toNumber(exec);
203
204 if (isnan(arg2))
205 return jsNaN(exec);
206 if (isinf(arg2) && fabs(arg) == 1)
207 return jsNaN(exec);
208 return jsNumber(exec, pow(arg, arg2));
209}
210
211JSValue* mathProtoFuncRandom(ExecState* exec, JSObject*, JSValue*, const ArgList&)
212{
213#if !ENABLE(JSC_MULTIPLE_THREADS)
214 static bool didInitRandom;
215 if (!didInitRandom) {
216 wtf_random_init();
217 didInitRandom = true;
218 }
219#endif
220
221 return jsNumber(exec, wtf_random());
222}
223
224JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
225{
226 double arg = args.at(exec, 0)->toNumber(exec);
227 if (signbit(arg) && arg >= -0.5)
228 return jsNumber(exec, -0.0);
229 return jsNumber(exec, floor(arg + 0.5));
230}
231
232JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
233{
234 return jsNumber(exec, sin(args.at(exec, 0)->toNumber(exec)));
235}
236
237JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
238{
239 return jsNumber(exec, sqrt(args.at(exec, 0)->toNumber(exec)));
240}
241
242JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
243{
244 return jsNumber(exec, tan(args.at(exec, 0)->toNumber(exec)));
245}
246
247} // namespace JSC
Note: See TracBrowser for help on using the repository browser.