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