本文整理汇总了C++中SymbolTableEntry::varOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTableEntry::varOffset方法的具体用法?C++ SymbolTableEntry::varOffset怎么用?C++ SymbolTableEntry::varOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTableEntry
的用法示例。
在下文中一共展示了SymbolTableEntry::varOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: instantiateDeclarations
void JSModuleRecord::instantiateDeclarations(ExecState* exec, ModuleProgramExecutable* moduleProgramExecutable)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
SymbolTable* symbolTable = moduleProgramExecutable->moduleEnvironmentSymbolTable();
JSModuleEnvironment* moduleEnvironment = JSModuleEnvironment::create(vm, exec->lexicalGlobalObject(), exec->lexicalGlobalObject(), symbolTable, jsTDZValue(), this);
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
// section 15.2.1.16.4 step 9.
// Ensure all the indirect exports are correctly resolved to unique bindings.
// Even if we avoided duplicate exports in the parser, still ambiguous exports occur due to the star export (`export * from "mod"`).
// When we see this type of ambiguity for the indirect exports here, throw a syntax error.
for (const auto& pair : exportEntries()) {
const ExportEntry& exportEntry = pair.value;
if (exportEntry.type == JSModuleRecord::ExportEntry::Type::Indirect) {
Resolution resolution = resolveExport(exec, exportEntry.exportName);
switch (resolution.type) {
case Resolution::Type::NotFound:
throwSyntaxError(exec, scope, makeString("Indirectly exported binding name '", String(exportEntry.exportName.impl()), "' is not found."));
return;
case Resolution::Type::Ambiguous:
throwSyntaxError(exec, scope, makeString("Indirectly exported binding name '", String(exportEntry.exportName.impl()), "' cannot be resolved due to ambiguous multiple bindings."));
return;
case Resolution::Type::Error:
throwSyntaxError(exec, scope, makeString("Indirectly exported binding name 'default' cannot be resolved by star export entries."));
return;
case Resolution::Type::Resolved:
break;
}
}
}
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
// section 15.2.1.16.4 step 12.
// Instantiate namespace objects and initialize the bindings with them if required.
// And ensure that all the imports correctly resolved to unique bindings.
for (const auto& pair : importEntries()) {
const ImportEntry& importEntry = pair.value;
AbstractModuleRecord* importedModule = hostResolveImportedModule(exec, importEntry.moduleRequest);
if (importEntry.isNamespace(vm)) {
JSModuleNamespaceObject* namespaceObject = importedModule->getModuleNamespace(exec);
RETURN_IF_EXCEPTION(scope, void());
bool putResult = false;
symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, importEntry.localName, namespaceObject, /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
} else {
Resolution resolution = importedModule->resolveExport(exec, importEntry.importName);
switch (resolution.type) {
case Resolution::Type::NotFound:
throwSyntaxError(exec, scope, makeString("Importing binding name '", String(importEntry.importName.impl()), "' is not found."));
return;
case Resolution::Type::Ambiguous:
throwSyntaxError(exec, scope, makeString("Importing binding name '", String(importEntry.importName.impl()), "' cannot be resolved due to ambiguous multiple bindings."));
return;
case Resolution::Type::Error:
throwSyntaxError(exec, scope, makeString("Importing binding name 'default' cannot be resolved by star export entries."));
return;
case Resolution::Type::Resolved:
break;
}
}
}
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
// section 15.2.1.16.4 step 14.
// Module environment contains the heap allocated "var", "function", "let", "const", and "class".
// When creating the environment, we initialized all the slots with empty, it's ok for lexical values.
// But for "var" and "function", we should initialize it with undefined. They are contained in the declared variables.
for (const auto& variable : declaredVariables()) {
SymbolTableEntry entry = symbolTable->get(variable.key.get());
VarOffset offset = entry.varOffset();
if (!offset.isStack()) {
bool putResult = false;
symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, Identifier::fromUid(exec, variable.key.get()), jsUndefined(), /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
}
}
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
// section 15.2.1.16.4 step 16-a-iv.
// Initialize heap allocated function declarations.
// They can be called before the body of the module is executed under circular dependencies.
UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock = moduleProgramExecutable->unlinkedModuleProgramCodeBlock();
for (size_t i = 0, numberOfFunctions = unlinkedCodeBlock->numberOfFunctionDecls(); i < numberOfFunctions; ++i) {
UnlinkedFunctionExecutable* unlinkedFunctionExecutable = unlinkedCodeBlock->functionDecl(i);
SymbolTableEntry entry = symbolTable->get(unlinkedFunctionExecutable->name().impl());
VarOffset offset = entry.varOffset();
if (!offset.isStack()) {
ASSERT(!unlinkedFunctionExecutable->name().isEmpty());
if (vm.typeProfiler() || vm.controlFlowProfiler()) {
vm.functionHasExecutedCache()->insertUnexecutedRange(moduleProgramExecutable->sourceID(),
unlinkedFunctionExecutable->typeProfilingStartOffset(),
unlinkedFunctionExecutable->typeProfilingEndOffset());
//.........这里部分代码省略.........