本文整理汇总了C++中JSGlobalObject::removeDirect方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::removeDirect方法的具体用法?C++ JSGlobalObject::removeDirect怎么用?C++ JSGlobalObject::removeDirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::removeDirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeGlobalProperties
JSObject* ProgramExecutable::initializeGlobalProperties(JSGlobalData& globalData, CallFrame* callFrame, JSScope* scope)
{
ASSERT(scope);
JSGlobalObject* globalObject = scope->globalObject();
ASSERT(globalObject);
ASSERT(&globalObject->globalData() == &globalData);
JSObject* exception = 0;
UnlinkedProgramCodeBlock* unlinkedCode = globalObject->createProgramCodeBlock(callFrame, this, &exception);
if (exception)
return exception;
m_unlinkedProgramCodeBlock.set(globalData, this, unlinkedCode);
BatchedTransitionOptimizer optimizer(globalData, globalObject);
const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCode->variableDeclarations();
const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCode->functionDeclarations();
size_t newGlobals = variableDeclarations.size() + functionDeclarations.size();
if (!newGlobals)
return 0;
globalObject->addRegisters(newGlobals);
CallFrame* globalExec = globalObject->globalExec();
for (size_t i = 0; i < functionDeclarations.size(); ++i) {
bool propertyDidExist = globalObject->removeDirect(globalData, functionDeclarations[i].first); // Newly declared functions overwrite existing properties.
UnlinkedFunctionExecutable* unlinkedFunctionExecutable = functionDeclarations[i].second.get();
JSValue value = JSFunction::create(globalExec, unlinkedFunctionExecutable->link(globalData, m_source, lineNo(), 0), scope);
int index = addGlobalVar(globalObject, functionDeclarations[i].first, IsVariable,
!propertyDidExist ? IsFunctionToSpecialize : NotFunctionOrNotSpecializable);
globalObject->registerAt(index).set(globalData, globalObject, value);
}
for (size_t i = 0; i < variableDeclarations.size(); ++i) {
if (globalObject->hasProperty(globalExec, variableDeclarations[i].first))
continue;
addGlobalVar(globalObject, variableDeclarations[i].first,
(variableDeclarations[i].second & DeclarationStacks::IsConstant) ? IsConstant : IsVariable,
NotFunctionOrNotSpecializable);
}
return 0;
}