Changeset 38767 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Nov 25, 2008, 4:09:30 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSFunction.cpp
r38528 r38767 148 148 } 149 149 150 /* Returns the parameter name corresponding to the given index. eg:151 * function f1(x, y, z): getParameterName(0) --> x152 *153 * If a name appears more than once, only the last index at which154 * it appears associates with it. eg:155 * function f2(x, x): getParameterName(0) --> null156 */157 const Identifier& JSFunction::getParameterName(int index)158 {159 const Identifier* parameters = m_body->parameters();160 161 if (static_cast<size_t>(index) >= m_body->parameterCount())162 return m_scopeChain.globalObject()->globalData()->propertyNames->nullIdentifier;163 164 const Identifier& name = parameters[index];165 166 // Are there any subsequent parameters with the same name?167 size_t size = m_body->parameterCount();168 for (size_t i = index + 1; i < size; ++i) {169 if (parameters[i] == name)170 return m_scopeChain.globalObject()->globalData()->propertyNames->nullIdentifier;171 }172 173 return name;174 }175 176 150 // ECMA 13.2.2 [[Construct]] 177 151 ConstructType JSFunction::getConstructData(ConstructData& constructData) -
trunk/JavaScriptCore/runtime/JSFunction.h
r38473 r38767 55 55 JSValue* call(ExecState*, JSValue* thisValue, const ArgList&); 56 56 57 // Note: Returns a null identifier for any parameters that will never get set58 // due to a later parameter with the same name.59 const Identifier& getParameterName(int index);60 61 57 void setScope(const ScopeChain& scopeChain) { m_scopeChain = scopeChain; } 62 58 ScopeChain& scope() { return m_scopeChain; }
Note:
See TracChangeset
for help on using the changeset viewer.