diff --git a/src/apps/debugger/source_language/CppLanguage.cpp b/src/apps/debugger/source_language/CppLanguage.cpp index 2aa19301de..249ef91169 100644 --- a/src/apps/debugger/source_language/CppLanguage.cpp +++ b/src/apps/debugger/source_language/CppLanguage.cpp @@ -1,12 +1,14 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #include "CppLanguage.h" +#include + #include "TeamTypeInformation.h" #include "Type.h" #include "TypeLookupConstraints.h" @@ -39,6 +41,7 @@ CppLanguage::ParseTypeExpression(const BString &expression, BString parsedName = expression; BString baseTypeName; + BString arraySpecifier; parsedName.RemoveAll(" "); int32 modifierIndex = -1; @@ -53,6 +56,12 @@ CppLanguage::ParseTypeExpression(const BString &expression, } else baseTypeName = parsedName; + modifierIndex = parsedName.FindFirst('['); + if (modifierIndex >= 0) { + parsedName.MoveInto(arraySpecifier, modifierIndex, + parsedName.Length() - modifierIndex); + } + result = info->LookupTypeByName(baseTypeName, TypeLookupConstraints(), baseType); if (result != B_OK) @@ -101,6 +110,37 @@ CppLanguage::ParseTypeExpression(const BString &expression, } 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(size, true, + arrayType); + } else { + result = arrayType->CreateDerivedArrayType(size, true, + arrayType); + } + + if (result != B_OK) + return result; + + typeRef.SetTo(arrayType, true); + + startIndex = arraySpecifier.FindFirst('[', startIndex + 1); + + } while (startIndex >= 0); + + _resultType = arrayType; + } + typeRef.Detach(); return result;