mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -32,10 +32,10 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
|
||||
String qualifiers_string;
|
||||
DeprecatedString qualifiers_string;
|
||||
if (!m_qualifiers.is_empty()) {
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "[{}]", String::join(' ', m_qualifiers));
|
||||
outln(output, "[{}]", DeprecatedString::join(' ', m_qualifiers));
|
||||
}
|
||||
|
||||
m_return_type->dump(output, indent + 1);
|
||||
|
@ -75,22 +75,22 @@ void Type::dump(FILE* output, size_t indent) const
|
|||
outln(output, "{}", to_string());
|
||||
}
|
||||
|
||||
String NamedType::to_string() const
|
||||
DeprecatedString NamedType::to_string() const
|
||||
{
|
||||
String qualifiers_string;
|
||||
DeprecatedString qualifiers_string;
|
||||
if (!qualifiers().is_empty())
|
||||
qualifiers_string = String::formatted("[{}] ", String::join(' ', qualifiers()));
|
||||
qualifiers_string = DeprecatedString::formatted("[{}] ", DeprecatedString::join(' ', qualifiers()));
|
||||
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
if (is_auto())
|
||||
name = "auto";
|
||||
else
|
||||
name = m_name.is_null() ? ""sv : m_name->full_name();
|
||||
|
||||
return String::formatted("{}{}", qualifiers_string, name);
|
||||
return DeprecatedString::formatted("{}{}", qualifiers_string, name);
|
||||
}
|
||||
|
||||
String Pointer::to_string() const
|
||||
DeprecatedString Pointer::to_string() const
|
||||
{
|
||||
if (!m_pointee)
|
||||
return {};
|
||||
|
@ -100,7 +100,7 @@ String Pointer::to_string() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
String Reference::to_string() const
|
||||
DeprecatedString Reference::to_string() const
|
||||
{
|
||||
if (!m_referenced_type)
|
||||
return {};
|
||||
|
@ -113,7 +113,7 @@ String Reference::to_string() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
String FunctionType::to_string() const
|
||||
DeprecatedString FunctionType::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_return_type->to_string());
|
||||
|
@ -552,7 +552,7 @@ StringView Name::full_name() const
|
|||
builder.appendff("{}::", scope.name());
|
||||
}
|
||||
}
|
||||
m_full_name = String::formatted("{}{}", builder.to_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
m_full_name = DeprecatedString::formatted("{}{}", builder.to_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
return *m_full_name;
|
||||
}
|
||||
|
||||
|
@ -652,7 +652,7 @@ StringView Declaration::full_name() const
|
|||
if (m_name)
|
||||
m_full_name = m_name->full_name();
|
||||
else
|
||||
m_full_name = String::empty();
|
||||
m_full_name = DeprecatedString::empty();
|
||||
}
|
||||
|
||||
return *m_full_name;
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
virtual bool is_dummy_node() const { return false; }
|
||||
|
||||
protected:
|
||||
ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: m_parent(parent)
|
||||
, m_start(start)
|
||||
, m_end(end)
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
||||
|
||||
TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
virtual NonnullRefPtrVector<Declaration> declarations() const override;
|
||||
|
||||
protected:
|
||||
Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ public:
|
|||
void set_name(RefPtr<Name> name) { m_name = move(name); }
|
||||
|
||||
protected:
|
||||
Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<Name> m_name;
|
||||
mutable Optional<String> m_full_name;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
};
|
||||
|
||||
class InvalidDeclaration : public Declaration {
|
||||
|
@ -146,7 +146,7 @@ class InvalidDeclaration : public Declaration {
|
|||
public:
|
||||
virtual ~InvalidDeclaration() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidDeclaration"sv; }
|
||||
InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
virtual bool is_destructor() const { return false; }
|
||||
RefPtr<FunctionDefinition> definition() { return m_definition; }
|
||||
|
||||
FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public:
|
|||
Type const* type() const { return m_type.ptr(); }
|
||||
|
||||
protected:
|
||||
VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_parameter() const override { return true; }
|
||||
|
||||
Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, RefPtr<Name> name)
|
||||
Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, RefPtr<Name> name)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -228,7 +228,7 @@ public:
|
|||
virtual bool is_type() const override { return true; }
|
||||
virtual bool is_templatized() const { return false; }
|
||||
virtual bool is_named_type() const { return false; }
|
||||
virtual String to_string() const = 0;
|
||||
virtual DeprecatedString to_string() const = 0;
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
bool is_auto() const { return m_is_auto; }
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
void set_qualifiers(Vector<StringView>&& qualifiers) { m_qualifiers = move(qualifiers); }
|
||||
|
||||
protected:
|
||||
Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -251,10 +251,10 @@ class NamedType : public Type {
|
|||
public:
|
||||
virtual ~NamedType() override = default;
|
||||
virtual StringView class_name() const override { return "NamedType"sv; }
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
virtual bool is_named_type() const override { return true; }
|
||||
|
||||
NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -271,9 +271,9 @@ public:
|
|||
virtual ~Pointer() override = default;
|
||||
virtual StringView class_name() const override { return "Pointer"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -290,14 +290,14 @@ public:
|
|||
virtual ~Reference() override = default;
|
||||
virtual StringView class_name() const override { return "Reference"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
enum class Kind {
|
||||
Lvalue,
|
||||
Rvalue,
|
||||
};
|
||||
|
||||
Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, Kind kind)
|
||||
Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, Kind kind)
|
||||
: Type(parent, start, end, filename)
|
||||
, m_kind(kind)
|
||||
{
|
||||
|
@ -317,9 +317,9 @@ public:
|
|||
virtual ~FunctionType() override = default;
|
||||
virtual StringView class_name() const override { return "FunctionType"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public:
|
|||
virtual StringView class_name() const override { return "FunctionDefinition"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ class InvalidStatement : public Statement {
|
|||
public:
|
||||
virtual ~InvalidStatement() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidStatement"sv; }
|
||||
InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ public:
|
|||
virtual StringView class_name() const override { return "Expression"sv; }
|
||||
|
||||
protected:
|
||||
Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ class InvalidExpression : public Expression {
|
|||
public:
|
||||
virtual ~InvalidExpression() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidExpression"sv; }
|
||||
InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ public:
|
|||
virtual StringView class_name() const override { return "VariableDeclaration"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -409,12 +409,12 @@ public:
|
|||
virtual StringView class_name() const override { return "Identifier"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView name)
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StringView name)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Identifier(parent, start, end, filename, {})
|
||||
{
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ public:
|
|||
virtual bool is_name() const override { return true; }
|
||||
virtual bool is_templatized() const { return false; }
|
||||
|
||||
Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public:
|
|||
private:
|
||||
RefPtr<Identifier> m_name;
|
||||
NonnullRefPtrVector<Identifier> m_scope;
|
||||
mutable Optional<String> m_full_name;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
};
|
||||
|
||||
class TemplatizedName : public Name {
|
||||
|
@ -461,7 +461,7 @@ public:
|
|||
virtual bool is_templatized() const override { return true; }
|
||||
virtual StringView full_name() const override;
|
||||
|
||||
TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Name(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public:
|
|||
|
||||
private:
|
||||
NonnullRefPtrVector<Type> m_template_arguments;
|
||||
mutable Optional<String> m_full_name;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
};
|
||||
|
||||
class NumericLiteral : public Expression {
|
||||
|
@ -479,7 +479,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NumericLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView value)
|
||||
NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StringView value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -495,7 +495,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NullPointerLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ public:
|
|||
virtual StringView class_name() const override { return "BooleanLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, bool value)
|
||||
BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, bool value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -541,7 +541,7 @@ enum class BinaryOp {
|
|||
|
||||
class BinaryExpression : public Expression {
|
||||
public:
|
||||
BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ enum class AssignmentOp {
|
|||
|
||||
class AssignmentExpression : public Expression {
|
||||
public:
|
||||
AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ private:
|
|||
|
||||
class FunctionCall : public Expression {
|
||||
public:
|
||||
FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ private:
|
|||
|
||||
class StringLiteral final : public Expression {
|
||||
public:
|
||||
StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -627,11 +627,11 @@ public:
|
|||
virtual StringView class_name() const override { return "StringLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
String const& value() const { return m_value; }
|
||||
void set_value(String value) { m_value = move(value); }
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
void set_value(DeprecatedString value) { m_value = move(value); }
|
||||
|
||||
private:
|
||||
String m_value;
|
||||
DeprecatedString m_value;
|
||||
};
|
||||
|
||||
class ReturnStatement : public Statement {
|
||||
|
@ -639,7 +639,7 @@ public:
|
|||
virtual ~ReturnStatement() override = default;
|
||||
virtual StringView class_name() const override { return "ReturnStatement"sv; }
|
||||
|
||||
ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_enum() const override { return true; }
|
||||
|
||||
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ public:
|
|||
Class
|
||||
};
|
||||
|
||||
StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StructOrClassDeclaration::Type type)
|
||||
StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StructOrClassDeclaration::Type type)
|
||||
: Declaration(parent, start, end, filename)
|
||||
, m_type(type)
|
||||
{
|
||||
|
@ -726,7 +726,7 @@ enum class UnaryOp {
|
|||
|
||||
class UnaryExpression : public Expression {
|
||||
public:
|
||||
UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ private:
|
|||
|
||||
class MemberExpression : public Expression {
|
||||
public:
|
||||
MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ private:
|
|||
|
||||
class ForStatement : public Statement {
|
||||
public:
|
||||
ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ private:
|
|||
|
||||
class BlockStatement final : public Statement {
|
||||
public:
|
||||
BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ private:
|
|||
|
||||
class Comment final : public Statement {
|
||||
public:
|
||||
Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -823,7 +823,7 @@ public:
|
|||
|
||||
class IfStatement : public Statement {
|
||||
public:
|
||||
IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_namespace() const override { return true; }
|
||||
|
||||
NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ private:
|
|||
|
||||
class CppCastExpression : public Expression {
|
||||
public:
|
||||
CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ private:
|
|||
|
||||
class CStyleCastExpression : public Expression {
|
||||
public:
|
||||
CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ private:
|
|||
|
||||
class SizeofExpression : public Expression {
|
||||
public:
|
||||
SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ private:
|
|||
|
||||
class BracedInitList : public Expression {
|
||||
public:
|
||||
BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ private:
|
|||
|
||||
class DummyAstNode : public ASTNode {
|
||||
public:
|
||||
DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_constructor() const override { return true; }
|
||||
|
||||
Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_destructor() const override { return true; }
|
||||
|
||||
Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include "Lexer.h"
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
|
@ -205,7 +205,7 @@ constexpr StringView s_known_types[] = {
|
|||
|
||||
static bool is_keyword(StringView string)
|
||||
{
|
||||
static HashTable<String> keywords(array_size(s_known_keywords));
|
||||
static HashTable<DeprecatedString> keywords(array_size(s_known_keywords));
|
||||
if (keywords.is_empty()) {
|
||||
keywords.set_from(s_known_keywords);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ static bool is_keyword(StringView string)
|
|||
|
||||
static bool is_known_type(StringView string)
|
||||
{
|
||||
static HashTable<String> types(array_size(s_known_types));
|
||||
static HashTable<DeprecatedString> types(array_size(s_known_types));
|
||||
if (types.is_empty()) {
|
||||
types.set_from(s_known_types);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#include <AK/ScopeLogger.h>
|
||||
#include <LibCpp/Lexer.h>
|
||||
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(String::formatted("'{}' - {} ({})", peek().text(), peek().type_as_string(), m_state.token_index))
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(DeprecatedString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_string(), m_state.token_index))
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
Parser::Parser(Vector<Token> tokens, String const& filename)
|
||||
Parser::Parser(Vector<Token> tokens, DeprecatedString const& filename)
|
||||
: m_filename(filename)
|
||||
, m_tokens(move(tokens))
|
||||
{
|
||||
|
@ -579,7 +579,7 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(ASTNode& parent, No
|
|||
return func;
|
||||
}
|
||||
default: {
|
||||
error(String::formatted("unexpected operator for expression. operator: {}", peek().to_string()));
|
||||
error(DeprecatedString::formatted("unexpected operator for expression. operator: {}", peek().to_string()));
|
||||
auto token = consume();
|
||||
return create_ast_node<InvalidExpression>(parent, token.start(), token.end());
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ Token Parser::consume(Token::Type type)
|
|||
{
|
||||
auto token = consume();
|
||||
if (token.type() != type)
|
||||
error(String::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type())));
|
||||
error(DeprecatedString::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type())));
|
||||
return token;
|
||||
}
|
||||
|
||||
|
@ -869,12 +869,12 @@ StringView Parser::text_of_token(Cpp::Token const& token) const
|
|||
return token.text();
|
||||
}
|
||||
|
||||
String Parser::text_of_node(ASTNode const& node) const
|
||||
DeprecatedString Parser::text_of_node(ASTNode const& node) const
|
||||
{
|
||||
return text_in_range(node.start(), node.end());
|
||||
}
|
||||
|
||||
String Parser::text_in_range(Position start, Position end) const
|
||||
DeprecatedString Parser::text_in_range(Position start, Position end) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (auto token : tokens_in_range(start, end)) {
|
||||
|
@ -906,11 +906,11 @@ void Parser::error(StringView message)
|
|||
|
||||
if (message.is_null() || message.is_empty())
|
||||
message = "<empty>"sv;
|
||||
String formatted_message;
|
||||
DeprecatedString formatted_message;
|
||||
if (m_state.token_index >= m_tokens.size()) {
|
||||
formatted_message = String::formatted("C++ Parsed error on EOF.{}", message);
|
||||
formatted_message = DeprecatedString::formatted("C++ Parsed error on EOF.{}", message);
|
||||
} else {
|
||||
formatted_message = String::formatted("C++ Parser error: {}. token: {} ({}:{})",
|
||||
formatted_message = DeprecatedString::formatted("C++ Parser error: {}. token: {} ({}:{})",
|
||||
message,
|
||||
m_state.token_index < m_tokens.size() ? text_of_token(m_tokens[m_state.token_index]) : "EOF"sv,
|
||||
m_tokens[m_state.token_index].start().line,
|
||||
|
@ -1106,21 +1106,21 @@ NonnullRefPtr<EnumDeclaration> Parser::parse_enum_declaration(ASTNode& parent)
|
|||
return enum_decl;
|
||||
}
|
||||
|
||||
Token Parser::consume_keyword(String const& keyword)
|
||||
Token Parser::consume_keyword(DeprecatedString const& keyword)
|
||||
{
|
||||
auto token = consume();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
error(String::formatted("unexpected token: {}, expected Keyword", token.to_string()));
|
||||
error(DeprecatedString::formatted("unexpected token: {}, expected Keyword", token.to_string()));
|
||||
return token;
|
||||
}
|
||||
if (text_of_token(token) != keyword) {
|
||||
error(String::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword));
|
||||
error(DeprecatedString::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword));
|
||||
return token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
bool Parser::match_keyword(String const& keyword)
|
||||
bool Parser::match_keyword(DeprecatedString const& keyword)
|
||||
{
|
||||
auto token = peek();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
|
@ -1232,7 +1232,7 @@ NonnullRefPtr<Type> Parser::parse_type(ASTNode& parent)
|
|||
|
||||
if (!match_name()) {
|
||||
named_type->set_end(position());
|
||||
error(String::formatted("expected name instead of: {}", peek().text()));
|
||||
error(DeprecatedString::formatted("expected name instead of: {}", peek().text()));
|
||||
return named_type;
|
||||
}
|
||||
named_type->set_name(parse_name(*named_type));
|
||||
|
|
|
@ -19,7 +19,7 @@ class Parser final {
|
|||
AK_MAKE_NONCOPYABLE(Parser);
|
||||
|
||||
public:
|
||||
explicit Parser(Vector<Token> tokens, String const& filename);
|
||||
explicit Parser(Vector<Token> tokens, DeprecatedString const& filename);
|
||||
~Parser() = default;
|
||||
|
||||
NonnullRefPtr<TranslationUnit> parse();
|
||||
|
@ -30,11 +30,11 @@ public:
|
|||
Optional<Token> token_at(Position) const;
|
||||
Optional<size_t> index_of_token_at(Position) const;
|
||||
RefPtr<TranslationUnit const> root_node() const { return m_root_node; }
|
||||
String text_of_node(ASTNode const&) const;
|
||||
DeprecatedString text_of_node(ASTNode const&) const;
|
||||
StringView text_of_token(Cpp::Token const& token) const;
|
||||
void print_tokens() const;
|
||||
Vector<Token> const& tokens() const { return m_tokens; }
|
||||
Vector<String> const& errors() const { return m_errors; }
|
||||
Vector<DeprecatedString> const& errors() const { return m_errors; }
|
||||
|
||||
Vector<CodeComprehension::TodoEntry> get_todo_entries() const;
|
||||
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
bool match_literal();
|
||||
bool match_unary_expression();
|
||||
bool match_boolean_literal();
|
||||
bool match_keyword(String const&);
|
||||
bool match_keyword(DeprecatedString const&);
|
||||
bool match_block_statement();
|
||||
bool match_namespace_declaration();
|
||||
bool match_template_arguments();
|
||||
|
@ -125,12 +125,12 @@ private:
|
|||
bool match(Token::Type);
|
||||
Token consume(Token::Type);
|
||||
Token consume();
|
||||
Token consume_keyword(String const&);
|
||||
Token consume_keyword(DeprecatedString const&);
|
||||
Token peek(size_t offset = 0) const;
|
||||
Optional<Token> peek(Token::Type) const;
|
||||
Position position() const;
|
||||
Position previous_token_end() const;
|
||||
String text_in_range(Position start, Position end) const;
|
||||
DeprecatedString text_in_range(Position start, Position end) const;
|
||||
|
||||
void save_state();
|
||||
void load_state();
|
||||
|
@ -185,12 +185,12 @@ private:
|
|||
};
|
||||
void parse_constructor_or_destructor_impl(FunctionDeclaration&, CtorOrDtor);
|
||||
|
||||
String m_filename;
|
||||
DeprecatedString m_filename;
|
||||
Vector<Token> m_tokens;
|
||||
State m_state;
|
||||
Vector<State> m_saved_states;
|
||||
RefPtr<TranslationUnit> m_root_node;
|
||||
Vector<String> m_errors;
|
||||
Vector<DeprecatedString> m_errors;
|
||||
NonnullRefPtrVector<ASTNode> m_nodes;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
namespace Cpp {
|
||||
Preprocessor::Preprocessor(String const& filename, StringView program)
|
||||
Preprocessor::Preprocessor(DeprecatedString const& filename, StringView program)
|
||||
: m_filename(filename)
|
||||
, m_program(program)
|
||||
{
|
||||
|
@ -362,7 +362,7 @@ Optional<Preprocessor::Definition> Preprocessor::create_definition(StringView li
|
|||
return definition;
|
||||
}
|
||||
|
||||
String Preprocessor::remove_escaped_newlines(StringView value)
|
||||
DeprecatedString Preprocessor::remove_escaped_newlines(StringView value)
|
||||
{
|
||||
static constexpr auto escaped_newline = "\\\n"sv;
|
||||
AK::StringBuilder processed_value;
|
||||
|
@ -374,7 +374,7 @@ String Preprocessor::remove_escaped_newlines(StringView value)
|
|||
return processed_value.to_string();
|
||||
}
|
||||
|
||||
String Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition)
|
||||
DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition)
|
||||
{
|
||||
if (macro_call.arguments.size() != definition.parameters.size()) {
|
||||
dbgln("mismatch in # of arguments for macro call: {}", macro_call.name.text());
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCpp/Token.h>
|
||||
|
@ -20,24 +20,24 @@ namespace Cpp {
|
|||
class Preprocessor {
|
||||
|
||||
public:
|
||||
explicit Preprocessor(String const& filename, StringView program);
|
||||
explicit Preprocessor(DeprecatedString const& filename, StringView program);
|
||||
Vector<Token> process_and_lex();
|
||||
Vector<StringView> included_paths() const { return m_included_paths; }
|
||||
|
||||
struct Definition {
|
||||
String key;
|
||||
Vector<String> parameters;
|
||||
String value;
|
||||
DeprecatedString key;
|
||||
Vector<DeprecatedString> parameters;
|
||||
DeprecatedString value;
|
||||
FlyString filename;
|
||||
size_t line { 0 };
|
||||
size_t column { 0 };
|
||||
};
|
||||
using Definitions = HashMap<String, Definition>;
|
||||
using Definitions = HashMap<DeprecatedString, Definition>;
|
||||
|
||||
struct Substitution {
|
||||
Vector<Token> original_tokens;
|
||||
Definition defined_value;
|
||||
String processed_value;
|
||||
DeprecatedString processed_value;
|
||||
};
|
||||
|
||||
Definitions const& definitions() const { return m_definitions; }
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
void handle_preprocessor_statement(StringView);
|
||||
void handle_include_statement(StringView);
|
||||
void handle_preprocessor_keyword(StringView keyword, GenericLexer& line_lexer);
|
||||
String remove_escaped_newlines(StringView value);
|
||||
DeprecatedString remove_escaped_newlines(StringView value);
|
||||
|
||||
size_t do_substitution(Vector<Token> const& tokens, size_t token_index, Definition const&);
|
||||
Optional<Definition> create_definition(StringView line);
|
||||
|
@ -69,10 +69,10 @@ private:
|
|||
size_t end_token_index { 0 };
|
||||
};
|
||||
Optional<MacroCall> parse_macro_call(Vector<Token> const& tokens, size_t token_index);
|
||||
String evaluate_macro_call(MacroCall const&, Definition const&);
|
||||
DeprecatedString evaluate_macro_call(MacroCall const&, Definition const&);
|
||||
|
||||
String m_filename;
|
||||
String m_program;
|
||||
DeprecatedString m_filename;
|
||||
DeprecatedString m_program;
|
||||
|
||||
Vector<Token> m_unprocessed_tokens;
|
||||
Vector<Token> m_processed_tokens;
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
Cpp::SyntaxHighlighter m_simple_syntax_highlighter;
|
||||
Vector<CodeComprehension::TokenInfo> m_tokens_info;
|
||||
String m_saved_tokens_text;
|
||||
DeprecatedString m_saved_tokens_text;
|
||||
Vector<Token> m_saved_tokens;
|
||||
Threading::Mutex m_lock;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Token.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
|
@ -26,12 +26,12 @@ bool Position::operator<=(Position const& other) const
|
|||
return !(*this > other);
|
||||
}
|
||||
|
||||
String Token::to_string() const
|
||||
DeprecatedString Token::to_string() const
|
||||
{
|
||||
return String::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
}
|
||||
|
||||
String Token::type_as_string() const
|
||||
DeprecatedString Token::type_as_string() const
|
||||
{
|
||||
return type_to_string(m_type);
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ struct Token {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String to_string() const;
|
||||
String type_as_string() const;
|
||||
DeprecatedString to_string() const;
|
||||
DeprecatedString type_as_string() const;
|
||||
|
||||
Position const& start() const { return m_start; }
|
||||
Position const& end() const { return m_end; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue