haiku/headers/private/debugger/value/value_nodes/ArrayValueNode.h

143 lines
3.5 KiB
C
Raw Normal View History

* EnumerationValue -> EnumeratorValue * Since some types don't have names (e.g. pointer types or anonymous structs or unions), each type does now also have a unique ID. The global type cache registers types by ID and by name (if they have one). This fixes clashes of types with empty names. * Completely refactored the code dealing with variable values. Formerly we had Variable and TypeComponentPath to navigate to a component, mapped to a BVariant representing the value. Now we have: * Interface Value with various subclasses (BoolValue, IntegerValue, etc.) to represent a value, with the flexibility for more esoteric values. * A tree of ValueNode+ValueNodeChild objects to represent the components of a variable. On top of each ValueNodeChild sits a ValueNode representing the value of the component, potentially having ValueNodeChild children. This should allow casting a component value, simply by replacing its ValueNode. * Interface ValueHandler and various implementations for the different value types. It is basically a factory for classes allowing to format/display a value. * ValueHandlerRoster -- a registry for ValueHandlers, finding the best one for a given value. * Interface TypeHandler and various implementions for the different type kinds (primitive, compound, address, etc.). It is basically a factory for ValueNodes for that type. * TypeHandlerRoster -- a registry for TypeHandlers, finding the best one for a given type. That's still a bit work in progress. It introduces at least one regression: The VariablesView doesn't save/restore its state anymore. Will take a while until that is added back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 21:15:21 +03:00
/*
* Copyright 2013-2015, Rene Gollent, rene@gollent.com.
* EnumerationValue -> EnumeratorValue * Since some types don't have names (e.g. pointer types or anonymous structs or unions), each type does now also have a unique ID. The global type cache registers types by ID and by name (if they have one). This fixes clashes of types with empty names. * Completely refactored the code dealing with variable values. Formerly we had Variable and TypeComponentPath to navigate to a component, mapped to a BVariant representing the value. Now we have: * Interface Value with various subclasses (BoolValue, IntegerValue, etc.) to represent a value, with the flexibility for more esoteric values. * A tree of ValueNode+ValueNodeChild objects to represent the components of a variable. On top of each ValueNodeChild sits a ValueNode representing the value of the component, potentially having ValueNodeChild children. This should allow casting a component value, simply by replacing its ValueNode. * Interface ValueHandler and various implementations for the different value types. It is basically a factory for classes allowing to format/display a value. * ValueHandlerRoster -- a registry for ValueHandlers, finding the best one for a given value. * Interface TypeHandler and various implementions for the different type kinds (primitive, compound, address, etc.). It is basically a factory for ValueNodes for that type. * TypeHandlerRoster -- a registry for TypeHandlers, finding the best one for a given type. That's still a bit work in progress. It introduces at least one regression: The VariablesView doesn't save/restore its state anymore. Will take a while until that is added back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 21:15:21 +03:00
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef ARRAY_VALUE_NODE_H
#define ARRAY_VALUE_NODE_H
#include <ObjectList.h>
#include "ValueNode.h"
class AbstractArrayValueNodeChild;
class ArrayType;
class AbstractArrayValueNode : public ValueNode {
public:
AbstractArrayValueNode(
ValueNodeChild* nodeChild, ArrayType* type,
int32 dimension);
virtual ~AbstractArrayValueNode();
ArrayType* GetArrayType() const
{ return fType; }
int32 Dimension() const
{ return fDimension; }
virtual Type* GetType() const;
virtual status_t ResolvedLocationAndValue(
ValueLoader* valueLoader,
ValueLocation*& _location,
Value*& _value);
// locking required
virtual status_t CreateChildren(TeamTypeInformation* info);
* EnumerationValue -> EnumeratorValue * Since some types don't have names (e.g. pointer types or anonymous structs or unions), each type does now also have a unique ID. The global type cache registers types by ID and by name (if they have one). This fixes clashes of types with empty names. * Completely refactored the code dealing with variable values. Formerly we had Variable and TypeComponentPath to navigate to a component, mapped to a BVariant representing the value. Now we have: * Interface Value with various subclasses (BoolValue, IntegerValue, etc.) to represent a value, with the flexibility for more esoteric values. * A tree of ValueNode+ValueNodeChild objects to represent the components of a variable. On top of each ValueNodeChild sits a ValueNode representing the value of the component, potentially having ValueNodeChild children. This should allow casting a component value, simply by replacing its ValueNode. * Interface ValueHandler and various implementations for the different value types. It is basically a factory for classes allowing to format/display a value. * ValueHandlerRoster -- a registry for ValueHandlers, finding the best one for a given value. * Interface TypeHandler and various implementions for the different type kinds (primitive, compound, address, etc.). It is basically a factory for ValueNodes for that type. * TypeHandlerRoster -- a registry for TypeHandlers, finding the best one for a given type. That's still a bit work in progress. It introduces at least one regression: The VariablesView doesn't save/restore its state anymore. Will take a while until that is added back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 21:15:21 +03:00
virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const;
virtual bool IsRangedContainer() const;
virtual void ClearChildren();
virtual status_t CreateChildrenInRange(
TeamTypeInformation* info,
int32 lowIndex, int32 highIndex);
virtual status_t SupportedChildRange(int32& lowIndex,
int32& highIndex) const;
* EnumerationValue -> EnumeratorValue * Since some types don't have names (e.g. pointer types or anonymous structs or unions), each type does now also have a unique ID. The global type cache registers types by ID and by name (if they have one). This fixes clashes of types with empty names. * Completely refactored the code dealing with variable values. Formerly we had Variable and TypeComponentPath to navigate to a component, mapped to a BVariant representing the value. Now we have: * Interface Value with various subclasses (BoolValue, IntegerValue, etc.) to represent a value, with the flexibility for more esoteric values. * A tree of ValueNode+ValueNodeChild objects to represent the components of a variable. On top of each ValueNodeChild sits a ValueNode representing the value of the component, potentially having ValueNodeChild children. This should allow casting a component value, simply by replacing its ValueNode. * Interface ValueHandler and various implementations for the different value types. It is basically a factory for classes allowing to format/display a value. * ValueHandlerRoster -- a registry for ValueHandlers, finding the best one for a given value. * Interface TypeHandler and various implementions for the different type kinds (primitive, compound, address, etc.). It is basically a factory for ValueNodes for that type. * TypeHandlerRoster -- a registry for TypeHandlers, finding the best one for a given type. That's still a bit work in progress. It introduces at least one regression: The VariablesView doesn't save/restore its state anymore. Will take a while until that is added back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 21:15:21 +03:00
protected:
typedef BObjectList<AbstractArrayValueNodeChild> ChildList;
protected:
ArrayType* fType;
ChildList fChildren;
int32 fDimension;
int32 fLowerBound;
int32 fUpperBound;
bool fBoundsInitialized;
* EnumerationValue -> EnumeratorValue * Since some types don't have names (e.g. pointer types or anonymous structs or unions), each type does now also have a unique ID. The global type cache registers types by ID and by name (if they have one). This fixes clashes of types with empty names. * Completely refactored the code dealing with variable values. Formerly we had Variable and TypeComponentPath to navigate to a component, mapped to a BVariant representing the value. Now we have: * Interface Value with various subclasses (BoolValue, IntegerValue, etc.) to represent a value, with the flexibility for more esoteric values. * A tree of ValueNode+ValueNodeChild objects to represent the components of a variable. On top of each ValueNodeChild sits a ValueNode representing the value of the component, potentially having ValueNodeChild children. This should allow casting a component value, simply by replacing its ValueNode. * Interface ValueHandler and various implementations for the different value types. It is basically a factory for classes allowing to format/display a value. * ValueHandlerRoster -- a registry for ValueHandlers, finding the best one for a given value. * Interface TypeHandler and various implementions for the different type kinds (primitive, compound, address, etc.). It is basically a factory for ValueNodes for that type. * TypeHandlerRoster -- a registry for TypeHandlers, finding the best one for a given type. That's still a bit work in progress. It introduces at least one regression: The VariablesView doesn't save/restore its state anymore. Will take a while until that is added back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 21:15:21 +03:00
};
// TODO: Are ArrayValueNode and InternalArrayValueNode still needed?
class ArrayValueNode : public AbstractArrayValueNode {
public:
ArrayValueNode(ValueNodeChild* nodeChild,
ArrayType* type);
virtual ~ArrayValueNode();
};
class InternalArrayValueNode : public AbstractArrayValueNode {
public:
InternalArrayValueNode(
ValueNodeChild* nodeChild,
ArrayType* type, int32 dimension);
virtual ~InternalArrayValueNode();
};
class AbstractArrayValueNodeChild : public ValueNodeChild {
public:
AbstractArrayValueNodeChild(
AbstractArrayValueNode* parent,
const BString& name, int64 elementIndex);
virtual ~AbstractArrayValueNodeChild();
AbstractArrayValueNode* ArrayParent() const { return fParent; }
int32 ElementIndex() const { return fElementIndex; }
virtual const BString& Name() const;
virtual ValueNode* Parent() const;
protected:
AbstractArrayValueNode* fParent;
BString fName;
int64 fElementIndex;
};
class ArrayValueNodeChild : public AbstractArrayValueNodeChild {
public:
ArrayValueNodeChild(
AbstractArrayValueNode* parent,
const BString& name, int64 elementIndex,
Type* type);
virtual ~ArrayValueNodeChild();
virtual Type* GetType() const;
virtual status_t ResolveLocation(ValueLoader* valueLoader,
ValueLocation*& _location);
private:
Type* fType;
};
class InternalArrayValueNodeChild : public AbstractArrayValueNodeChild {
public:
InternalArrayValueNodeChild(
AbstractArrayValueNode* parent,
const BString& name, int64 elementIndex,
ArrayType* type);
virtual ~InternalArrayValueNodeChild();
virtual Type* GetType() const;
virtual bool IsInternal() const;
virtual status_t CreateInternalNode(ValueNode*& _node);
virtual status_t ResolveLocation(ValueLoader* valueLoader,
ValueLocation*& _location);
private:
ArrayType* fType;
};
#endif // ARRAY_VALUE_NODE_H