void DebugManager::UpdateConsoleScope(DynamicObject* copyFromScope, ScriptContext* scriptContext) { Assert(copyFromScope != nullptr); DynamicObject* consoleScope = this->GetConsoleScope(scriptContext); Js::RecyclableObject* recyclableObject = Js::RecyclableObject::FromVar(copyFromScope); ulong newPropCount = recyclableObject->GetPropertyCount(); for (ulong i = 0; i < newPropCount; i++) { Js::PropertyId propertyId = recyclableObject->GetPropertyId((Js::PropertyIndex)i); // For deleted properties we won't have a property id if (propertyId != Js::Constants::NoProperty) { Js::PropertyValueInfo propertyValueInfo; Var propertyValue; BOOL gotPropertyValue = recyclableObject->GetProperty(recyclableObject, propertyId, &propertyValue, &propertyValueInfo, scriptContext); AssertMsg(gotPropertyValue, "DebugManager::UpdateConsoleScope Should have got valid value?"); OUTPUT_TRACE(Js::ConsoleScopePhase, _u("Adding property '%s'\n"), scriptContext->GetPropertyName(propertyId)->GetBuffer()); BOOL updateSuccess = consoleScope->SetPropertyWithAttributes(propertyId, propertyValue, propertyValueInfo.GetAttributes(), &propertyValueInfo); AssertMsg(updateSuccess, "DebugManager::UpdateConsoleScope Unable to update property value. Am I missing a scenario?"); } } OUTPUT_TRACE(Js::ConsoleScopePhase, _u("Number of properties on console scope object after update are %d\n"), consoleScope->GetPropertyCount()); }
Var JsBuiltInEngineInterfaceExtensionObject::EntryJsBuiltIn_Internal_InitInternalProperties(RecyclableObject *function, CallInfo callInfo, ...) { EngineInterfaceObject_CommonFunctionProlog(function, callInfo); DynamicObject* obj = DynamicObject::FromVar(args.Values[1]); unsigned propCount = TaggedInt::ToUInt32(args.Values[2]); Assert(callInfo.Count == 3 + propCount); for (unsigned i = 0; i < propCount; i++) { JavascriptString *propName = JavascriptString::FromVar(args.Values[i + 3]); obj->SetPropertyWithAttributes(JavascriptOperators::GetPropertyId(propName, scriptContext), scriptContext->GetLibrary()->GetNull(), PropertyWritable, nullptr); } return obj; }