VariableEnvironment.cpp [plain text]
#include "config.h"
#include "VariableEnvironment.h"
#include <wtf/text/UniquedStringImpl.h>
namespace JSC {
void VariableEnvironment::markVariableAsCapturedIfDefined(const RefPtr<UniquedStringImpl>& identifier)
{
auto findResult = m_map.find(identifier);
if (findResult != m_map.end())
findResult->value.setIsCaptured();
}
void VariableEnvironment::markVariableAsCaptured(const RefPtr<UniquedStringImpl>& identifier)
{
auto findResult = m_map.find(identifier);
RELEASE_ASSERT(findResult != m_map.end());
findResult->value.setIsCaptured();
}
void VariableEnvironment::markAllVariablesAsCaptured()
{
if (m_isEverythingCaptured)
return;
m_isEverythingCaptured = true; for (auto iter = m_map.begin(), end = m_map.end(); iter != end; ++iter)
iter->value.setIsCaptured();
}
bool VariableEnvironment::hasCapturedVariables() const
{
if (m_isEverythingCaptured)
return size() > 0;
for (auto entry : m_map) {
if (entry.value.isCaptured())
return true;
}
return false;
}
bool VariableEnvironment::captures(UniquedStringImpl* identifier) const
{
if (m_isEverythingCaptured)
return true;
auto findResult = m_map.find(identifier);
if (findResult == m_map.end())
return false;
return findResult->value.isCaptured();
}
void VariableEnvironment::swap(VariableEnvironment& other)
{
m_map.swap(other.m_map);
m_isEverythingCaptured = other.m_isEverythingCaptured;
}
void VariableEnvironment::markVariableAsImported(const RefPtr<UniquedStringImpl>& identifier)
{
auto findResult = m_map.find(identifier);
RELEASE_ASSERT(findResult != m_map.end());
findResult->value.setIsImported();
}
void VariableEnvironment::markVariableAsExported(const RefPtr<UniquedStringImpl>& identifier)
{
auto findResult = m_map.find(identifier);
RELEASE_ASSERT(findResult != m_map.end());
findResult->value.setIsExported();
}
}