mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -32,10 +32,10 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
|
||||
DeprecatedString qualifiers_string;
|
||||
ByteString qualifiers_string;
|
||||
if (!m_qualifiers.is_empty()) {
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "[{}]", DeprecatedString::join(' ', m_qualifiers));
|
||||
outln(output, "[{}]", ByteString::join(' ', m_qualifiers));
|
||||
}
|
||||
|
||||
m_return_type->dump(output, indent + 1);
|
||||
|
@ -72,51 +72,51 @@ void Type::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "{}", to_deprecated_string());
|
||||
outln(output, "{}", to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString NamedType::to_deprecated_string() const
|
||||
ByteString NamedType::to_byte_string() const
|
||||
{
|
||||
DeprecatedString qualifiers_string;
|
||||
ByteString qualifiers_string;
|
||||
if (!qualifiers().is_empty())
|
||||
qualifiers_string = DeprecatedString::formatted("[{}] ", DeprecatedString::join(' ', qualifiers()));
|
||||
qualifiers_string = ByteString::formatted("[{}] ", ByteString::join(' ', qualifiers()));
|
||||
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
if (is_auto())
|
||||
name = "auto";
|
||||
else
|
||||
name = m_name.is_null() ? ""sv : m_name->full_name();
|
||||
|
||||
return DeprecatedString::formatted("{}{}", qualifiers_string, name);
|
||||
return ByteString::formatted("{}{}", qualifiers_string, name);
|
||||
}
|
||||
|
||||
DeprecatedString Pointer::to_deprecated_string() const
|
||||
ByteString Pointer::to_byte_string() const
|
||||
{
|
||||
if (!m_pointee)
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
builder.append(m_pointee->to_deprecated_string());
|
||||
builder.append(m_pointee->to_byte_string());
|
||||
builder.append('*');
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString Reference::to_deprecated_string() const
|
||||
ByteString Reference::to_byte_string() const
|
||||
{
|
||||
if (!m_referenced_type)
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
builder.append(m_referenced_type->to_deprecated_string());
|
||||
builder.append(m_referenced_type->to_byte_string());
|
||||
if (m_kind == Kind::Lvalue)
|
||||
builder.append('&');
|
||||
else
|
||||
builder.append("&&"sv);
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString FunctionType::to_deprecated_string() const
|
||||
ByteString FunctionType::to_byte_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_return_type->to_deprecated_string());
|
||||
builder.append(m_return_type->to_byte_string());
|
||||
builder.append('(');
|
||||
bool first = true;
|
||||
for (auto& parameter : m_parameters) {
|
||||
|
@ -125,14 +125,14 @@ DeprecatedString FunctionType::to_deprecated_string() const
|
|||
else
|
||||
builder.append(", "sv);
|
||||
if (parameter->type())
|
||||
builder.append(parameter->type()->to_deprecated_string());
|
||||
builder.append(parameter->type()->to_byte_string());
|
||||
if (parameter->name() && !parameter->full_name().is_empty()) {
|
||||
builder.append(' ');
|
||||
builder.append(parameter->full_name());
|
||||
}
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
void Parameter::dump(FILE* output, size_t indent) const
|
||||
|
@ -552,7 +552,7 @@ StringView Name::full_name() const
|
|||
builder.appendff("{}::", scope->name());
|
||||
}
|
||||
}
|
||||
m_full_name = DeprecatedString::formatted("{}{}", builder.to_deprecated_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
m_full_name = ByteString::formatted("{}{}", builder.to_byte_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
return *m_full_name;
|
||||
}
|
||||
|
||||
|
@ -565,10 +565,10 @@ StringView TemplatizedName::full_name() const
|
|||
name.append(Name::full_name());
|
||||
name.append('<');
|
||||
for (auto& type : m_template_arguments) {
|
||||
name.append(type->to_deprecated_string());
|
||||
name.append(type->to_byte_string());
|
||||
}
|
||||
name.append('>');
|
||||
m_full_name = name.to_deprecated_string();
|
||||
m_full_name = name.to_byte_string();
|
||||
return *m_full_name;
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ void SizedName::dump(FILE* output, size_t indent) const
|
|||
if (dimension_info.is_empty()) {
|
||||
dimension_info.append("[]"sv);
|
||||
}
|
||||
outln(output, "{}", dimension_info.to_deprecated_string());
|
||||
outln(output, "{}", dimension_info.to_byte_string());
|
||||
}
|
||||
|
||||
void CppCastExpression::dump(FILE* output, size_t indent) const
|
||||
|
@ -670,7 +670,7 @@ StringView Declaration::full_name() const
|
|||
if (m_name)
|
||||
m_full_name = m_name->full_name();
|
||||
else
|
||||
m_full_name = DeprecatedString::empty();
|
||||
m_full_name = ByteString::empty();
|
||||
}
|
||||
|
||||
return *m_full_name;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
virtual bool is_dummy_node() const { return false; }
|
||||
|
||||
protected:
|
||||
ASTNode(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
ASTNode(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: m_parent(parent)
|
||||
, m_start(start)
|
||||
, m_end(end)
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override { return m_declarations; }
|
||||
|
||||
TranslationUnit(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
TranslationUnit(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
|
||||
|
||||
protected:
|
||||
Statement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Statement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ public:
|
|||
void set_name(RefPtr<Name const> name) { m_name = move(name); }
|
||||
|
||||
protected:
|
||||
Declaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Declaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<Name const> m_name;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
mutable Optional<ByteString> m_full_name;
|
||||
};
|
||||
|
||||
class InvalidDeclaration : public Declaration {
|
||||
|
@ -145,7 +145,7 @@ class InvalidDeclaration : public Declaration {
|
|||
public:
|
||||
virtual ~InvalidDeclaration() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidDeclaration"sv; }
|
||||
InvalidDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
InvalidDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public:
|
|||
virtual bool is_destructor() const { return false; }
|
||||
RefPtr<FunctionDefinition const> definition() { return m_definition; }
|
||||
|
||||
FunctionDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
FunctionDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
Type const* type() const { return m_type.ptr(); }
|
||||
|
||||
protected:
|
||||
VariableOrParameterDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
VariableOrParameterDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_parameter() const override { return true; }
|
||||
|
||||
Parameter(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, RefPtr<Name const> name)
|
||||
Parameter(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, RefPtr<Name const> name)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -227,7 +227,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 DeprecatedString to_deprecated_string() const = 0;
|
||||
virtual ByteString to_byte_string() const = 0;
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
bool is_auto() const { return m_is_auto; }
|
||||
|
@ -236,7 +236,7 @@ public:
|
|||
void set_qualifiers(Vector<StringView>&& qualifiers) { m_qualifiers = move(qualifiers); }
|
||||
|
||||
protected:
|
||||
Type(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Type(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -250,10 +250,10 @@ class NamedType : public Type {
|
|||
public:
|
||||
virtual ~NamedType() override = default;
|
||||
virtual StringView class_name() const override { return "NamedType"sv; }
|
||||
virtual DeprecatedString to_deprecated_string() const override;
|
||||
virtual ByteString to_byte_string() const override;
|
||||
virtual bool is_named_type() const override { return true; }
|
||||
|
||||
NamedType(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
NamedType(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -270,9 +270,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 DeprecatedString to_deprecated_string() const override;
|
||||
virtual ByteString to_byte_string() const override;
|
||||
|
||||
Pointer(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Pointer(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -289,14 +289,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 DeprecatedString to_deprecated_string() const override;
|
||||
virtual ByteString to_byte_string() const override;
|
||||
|
||||
enum class Kind {
|
||||
Lvalue,
|
||||
Rvalue,
|
||||
};
|
||||
|
||||
Reference(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, Kind kind)
|
||||
Reference(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, Kind kind)
|
||||
: Type(parent, start, end, filename)
|
||||
, m_kind(kind)
|
||||
{
|
||||
|
@ -316,9 +316,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 DeprecatedString to_deprecated_string() const override;
|
||||
virtual ByteString to_byte_string() const override;
|
||||
|
||||
FunctionType(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
FunctionType(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public:
|
|||
virtual StringView class_name() const override { return "FunctionDefinition"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
FunctionDefinition(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
FunctionDefinition(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ class InvalidStatement : public Statement {
|
|||
public:
|
||||
virtual ~InvalidStatement() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidStatement"sv; }
|
||||
InvalidStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
InvalidStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ public:
|
|||
virtual StringView class_name() const override { return "Expression"sv; }
|
||||
|
||||
protected:
|
||||
Expression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Expression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ class InvalidExpression : public Expression {
|
|||
public:
|
||||
virtual ~InvalidExpression() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidExpression"sv; }
|
||||
InvalidExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
InvalidExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ public:
|
|||
virtual StringView class_name() const override { return "VariableDeclaration"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
VariableDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
VariableDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -408,12 +408,12 @@ public:
|
|||
virtual StringView class_name() const override { return "Identifier"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
Identifier(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StringView name)
|
||||
Identifier(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, StringView name)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
Identifier(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Identifier(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Identifier(parent, start, end, filename, {})
|
||||
{
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ public:
|
|||
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)
|
||||
Name(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public:
|
|||
private:
|
||||
RefPtr<Identifier const> m_name;
|
||||
Vector<NonnullRefPtr<Identifier const>> m_scope;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
mutable Optional<ByteString> m_full_name;
|
||||
};
|
||||
|
||||
class SizedName : public Name {
|
||||
|
@ -461,7 +461,7 @@ public:
|
|||
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)
|
||||
SizedName(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Name(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public:
|
|||
|
||||
private:
|
||||
Vector<StringView> m_dimensions;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
mutable Optional<ByteString> m_full_name;
|
||||
};
|
||||
|
||||
class TemplatizedName : public Name {
|
||||
|
@ -480,7 +480,7 @@ public:
|
|||
virtual bool is_templatized() const override { return true; }
|
||||
virtual StringView full_name() const override;
|
||||
|
||||
TemplatizedName(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
TemplatizedName(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Name(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ public:
|
|||
|
||||
private:
|
||||
Vector<NonnullRefPtr<Type const>> m_template_arguments;
|
||||
mutable Optional<DeprecatedString> m_full_name;
|
||||
mutable Optional<ByteString> m_full_name;
|
||||
};
|
||||
|
||||
class NumericLiteral : public Expression {
|
||||
|
@ -498,7 +498,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NumericLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NumericLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StringView value)
|
||||
NumericLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, StringView value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -516,7 +516,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NullPointerLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NullPointerLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
NullPointerLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ public:
|
|||
virtual StringView class_name() const override { return "BooleanLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
BooleanLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, bool value)
|
||||
BooleanLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, bool value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ enum class BinaryOp {
|
|||
|
||||
class BinaryExpression : public Expression {
|
||||
public:
|
||||
BinaryExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
BinaryExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ enum class AssignmentOp {
|
|||
|
||||
class AssignmentExpression : public Expression {
|
||||
public:
|
||||
AssignmentExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
AssignmentExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ private:
|
|||
|
||||
class FunctionCall : public Expression {
|
||||
public:
|
||||
FunctionCall(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
FunctionCall(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ private:
|
|||
|
||||
class StringLiteral final : public Expression {
|
||||
public:
|
||||
StringLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
StringLiteral(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -648,11 +648,11 @@ public:
|
|||
virtual StringView class_name() const override { return "StringLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
void set_value(DeprecatedString value) { m_value = move(value); }
|
||||
ByteString const& value() const { return m_value; }
|
||||
void set_value(ByteString value) { m_value = move(value); }
|
||||
|
||||
private:
|
||||
DeprecatedString m_value;
|
||||
ByteString m_value;
|
||||
};
|
||||
|
||||
class ReturnStatement : public Statement {
|
||||
|
@ -660,7 +660,7 @@ public:
|
|||
virtual ~ReturnStatement() override = default;
|
||||
virtual StringView class_name() const override { return "ReturnStatement"sv; }
|
||||
|
||||
ReturnStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
ReturnStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_enum() const override { return true; }
|
||||
|
||||
EnumDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
EnumDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ public:
|
|||
Class
|
||||
};
|
||||
|
||||
StructOrClassDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename, StructOrClassDeclaration::Type type)
|
||||
StructOrClassDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename, StructOrClassDeclaration::Type type)
|
||||
: Declaration(parent, start, end, filename)
|
||||
, m_type(type)
|
||||
{
|
||||
|
@ -747,7 +747,7 @@ enum class UnaryOp {
|
|||
|
||||
class UnaryExpression : public Expression {
|
||||
public:
|
||||
UnaryExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
UnaryExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ private:
|
|||
|
||||
class MemberExpression : public Expression {
|
||||
public:
|
||||
MemberExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
MemberExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ private:
|
|||
|
||||
class ForStatement : public Statement {
|
||||
public:
|
||||
ForStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
ForStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ private:
|
|||
|
||||
class BlockStatement final : public Statement {
|
||||
public:
|
||||
BlockStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
BlockStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -835,7 +835,7 @@ private:
|
|||
|
||||
class Comment final : public Statement {
|
||||
public:
|
||||
Comment(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Comment(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ public:
|
|||
|
||||
class IfStatement : public Statement {
|
||||
public:
|
||||
IfStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
IfStatement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_namespace() const override { return true; }
|
||||
|
||||
NamespaceDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
NamespaceDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ private:
|
|||
|
||||
class CppCastExpression : public Expression {
|
||||
public:
|
||||
CppCastExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
CppCastExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ private:
|
|||
|
||||
class CStyleCastExpression : public Expression {
|
||||
public:
|
||||
CStyleCastExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
CStyleCastExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ private:
|
|||
|
||||
class SizeofExpression : public Expression {
|
||||
public:
|
||||
SizeofExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
SizeofExpression(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ private:
|
|||
|
||||
class BracedInitList : public Expression {
|
||||
public:
|
||||
BracedInitList(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
BracedInitList(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -965,7 +965,7 @@ private:
|
|||
|
||||
class DummyAstNode : public ASTNode {
|
||||
public:
|
||||
DummyAstNode(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
DummyAstNode(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_constructor() const override { return true; }
|
||||
|
||||
Constructor(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Constructor(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -994,7 +994,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_destructor() const override { return true; }
|
||||
|
||||
Destructor(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
Destructor(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ public:
|
|||
virtual StringView class_name() const override { return "UsingNamespaceDeclaration"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
UsingNamespaceDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
UsingNamespaceDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ public:
|
|||
virtual StringView class_name() const override { return "TypedefDeclaration"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
TypedefDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
TypedefDeclaration(ASTNode const* parent, Optional<Position> start, Optional<Position> end, ByteString const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
#include "Lexer.h"
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
@ -203,7 +203,7 @@ constexpr StringView s_known_types[] = {
|
|||
|
||||
static bool is_keyword(StringView string)
|
||||
{
|
||||
static HashTable<DeprecatedString> keywords(array_size(s_known_keywords));
|
||||
static HashTable<ByteString> keywords(array_size(s_known_keywords));
|
||||
if (keywords.is_empty()) {
|
||||
keywords.set_from(s_known_keywords);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ static bool is_keyword(StringView string)
|
|||
|
||||
static bool is_known_type(StringView string)
|
||||
{
|
||||
static HashTable<DeprecatedString> types(array_size(s_known_types));
|
||||
static HashTable<ByteString> types(array_size(s_known_types));
|
||||
if (types.is_empty()) {
|
||||
types.set_from(s_known_types);
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@
|
|||
#include <AK/ScopeLogger.h>
|
||||
#include <LibCpp/Lexer.h>
|
||||
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(DeprecatedString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_deprecated_string(), m_state.token_index))
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(ByteString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_byte_string(), m_state.token_index))
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
Parser::Parser(Vector<Token> tokens, DeprecatedString const& filename)
|
||||
Parser::Parser(Vector<Token> tokens, ByteString const& filename)
|
||||
: m_filename(filename)
|
||||
, m_tokens(move(tokens))
|
||||
{
|
||||
if constexpr (CPP_DEBUG) {
|
||||
dbgln("Tokens:");
|
||||
for (size_t i = 0; i < m_tokens.size(); ++i) {
|
||||
dbgln("{}- {}", i, m_tokens[i].to_deprecated_string());
|
||||
dbgln("{}- {}", i, m_tokens[i].to_byte_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ NonnullRefPtr<Expression const> Parser::parse_secondary_expression(ASTNode const
|
|||
return func;
|
||||
}
|
||||
default: {
|
||||
error(DeprecatedString::formatted("unexpected operator for expression. operator: {}", peek().to_deprecated_string()));
|
||||
error(ByteString::formatted("unexpected operator for expression. operator: {}", peek().to_byte_string()));
|
||||
auto token = consume();
|
||||
return create_ast_node<InvalidExpression>(parent, token.start(), token.end());
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ Token Parser::consume(Token::Type type)
|
|||
{
|
||||
auto token = consume();
|
||||
if (token.type() != type)
|
||||
error(DeprecatedString::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type())));
|
||||
error(ByteString::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type())));
|
||||
return token;
|
||||
}
|
||||
|
||||
|
@ -894,18 +894,18 @@ StringView Parser::text_of_token(Cpp::Token const& token) const
|
|||
return token.text();
|
||||
}
|
||||
|
||||
DeprecatedString Parser::text_of_node(ASTNode const& node) const
|
||||
ByteString Parser::text_of_node(ASTNode const& node) const
|
||||
{
|
||||
return text_in_range(node.start(), node.end());
|
||||
}
|
||||
|
||||
DeprecatedString Parser::text_in_range(Position start, Position end) const
|
||||
ByteString Parser::text_in_range(Position start, Position end) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (auto token : tokens_in_range(start, end)) {
|
||||
builder.append(token.text());
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
Vector<Token> Parser::tokens_in_range(Position start, Position end) const
|
||||
|
@ -931,11 +931,11 @@ void Parser::error(StringView message)
|
|||
|
||||
if (message.is_null() || message.is_empty())
|
||||
message = "<empty>"sv;
|
||||
DeprecatedString formatted_message;
|
||||
ByteString formatted_message;
|
||||
if (m_state.token_index >= m_tokens.size()) {
|
||||
formatted_message = DeprecatedString::formatted("C++ Parsed error on EOF.{}", message);
|
||||
formatted_message = ByteString::formatted("C++ Parsed error on EOF.{}", message);
|
||||
} else {
|
||||
formatted_message = DeprecatedString::formatted("C++ Parser error: {}. token: {} ({}:{})",
|
||||
formatted_message = ByteString::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,
|
||||
|
@ -1033,7 +1033,7 @@ Optional<size_t> Parser::index_of_token_at(Position pos) const
|
|||
void Parser::print_tokens() const
|
||||
{
|
||||
for (auto& token : m_tokens) {
|
||||
outln("{}", token.to_deprecated_string());
|
||||
outln("{}", token.to_byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1131,21 +1131,21 @@ NonnullRefPtr<EnumDeclaration const> Parser::parse_enum_declaration(ASTNode cons
|
|||
return enum_decl;
|
||||
}
|
||||
|
||||
Token Parser::consume_keyword(DeprecatedString const& keyword)
|
||||
Token Parser::consume_keyword(ByteString const& keyword)
|
||||
{
|
||||
auto token = consume();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
error(DeprecatedString::formatted("unexpected token: {}, expected Keyword", token.to_deprecated_string()));
|
||||
error(ByteString::formatted("unexpected token: {}, expected Keyword", token.to_byte_string()));
|
||||
return token;
|
||||
}
|
||||
if (text_of_token(token) != keyword) {
|
||||
error(DeprecatedString::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword));
|
||||
error(ByteString::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword));
|
||||
return token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
bool Parser::match_keyword(DeprecatedString const& keyword)
|
||||
bool Parser::match_keyword(ByteString const& keyword)
|
||||
{
|
||||
auto token = peek();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
|
@ -1257,7 +1257,7 @@ NonnullRefPtr<Type const> Parser::parse_type(ASTNode const& parent)
|
|||
|
||||
if (!match_name()) {
|
||||
named_type->set_end(position());
|
||||
error(DeprecatedString::formatted("expected name instead of: {}", peek().text()));
|
||||
error(ByteString::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, DeprecatedString const& filename);
|
||||
explicit Parser(Vector<Token> tokens, ByteString 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; }
|
||||
DeprecatedString text_of_node(ASTNode const&) const;
|
||||
ByteString 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<DeprecatedString> const& errors() const { return m_errors; }
|
||||
Vector<ByteString> const& errors() const { return m_errors; }
|
||||
|
||||
Vector<CodeComprehension::TodoEntry> get_todo_entries() const;
|
||||
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
bool match_literal();
|
||||
bool match_unary_expression();
|
||||
bool match_boolean_literal();
|
||||
bool match_keyword(DeprecatedString const&);
|
||||
bool match_keyword(ByteString const&);
|
||||
bool match_block_statement();
|
||||
bool match_namespace_declaration();
|
||||
bool match_template_arguments();
|
||||
|
@ -132,12 +132,12 @@ private:
|
|||
bool match(Token::Type);
|
||||
Token consume(Token::Type);
|
||||
Token consume();
|
||||
Token consume_keyword(DeprecatedString const&);
|
||||
Token consume_keyword(ByteString const&);
|
||||
Token peek(size_t offset = 0) const;
|
||||
Optional<Token> peek(Token::Type) const;
|
||||
Position position() const;
|
||||
Position previous_token_end() const;
|
||||
DeprecatedString text_in_range(Position start, Position end) const;
|
||||
ByteString text_in_range(Position start, Position end) const;
|
||||
|
||||
void save_state();
|
||||
void load_state();
|
||||
|
@ -192,12 +192,12 @@ private:
|
|||
};
|
||||
void parse_constructor_or_destructor_impl(FunctionDeclaration&, CtorOrDtor);
|
||||
|
||||
DeprecatedString m_filename;
|
||||
ByteString m_filename;
|
||||
Vector<Token> m_tokens;
|
||||
State m_state;
|
||||
Vector<State> m_saved_states;
|
||||
RefPtr<TranslationUnit> m_root_node;
|
||||
Vector<DeprecatedString> m_errors;
|
||||
Vector<ByteString> m_errors;
|
||||
Vector<NonnullRefPtr<ASTNode>> m_nodes;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
namespace Cpp {
|
||||
Preprocessor::Preprocessor(DeprecatedString const& filename, StringView program)
|
||||
Preprocessor::Preprocessor(ByteString const& filename, StringView program)
|
||||
: m_filename(filename)
|
||||
, m_program(program)
|
||||
{
|
||||
|
@ -369,7 +369,7 @@ Optional<Preprocessor::Definition> Preprocessor::create_definition(StringView li
|
|||
return definition;
|
||||
}
|
||||
|
||||
DeprecatedString Preprocessor::remove_escaped_newlines(StringView value)
|
||||
ByteString Preprocessor::remove_escaped_newlines(StringView value)
|
||||
{
|
||||
static constexpr auto escaped_newline = "\\\n"sv;
|
||||
AK::StringBuilder processed_value;
|
||||
|
@ -378,10 +378,10 @@ DeprecatedString Preprocessor::remove_escaped_newlines(StringView value)
|
|||
processed_value.append(lexer.consume_until(escaped_newline));
|
||||
lexer.ignore(escaped_newline.length());
|
||||
}
|
||||
return processed_value.to_deprecated_string();
|
||||
return processed_value.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition)
|
||||
ByteString 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());
|
||||
|
@ -408,7 +408,7 @@ DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call,
|
|||
}
|
||||
});
|
||||
|
||||
return processed_value.to_deprecated_string();
|
||||
return processed_value.to_byte_string();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Optional.h>
|
||||
|
@ -20,24 +20,24 @@ namespace Cpp {
|
|||
class Preprocessor {
|
||||
|
||||
public:
|
||||
explicit Preprocessor(DeprecatedString const& filename, StringView program);
|
||||
explicit Preprocessor(ByteString const& filename, StringView program);
|
||||
Vector<Token> process_and_lex();
|
||||
Vector<StringView> included_paths() const { return m_included_paths; }
|
||||
|
||||
struct Definition {
|
||||
DeprecatedString key;
|
||||
Vector<DeprecatedString> parameters;
|
||||
DeprecatedString value;
|
||||
ByteString key;
|
||||
Vector<ByteString> parameters;
|
||||
ByteString value;
|
||||
DeprecatedFlyString filename;
|
||||
size_t line { 0 };
|
||||
size_t column { 0 };
|
||||
};
|
||||
using Definitions = HashMap<DeprecatedString, Definition>;
|
||||
using Definitions = HashMap<ByteString, Definition>;
|
||||
|
||||
struct Substitution {
|
||||
Vector<Token> original_tokens;
|
||||
Definition defined_value;
|
||||
DeprecatedString processed_value;
|
||||
ByteString 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);
|
||||
DeprecatedString remove_escaped_newlines(StringView value);
|
||||
ByteString 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);
|
||||
DeprecatedString evaluate_macro_call(MacroCall const&, Definition const&);
|
||||
ByteString evaluate_macro_call(MacroCall const&, Definition const&);
|
||||
|
||||
DeprecatedString m_filename;
|
||||
DeprecatedString m_program;
|
||||
ByteString m_filename;
|
||||
ByteString m_program;
|
||||
|
||||
Vector<Token> m_unprocessed_tokens;
|
||||
Vector<Token> m_processed_tokens;
|
||||
|
|
|
@ -45,13 +45,13 @@ void SemanticSyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
StringBuilder previous_tokens_as_lines;
|
||||
|
||||
for (auto& token : current_tokens)
|
||||
current_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string());
|
||||
current_tokens_as_lines.appendff("{}\n", token.type_as_byte_string());
|
||||
|
||||
for (Cpp::Token const& token : m_saved_tokens)
|
||||
previous_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string());
|
||||
previous_tokens_as_lines.appendff("{}\n", token.type_as_byte_string());
|
||||
|
||||
auto previous = previous_tokens_as_lines.to_deprecated_string();
|
||||
auto current = current_tokens_as_lines.to_deprecated_string();
|
||||
auto previous = previous_tokens_as_lines.to_byte_string();
|
||||
auto current = current_tokens_as_lines.to_byte_string();
|
||||
|
||||
// FIXME: Computing the diff on the entire document's tokens is quite inefficient.
|
||||
// An improvement over this could be only including the tokens that are in edited text ranges in the diff.
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
Cpp::SyntaxHighlighter m_simple_syntax_highlighter;
|
||||
Vector<CodeComprehension::TokenInfo> m_tokens_info;
|
||||
DeprecatedString m_saved_tokens_text;
|
||||
ByteString m_saved_tokens_text;
|
||||
Vector<Token> m_saved_tokens;
|
||||
Threading::Mutex m_lock;
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
Vector<GUI::TextDocumentSpan> spans;
|
||||
lexer.lex_iterable([&](auto token) {
|
||||
// FIXME: The +1 for the token end column is a quick hack due to not wanting to modify the lexer (which is also used by the parser). Maybe there's a better way to do this.
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_deprecated_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1);
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_byte_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1);
|
||||
GUI::TextDocumentSpan span;
|
||||
span.range.set_start({ token.start().line, token.start().column });
|
||||
span.range.set_end({ token.end().line, token.end().column + 1 });
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Token.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
|
@ -26,12 +26,12 @@ bool Position::operator<=(Position const& other) const
|
|||
return !(*this > other);
|
||||
}
|
||||
|
||||
DeprecatedString Token::to_deprecated_string() const
|
||||
ByteString Token::to_byte_string() const
|
||||
{
|
||||
return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
return ByteString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
}
|
||||
|
||||
DeprecatedString Token::type_as_deprecated_string() const
|
||||
ByteString Token::type_as_byte_string() const
|
||||
{
|
||||
return type_to_string(m_type);
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ struct Token {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
DeprecatedString type_as_deprecated_string() const;
|
||||
ByteString to_byte_string() const;
|
||||
ByteString type_as_byte_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