void InspectorWindow::ExpressionEvaluated(ExpressionInfo* info, status_t result, ExpressionResult* value) { BMessage message(MSG_EXPRESSION_EVALUATED); message.AddInt32("result", result); BReference<ExpressionResult> reference; if (value != NULL) { reference.SetTo(value); message.AddPointer("value", value); } if (PostMessage(&message) == B_OK) reference.Detach(); }
status_t DwarfType::CreateDerivedArrayType(int64 lowerBound, int64 elementCount, bool extendExisting, ArrayType*& _resultType) { DwarfArrayType* resultType = NULL; BReference<DwarfType> baseTypeReference; if (extendExisting) resultType = dynamic_cast<DwarfArrayType*>(this); if (resultType == NULL) { resultType = new(std::nothrow) DwarfArrayType(fTypeContext, fName, NULL, this); baseTypeReference.SetTo(resultType, true); } if (resultType == NULL) return B_NO_MEMORY; DwarfSubrangeType* subrangeType = new(std::nothrow) DwarfSubrangeType( fTypeContext, fName, NULL, resultType, BVariant(lowerBound), BVariant(lowerBound + elementCount - 1)); if (subrangeType == NULL) return B_NO_MEMORY; BReference<DwarfSubrangeType> subrangeReference(subrangeType, true); DwarfArrayDimension* dimension = new(std::nothrow) DwarfArrayDimension( subrangeType); if (dimension == NULL) return B_NO_MEMORY; BReference<DwarfArrayDimension> dimensionReference(dimension, true); if (!resultType->AddDimension(dimension)) return B_NO_MEMORY; baseTypeReference.Detach(); _resultType = resultType; return B_OK; }
status_t CLanguageFamily::ParseTypeExpression(const BString& expression, TeamTypeInformation* info, Type*& _resultType) const { status_t result = B_OK; Type* baseType = NULL; BString parsedName = expression; BString baseTypeName; BString arraySpecifier; parsedName.RemoveAll(" "); int32 modifierIndex = -1; modifierIndex = parsedName.FindFirst('*'); if (modifierIndex == -1) modifierIndex = parsedName.FindFirst('&'); if (modifierIndex == -1) modifierIndex = parsedName.FindFirst('['); if (modifierIndex == -1) modifierIndex = parsedName.Length(); parsedName.MoveInto(baseTypeName, 0, modifierIndex); modifierIndex = parsedName.FindFirst('['); if (modifierIndex >= 0) { parsedName.MoveInto(arraySpecifier, modifierIndex, parsedName.Length() - modifierIndex); } result = info->LookupTypeByName(baseTypeName, TypeLookupConstraints(), baseType); if (result != B_OK) return result; BReference<Type> typeRef; typeRef.SetTo(baseType, true); if (!parsedName.IsEmpty()) { AddressType* derivedType = NULL; // walk the list of modifiers trying to add each. for (int32 i = 0; i < parsedName.Length(); i++) { if (!IsModifierValid(parsedName[i])) return B_BAD_VALUE; address_type_kind typeKind; switch (parsedName[i]) { case '*': { typeKind = DERIVED_TYPE_POINTER; break; } case '&': { typeKind = DERIVED_TYPE_REFERENCE; break; } default: { return B_BAD_VALUE; } } if (derivedType == NULL) { result = baseType->CreateDerivedAddressType(typeKind, derivedType); } else { result = derivedType->CreateDerivedAddressType(typeKind, derivedType); } if (result != B_OK) return result; typeRef.SetTo(derivedType, true); } _resultType = derivedType; } else _resultType = baseType; if (!arraySpecifier.IsEmpty()) { ArrayType* arrayType = NULL; int32 startIndex = 1; do { int32 size = strtoul(arraySpecifier.String() + startIndex, NULL, 10); if (size < 0) return B_ERROR; if (arrayType == NULL) { result = _resultType->CreateDerivedArrayType(0, size, true, arrayType); } else { result = arrayType->CreateDerivedArrayType(0, size, true, arrayType); } if (result != B_OK) return result; typeRef.SetTo(arrayType, true); startIndex = arraySpecifier.FindFirst('[', startIndex + 1); } while (startIndex >= 0); // since a C/C++ array is essentially pointer math, // the resulting array has to be wrapped in a pointer to // ensure the element addresses wind up being against the // correct address. AddressType* addressType = NULL; result = arrayType->CreateDerivedAddressType(DERIVED_TYPE_POINTER, addressType); if (result != B_OK) return result; _resultType = addressType; } typeRef.Detach(); return result; }
status_t CppLanguage::ParseTypeExpression(const BString &expression, TeamTypeInformation* info, Type*& _resultType) const { status_t result = B_OK; Type* baseType = NULL; BString parsedName = expression; BString baseTypeName; parsedName.RemoveAll(" "); int32 modifierIndex = -1; for (int32 i = parsedName.Length() - 1; i >= 0; i--) { if (parsedName[i] == '*' || parsedName[i] == '&') modifierIndex = i; } if (modifierIndex >= 0) { parsedName.CopyInto(baseTypeName, 0, modifierIndex); parsedName.Remove(0, modifierIndex); } else baseTypeName = parsedName; result = info->LookupTypeByName(baseTypeName, TypeLookupConstraints(), baseType); if (result != B_OK) return result; BReference<Type> typeRef; typeRef.SetTo(baseType, true); if (!parsedName.IsEmpty()) { AddressType* derivedType = NULL; // walk the list of modifiers trying to add each. for (int32 i = 0; i < parsedName.Length(); i++) { address_type_kind typeKind; switch (parsedName[i]) { case '*': { typeKind = DERIVED_TYPE_POINTER; break; } case '&': { typeKind = DERIVED_TYPE_REFERENCE; break; } default: { return B_BAD_VALUE; } } if (derivedType == NULL) { result = baseType->CreateDerivedAddressType(typeKind, derivedType); } else { result = derivedType->CreateDerivedAddressType(typeKind, derivedType); } if (result != B_OK) return result; typeRef.SetTo(derivedType, true); } _resultType = derivedType; } else _resultType = baseType; typeRef.Detach(); return result; }
bool UpdateBreakpoint(BreakpointProxy* proxy) { if (fTeam == NULL) { for (int32 i = 0; BreakpointProxy* proxy = fBreakpointProxies.ItemAt(i); i++) { proxy->ReleaseReference(); } fBreakpointProxies.MakeEmpty(); return true; } AutoLocker<Team> locker(fTeam); UserBreakpointList::ConstIterator it = fTeam->UserBreakpoints().GetIterator(); int32 watchpointIndex = 0; UserBreakpoint* newBreakpoint = it.Next(); Watchpoint* newWatchpoint = fTeam->WatchpointAt(watchpointIndex); int32 index = 0; bool remove; // remove no longer existing breakpoints while (BreakpointProxy* oldProxy = fBreakpointProxies.ItemAt(index)) { remove = false; switch (oldProxy->Type()) { case BREAKPOINT_PROXY_TYPE_BREAKPOINT: { UserBreakpoint* breakpoint = oldProxy->GetBreakpoint(); if (breakpoint == newBreakpoint) { if (breakpoint == proxy->GetBreakpoint()) NotifyRowsChanged(index, 1); ++index; newBreakpoint = it.Next(); } else remove = true; } break; case BREAKPOINT_PROXY_TYPE_WATCHPOINT: { Watchpoint* watchpoint = oldProxy->GetWatchpoint(); if (watchpoint == newWatchpoint) { if (watchpoint == proxy->GetWatchpoint()) NotifyRowsChanged(index, 1); ++watchpointIndex; ++index; newWatchpoint = fTeam->WatchpointAt(watchpointIndex); } else remove = true; } break; } if (remove) { // TODO: Not particularly efficient! fBreakpointProxies.RemoveItemAt(index); oldProxy->ReleaseReference(); NotifyRowsRemoved(index, 1); } } // add new breakpoints int32 countBefore = fBreakpointProxies.CountItems(); BreakpointProxy* newProxy = NULL; BReference<BreakpointProxy> proxyReference; while (newBreakpoint != NULL) { newProxy = new(std::nothrow) BreakpointProxy(newBreakpoint, NULL); if (newProxy == NULL) return false; proxyReference.SetTo(newProxy, true); if (!fBreakpointProxies.AddItem(newProxy)) return false; proxyReference.Detach(); newBreakpoint = it.Next(); } // add new watchpoints while (newWatchpoint != NULL) { newProxy = new(std::nothrow) BreakpointProxy(NULL, newWatchpoint); if (newProxy == NULL) return false; proxyReference.SetTo(newProxy, true); if (!fBreakpointProxies.AddItem(newProxy)) return false; proxyReference.Detach(); newWatchpoint = fTeam->WatchpointAt(++watchpointIndex); } int32 count = fBreakpointProxies.CountItems(); if (count > countBefore) NotifyRowsAdded(countBefore, count - countBefore); return true; }