本文整理汇总了C++中GetScriptContext函数的典型用法代码示例。如果您正苦于以下问题:C++ GetScriptContext函数的具体用法?C++ GetScriptContext怎么用?C++ GetScriptContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetScriptContext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScriptContext
void RegexPattern::Finalize(bool isShutdown)
{
if(isShutdown)
return;
const auto scriptContext = GetScriptContext();
if(!scriptContext)
return;
#if DBG
if(!isLiteral && !scriptContext->IsClosed())
{
const auto source = GetSource();
RegexPattern *p;
Assert(
!GetScriptContext()->GetDynamicRegexMap()->TryGetValue(
RegexKey(source.GetBuffer(), source.GetLength(), GetFlags()),
&p) || ( source.GetLength() == 0 ) ||
p != this);
}
#endif
if(isShallowClone)
return;
rep.unified.program->FreeBody(scriptContext->RegexAllocator());
}
示例2: switch
BOOL JavascriptRegExpConstructor::DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags)
{
switch (propertyId)
{
// all globals are 'fNoDelete' in V5.8
case PropertyIds::input:
case PropertyIds::$_:
case PropertyIds::lastMatch:
case PropertyIds::$Ampersand:
case PropertyIds::lastParen:
case PropertyIds::$Plus:
case PropertyIds::leftContext:
case PropertyIds::$BackTick:
case PropertyIds::rightContext:
case PropertyIds::$Tick:
case PropertyIds::$1:
case PropertyIds::$2:
case PropertyIds::$3:
case PropertyIds::$4:
case PropertyIds::$5:
case PropertyIds::$6:
case PropertyIds::$7:
case PropertyIds::$8:
case PropertyIds::$9:
case PropertyIds::index:
JavascriptError::ThrowCantDeleteIfStrictMode(flags, GetScriptContext(), GetScriptContext()->GetPropertyName(propertyId)->GetBuffer());
return false;
default:
return JavascriptFunction::DeleteProperty(propertyId, flags);
}
}
示例3: ArrayBufferBase
SharedArrayBuffer::SharedArrayBuffer(uint32 length, DynamicType * type, Allocator allocator) :
ArrayBufferBase(type), sharedContents(nullptr)
{
BYTE * buffer = nullptr;
if (length > MaxSharedArrayBufferLength)
{
JavascriptError::ThrowTypeError(GetScriptContext(), JSERR_FunctionArgument_Invalid);
}
else if (length > 0)
{
Recycler* recycler = GetType()->GetLibrary()->GetRecycler();
if (recycler->ReportExternalMemoryAllocation(length))
{
buffer = (BYTE*)allocator(length);
if (buffer == nullptr)
{
recycler->ReportExternalMemoryFree(length);
}
}
if (buffer == nullptr)
{
recycler->CollectNow<CollectOnTypedArrayAllocation>();
if (recycler->ReportExternalMemoryAllocation(length))
{
buffer = (BYTE*)allocator(length);
if (buffer == nullptr)
{
recycler->ReportExternalMemoryFailure(length);
}
}
else
{
JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
}
}
if (buffer != nullptr)
{
ZeroMemory(buffer, length);
sharedContents = HeapNew(SharedContents, buffer, length);
if (sharedContents == nullptr)
{
recycler->ReportExternalMemoryFailure(length);
// What else could we do?
JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
}
#if DBG
sharedContents->AddAgent((DWORD_PTR)GetScriptContext());
#endif
}
}
}
示例4: GetScriptContext
void ArrayObject::ThrowItemNotConfigurableError(PropertyId propId /*= Constants::NoProperty*/)
{
ScriptContext* scriptContext = GetScriptContext();
JavascriptError::ThrowTypeError(scriptContext, JSERR_DefineProperty_NotConfigurable,
propId != Constants::NoProperty ?
scriptContext->GetThreadContext()->GetPropertyName(propId)->GetBuffer() : nullptr);
}
示例5: GetScriptContext
BOOL JavascriptStringObject::GetProperty(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext)
{
BOOL result;
if (GetPropertyBuiltIns(propertyId, value, requestContext, &result))
{
return result;
}
if (DynamicObject::GetProperty(originalInstance, propertyId, value, info, requestContext))
{
return true;
}
// For NumericPropertyIds check that index is less than JavascriptString length
ScriptContext*scriptContext = GetScriptContext();
uint32 index;
if (scriptContext->IsNumericPropertyId(propertyId, &index))
{
JavascriptString* str = JavascriptString::FromVar(CrossSite::MarshalVar(requestContext, this->InternalUnwrap()));
return str->GetItemAt(index, value);
}
*value = requestContext->GetMissingPropertyResult();
return false;
}
示例6: GetScriptContext
PropertyQueryFlags JavascriptStringObject::GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext)
{
BOOL result;
if (GetPropertyBuiltIns(propertyId, value, requestContext, &result))
{
return JavascriptConversion::BooleanToPropertyQueryFlags(result);
}
if (JavascriptConversion::PropertyQueryFlagsToBoolean(DynamicObject::GetPropertyQuery(originalInstance, propertyId, value, info, requestContext)))
{
return PropertyQueryFlags::Property_Found;
}
// For NumericPropertyIds check that index is less than JavascriptString length
ScriptContext*scriptContext = GetScriptContext();
uint32 index;
if (scriptContext->IsNumericPropertyId(propertyId, &index))
{
JavascriptString* str = this->InternalUnwrap();
str = JavascriptString::FromVar(CrossSite::MarshalVar(requestContext, str, scriptContext));
return JavascriptConversion::BooleanToPropertyQueryFlags(str->GetItemAt(index, value));
}
*value = requestContext->GetMissingPropertyResult();
return PropertyQueryFlags::Property_NotFound;
}
示例7: Assert
BOOL ForInObjectEnumerator::GetCurrentEnumerator()
{
Assert(object);
ScriptContext* scriptContext = GetScriptContext();
if (VirtualTableInfo<DynamicObject>::HasVirtualTable(object))
{
DynamicObject* dynamicObject = (DynamicObject*)object;
if (!dynamicObject->GetTypeHandler()->EnsureObjectReady(dynamicObject))
{
return false;
}
dynamicObject->GetDynamicType()->PrepareForTypeSnapshotEnumeration();
embeddedEnumerator.Initialize(dynamicObject, true);
currentEnumerator = &embeddedEnumerator;
return true;
}
if (!object->GetEnumerator(TRUE /*enumNonEnumerable*/, (Var *)¤tEnumerator, scriptContext, true /*preferSnapshotSemantics */, enumSymbols))
{
currentEnumerator = scriptContext->GetLibrary()->GetNullEnumerator();
return false;
}
return true;
}
示例8: GetLdElemInlineCache
PolymorphicInlineCache * PropertyString::CreateBiggerPolymorphicInlineCache(bool isLdElem)
{
PolymorphicInlineCache * polymorphicInlineCache = isLdElem ? GetLdElemInlineCache() : GetStElemInlineCache();
Assert(polymorphicInlineCache && polymorphicInlineCache->CanAllocateBigger());
uint16 polymorphicInlineCacheSize = polymorphicInlineCache->GetSize();
uint16 newPolymorphicInlineCacheSize = PolymorphicInlineCache::GetNextSize(polymorphicInlineCacheSize);
Assert(newPolymorphicInlineCacheSize > polymorphicInlineCacheSize);
PolymorphicInlineCache * newPolymorphicInlineCache = ScriptContextPolymorphicInlineCache::New(newPolymorphicInlineCacheSize, GetLibrary());
polymorphicInlineCache->CopyTo(this->propertyRecord->GetPropertyId(), GetScriptContext(), newPolymorphicInlineCache);
if (isLdElem)
{
this->ldElemInlineCache = newPolymorphicInlineCache;
}
else
{
this->stElemInlineCache = newPolymorphicInlineCache;
}
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS
if (PHASE_VERBOSE_TRACE1(Js::PolymorphicInlineCachePhase) || PHASE_TRACE1(PropertyStringCachePhase))
{
Output::Print(_u("PropertyString '%s' : Bigger PIC, oldSize = %d, newSize = %d\n"), GetString(), polymorphicInlineCacheSize, newPolymorphicInlineCacheSize);
}
#endif
return newPolymorphicInlineCache;
}
示例9: propertyDescriptor
BOOL ModuleNamespace::FindNextProperty(BigPropertyIndex& index, JavascriptString** propertyString, PropertyId* propertyId, PropertyAttributes* attributes) const
{
if (index < propertyMap->Count())
{
SimpleDictionaryPropertyDescriptor<BigPropertyIndex> propertyDescriptor(propertyMap->GetValueAt(index));
Assert(propertyDescriptor.Attributes == PropertyModuleNamespaceDefault);
const PropertyRecord* propertyRecord = propertyMap->GetKeyAt(index);
*propertyId = propertyRecord->GetPropertyId();
if (propertyString != nullptr)
{
*propertyString = GetScriptContext()->GetPropertyString(*propertyId);
}
if (attributes != nullptr)
{
*attributes = propertyDescriptor.Attributes;
}
return TRUE;
}
else
{
*propertyId = Constants::NoProperty;
if (propertyString != nullptr)
{
*propertyString = nullptr;
}
}
return FALSE;
}
示例10: GetScriptContext
// We will make sure the iterator will iterate through the exported properties in sorted order.
// There is no such requirement for enumerator (forin).
ListForListIterator* ModuleNamespace::EnsureSortedExportedNames()
{
if (sortedExportedNames == nullptr)
{
ExportedNames* exportedNames = moduleRecord->GetExportedNames(nullptr);
ScriptContext* scriptContext = GetScriptContext();
sortedExportedNames = ListForListIterator::New(scriptContext->GetRecycler());
exportedNames->Map([&](PropertyId propertyId) {
JavascriptString* propertyString = scriptContext->GetPropertyString(propertyId);
sortedExportedNames->Add(propertyString);
});
sortedExportedNames->Sort([](void* context, const void* left, const void* right) ->int {
JavascriptString** leftString = (JavascriptString**) (left);
JavascriptString** rightString = (JavascriptString**) (right);
if (JavascriptString::LessThan(*leftString, *rightString))
{
return -1;
}
if (JavascriptString::LessThan(*rightString, *leftString))
{
return 1;
}
return 0;
}, nullptr);
}
return sortedExportedNames;
}
示例11: ENTER_PINNED_SCOPE
BOOL JavascriptNumberObject::GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
{
ENTER_PINNED_SCOPE(JavascriptString, valueStr);
valueStr = JavascriptNumber::ToStringRadix10(this->GetValue(), GetScriptContext());
stringBuilder->Append(valueStr->GetString(), valueStr->GetLength());
LEAVE_PINNED_SCOPE();
return TRUE;
}
示例12: GetScriptContext
void JavascriptSet::Add(Var value)
{
if (!set->ContainsKey(value))
{
SetDataNode* node = list.Append(value, GetScriptContext()->GetRecycler());
set->Add(value, node);
}
}
示例13: Init
BOOL ModuleNamespaceEnumerator::Init()
{
if (!nsObject->DynamicObject::GetEnumerator(&symbolEnumerator, flags, GetScriptContext()))
{
return FALSE;
}
nonLocalMap = nsObject->GetUnambiguousNonLocalExports();
Reset();
return TRUE;
}
示例14:
bool ES5Array::GetPropertyBuiltIns(PropertyId propertyId, Var* value, BOOL* result)
{
if (propertyId == PropertyIds::length)
{
*value = JavascriptNumber::ToVar(this->GetLength(), GetScriptContext());
*result = true;
return true;
}
return false;
}
示例15: InitializeCurrentEnumerator
BOOL ForInObjectEnumerator::InitializeCurrentEnumerator(RecyclableObject * object, ForInCache * forInCache)
{
EnumeratorFlags flags = enumerator.GetFlags();
RecyclableObject * prototype = object->GetPrototype();
if (prototype == nullptr || prototype->GetTypeId() == TypeIds_Null)
{
// If this is the last object on the prototype chain, we don't need to get the non-enumerable properties any more to track shadowing
flags &= ~EnumeratorFlags::EnumNonEnumerable;
}
return InitializeCurrentEnumerator(object, flags, GetScriptContext(), forInCache);
}