source: webkit/trunk/JavaScriptCore/kjs/JSActivation.cpp@ 35242

Last change on this file since 35242 was 35242, checked in by [email protected], 17 years ago

JavaScriptCore:

2008-07-18 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Three renames:


"CallTypeNative" => "CallTypeHost"
"code" => "byteCode"
"generatedCode" => "generatedByteCode"

JavaScriptGlue:

2008-07-18 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Three renames:


"CallTypeNative" => "CallTypeHost"
"code" => "byteCode"
"generatedCode" => "generatedByteCode"

  • ChangeLog:
  • JSObject.cpp: (JSUserObject::getCallData):

WebCore:

2008-07-18 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Three renames:


"CallTypeNative" => "CallTypeHost"
"code" => "byteCode"
"generatedCode" => "generatedByteCode"

File size: 5.5 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "JSActivation.h"
31
32#include "Arguments.h"
33#include "CodeBlock.h"
34#include "Machine.h"
35#include "Register.h"
36#include "JSFunction.h"
37
38namespace KJS {
39
40const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 };
41
42JSActivation::JSActivation(PassRefPtr<FunctionBodyNode> functionBody, Register* registers)
43 : Base(new JSActivationData(functionBody, registers))
44{
45}
46
47JSActivation::~JSActivation()
48{
49 delete d();
50}
51
52void JSActivation::copyRegisters()
53{
54 int numLocals = d()->functionBody->generatedByteCode().numLocals;
55 if (!numLocals)
56 return;
57
58 copyRegisterArray(d()->registers - numLocals, numLocals);
59}
60
61bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
62{
63 if (symbolTableGet(propertyName, slot))
64 return true;
65
66 if (JSValue** location = getDirectLocation(propertyName)) {
67 slot.setValueSlot(location);
68 return true;
69 }
70
71 // Only return the built-in arguments object if it wasn't overridden above.
72 if (propertyName == exec->propertyNames().arguments) {
73 slot.setCustom(this, getArgumentsGetter());
74 return true;
75 }
76
77 // We don't call through to JSObject because there's no way to give an
78 // activation object getter properties or a prototype.
79 ASSERT(!m_propertyMap.hasGetterSetterProperties());
80 ASSERT(prototype() == jsNull());
81 return false;
82}
83
84void JSActivation::put(ExecState*, const Identifier& propertyName, JSValue* value)
85{
86 if (symbolTablePut(propertyName, value))
87 return;
88
89 // We don't call through to JSObject because __proto__ and getter/setter
90 // properties are non-standard extensions that other implementations do not
91 // expose in the activation object.
92 ASSERT(!m_propertyMap.hasGetterSetterProperties());
93 m_propertyMap.put(propertyName, value, 0, true);
94}
95
96// FIXME: Make this function honor ReadOnly (const) and DontEnum
97void JSActivation::putWithAttributes(ExecState*, const Identifier& propertyName, JSValue* value, unsigned attributes)
98{
99 if (symbolTablePutWithAttributes(propertyName, value, attributes))
100 return;
101
102 // We don't call through to JSObject because __proto__ and getter/setter
103 // properties are non-standard extensions that other implementations do not
104 // expose in the activation object.
105 ASSERT(!m_propertyMap.hasGetterSetterProperties());
106 m_propertyMap.put(propertyName, value, attributes, true);
107}
108
109bool JSActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
110{
111 if (propertyName == exec->propertyNames().arguments)
112 return false;
113
114 return Base::deleteProperty(exec, propertyName);
115}
116
117JSObject* JSActivation::toThisObject(ExecState* exec) const
118{
119 return exec->globalThisValue();
120}
121
122void JSActivation::mark()
123{
124 Base::mark();
125
126 if (d()->argumentsObject)
127 d()->argumentsObject->mark();
128}
129
130bool JSActivation::isActivationObject() const
131{
132 return true;
133}
134
135bool JSActivation::isDynamicScope() const
136{
137 return d()->functionBody->usesEval();
138}
139
140JSValue* JSActivation::argumentsGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
141{
142 JSActivation* thisObj = static_cast<JSActivation*>(slot.slotBase());
143 if (!thisObj->d()->argumentsObject)
144 thisObj->d()->argumentsObject = thisObj->createArgumentsObject(exec);
145
146 return thisObj->d()->argumentsObject;
147}
148
149// These two functions serve the purpose of isolating the common case from a
150// PIC branch.
151
152PropertySlot::GetValueFunc JSActivation::getArgumentsGetter()
153{
154 return argumentsGetter;
155}
156
157JSObject* JSActivation::createArgumentsObject(ExecState* exec)
158{
159 Register* callFrame = d()->registers - d()->functionBody->generatedByteCode().numLocals - RegisterFile::CallFrameHeaderSize;
160
161 JSFunction* function;
162 Register* argv;
163 int argc;
164 exec->machine()->getArgumentsData(callFrame, function, argv, argc);
165
166 ArgList args(argv, argc);
167 return new (exec) Arguments(exec, function, args, this);
168}
169
170} // namespace KJS
Note: See TracBrowser for help on using the repository browser.