mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibCpp: Support for parsing c-style fixed arrays (arr[2])
Also adds tests for finding declaration of arrays inside CppComprehension which requires proper parsing for passing. Side-effect of this patch: if we ctrl+click on array variables, it should jump to the correct declaration inside HackStudio.
This commit is contained in:
parent
34b04271f4
commit
ac435f914c
7 changed files with 184 additions and 8 deletions
|
@ -434,6 +434,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_name() const override { return true; }
|
||||
virtual bool is_templatized() const { return false; }
|
||||
virtual bool is_sized() const { return false; }
|
||||
|
||||
Name(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
|
@ -453,6 +454,25 @@ private:
|
|||
mutable Optional<DeprecatedString> m_full_name;
|
||||
};
|
||||
|
||||
class SizedName : public Name {
|
||||
public:
|
||||
virtual ~SizedName() override = default;
|
||||
virtual StringView class_name() const override { return "SizedName"sv; }
|
||||
virtual bool is_sized() const override { return true; }
|
||||
void dump(FILE* output, size_t indent) const override;
|
||||
|
||||
SizedName(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Name(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
void append_dimension(StringView dim) { m_dimensions.append(dim); };
|
||||
|
||||
private:
|
||||
Vector<StringView> m_dimensions;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
};
|
||||
|
||||
class TemplatizedName : public Name {
|
||||
public:
|
||||
virtual ~TemplatizedName() override = default;
|
||||
|
@ -1020,5 +1040,6 @@ template<>
|
|||
inline bool ASTNode::fast_is<NamedType>() const { return is_type() && verify_cast<Type>(*this).is_named_type(); }
|
||||
template<>
|
||||
inline bool ASTNode::fast_is<TemplatizedName>() const { return is_name() && verify_cast<Name>(*this).is_templatized(); }
|
||||
|
||||
template<>
|
||||
inline bool ASTNode::fast_is<SizedName>() const { return is_name() && verify_cast<Name>(*this).is_sized(); }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue