]>
git.saurik.com Git - apple/javascriptcore.git/blob - inspector/ScriptArguments.cpp
4100a3f995e933664a93710c30e8c214a0b3b8eb
2 * Copyright (C) 2014 Apple Inc. All rights reserved.
3 * Copyright (c) 2010 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "ScriptArguments.h"
35 #include "JSCInlines.h"
36 #include "ScriptValue.h"
40 PassRefPtr
<ScriptArguments
> ScriptArguments::create(JSC::ExecState
* scriptState
, Vector
<Deprecated::ScriptValue
>& arguments
)
42 return adoptRef(new ScriptArguments(scriptState
, arguments
));
45 ScriptArguments::ScriptArguments(JSC::ExecState
* execState
, Vector
<Deprecated::ScriptValue
>& arguments
)
46 : m_globalObject(execState
->vm(), execState
->lexicalGlobalObject())
48 m_arguments
.swap(arguments
);
51 ScriptArguments::~ScriptArguments()
55 const Deprecated::ScriptValue
&ScriptArguments::argumentAt(size_t index
) const
57 ASSERT(m_arguments
.size() > index
);
58 return m_arguments
[index
];
61 JSC::ExecState
* ScriptArguments::globalState() const
64 return const_cast<JSC::JSGlobalObject
*>(m_globalObject
.get())->globalExec();
69 bool ScriptArguments::getFirstArgumentAsString(String
& result
, bool checkForNullOrUndefined
)
74 const Deprecated::ScriptValue
& value
= argumentAt(0);
75 if (checkForNullOrUndefined
&& (value
.isNull() || value
.isUndefined()))
83 result
= value
.toString(globalState());
87 bool ScriptArguments::isEqual(ScriptArguments
* other
) const
92 if (m_arguments
.size() != other
->m_arguments
.size())
94 if (!globalState() && m_arguments
.size())
97 for (size_t i
= 0; i
< m_arguments
.size(); ++i
) {
98 if (!m_arguments
[i
].isEqual(other
->globalState(), other
->m_arguments
[i
]))
105 } // namespace Inspector