Commit 8ab941a0 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[parsing][cleanup] Using 'using' instead of 'typedef'

Even though both are allowed in the style guide, it recommends to use
'using', as its syntax is more consistent with the rest of C++.
This CL turns all typedefs in parsing code to 'using' declarations.

R=leszeks@chromium.org

Bug: v8:8834
Change-Id: I0c95f83ee6897d294bd002b7a4a6277962397e90
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545897Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60522}
parent 138d2dfc
......@@ -41,8 +41,8 @@ class VariableProxy;
template <typename Types>
class ExpressionScope {
public:
typedef typename Types::Impl ParserT;
typedef typename Types::Expression ExpressionT;
using ParserT = typename Types::Impl;
using ExpressionT = typename Types::Expression;
VariableProxy* NewVariable(const AstRawString* name,
int pos = kNoSourcePosition) {
......@@ -281,9 +281,9 @@ class ExpressionScope {
template <typename Types>
class VariableDeclarationParsingScope : public ExpressionScope<Types> {
public:
typedef typename Types::Impl ParserT;
typedef class ExpressionScope<Types> ExpressionScopeT;
typedef typename ExpressionScopeT::ScopeType ScopeType;
using ParserT = typename Types::Impl;
using ExpressionScopeT = ExpressionScope<Types>;
using ScopeType = typename ExpressionScopeT::ScopeType;
VariableDeclarationParsingScope(ParserT* parser, VariableMode mode,
ZonePtrList<const AstRawString>* names)
......@@ -351,9 +351,9 @@ class VariableDeclarationParsingScope : public ExpressionScope<Types> {
template <typename Types>
class ParameterDeclarationParsingScope : public ExpressionScope<Types> {
public:
typedef typename Types::Impl ParserT;
typedef class ExpressionScope<Types> ExpressionScopeT;
typedef typename ExpressionScopeT::ScopeType ScopeType;
using ParserT = typename Types::Impl;
using ExpressionScopeT = ExpressionScope<Types>;
using ScopeType = typename ExpressionScopeT::ScopeType;
explicit ParameterDeclarationParsingScope(ParserT* parser)
: ExpressionScopeT(parser, ExpressionScopeT::kParameterDeclaration) {}
......@@ -391,10 +391,10 @@ class ParameterDeclarationParsingScope : public ExpressionScope<Types> {
template <typename Types>
class ExpressionParsingScope : public ExpressionScope<Types> {
public:
typedef typename Types::Impl ParserT;
typedef typename Types::Expression ExpressionT;
typedef class ExpressionScope<Types> ExpressionScopeT;
typedef typename ExpressionScopeT::ScopeType ScopeType;
using ParserT = typename Types::Impl;
using ExpressionT = typename Types::Expression;
using ExpressionScopeT = ExpressionScope<Types>;
using ScopeType = typename ExpressionScopeT::ScopeType;
ExpressionParsingScope(ParserT* parser,
ScopeType type = ExpressionScopeT::kExpression)
......@@ -563,7 +563,7 @@ class ExpressionParsingScope : public ExpressionScope<Types> {
template <typename Types>
class AccumulationScope {
public:
typedef typename Types::Impl ParserT;
using ParserT = typename Types::Impl;
static const int kNumberOfErrors =
ExpressionParsingScope<Types>::kNumberOfErrors;
......@@ -644,8 +644,8 @@ class AccumulationScope {
template <typename Types>
class ArrowHeadParsingScope : public ExpressionParsingScope<Types> {
public:
typedef typename Types::Impl ParserT;
typedef typename ExpressionScope<Types>::ScopeType ScopeType;
using ParserT = typename Types::Impl;
using ScopeType = typename ExpressionScope<Types>::ScopeType;
ArrowHeadParsingScope(ParserT* parser, FunctionKind kind)
: ExpressionParsingScope<Types>(
......
......@@ -236,8 +236,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
void Enqueue(ParseInfo* outer_parse_info, const AstRawString* function_name,
FunctionLiteral* literal);
typedef std::forward_list<std::pair<FunctionLiteral*, uintptr_t>>::iterator
EnqueuedJobsIterator;
using EnqueuedJobsIterator =
std::forward_list<std::pair<FunctionLiteral*, uintptr_t>>::iterator;
EnqueuedJobsIterator begin() { return enqueued_jobs_.begin(); }
EnqueuedJobsIterator end() { return enqueued_jobs_.end(); }
......
......@@ -49,7 +49,7 @@ enum class ParseFunctionFlag : uint8_t {
kIsAsync = 1 << 1
};
typedef base::Flags<ParseFunctionFlag> ParseFunctionFlags;
using ParseFunctionFlags = base::Flags<ParseFunctionFlag>;
struct FormalParametersBase {
explicit FormalParametersBase(DeclarationScope* scope) : scope(scope) {}
......@@ -195,44 +195,44 @@ template <typename Impl>
class ParserBase {
public:
// Shorten type names defined by ParserTypes<Impl>.
typedef ParserTypes<Impl> Types;
typedef typename v8::internal::ExpressionScope<Types> ExpressionScope;
typedef typename v8::internal::ExpressionParsingScope<Types>
ExpressionParsingScope;
typedef typename v8::internal::AccumulationScope<Types> AccumulationScope;
typedef typename v8::internal::ArrowHeadParsingScope<Types>
ArrowHeadParsingScope;
typedef typename v8::internal::VariableDeclarationParsingScope<Types>
VariableDeclarationParsingScope;
typedef typename v8::internal::ParameterDeclarationParsingScope<Types>
ParameterDeclarationParsingScope;
using Types = ParserTypes<Impl>;
using ExpressionScope = typename v8::internal::ExpressionScope<Types>;
using ExpressionParsingScope =
typename v8::internal::ExpressionParsingScope<Types>;
using AccumulationScope = typename v8::internal::AccumulationScope<Types>;
using ArrowHeadParsingScope =
typename v8::internal::ArrowHeadParsingScope<Types>;
using VariableDeclarationParsingScope =
typename v8::internal::VariableDeclarationParsingScope<Types>;
using ParameterDeclarationParsingScope =
typename v8::internal::ParameterDeclarationParsingScope<Types>;
// Return types for traversing functions.
typedef typename Types::Block BlockT;
typedef typename Types::BreakableStatement BreakableStatementT;
typedef typename Types::ClassLiteralProperty ClassLiteralPropertyT;
typedef typename Types::ClassPropertyList ClassPropertyListT;
typedef typename Types::Expression ExpressionT;
typedef typename Types::ExpressionList ExpressionListT;
typedef typename Types::FormalParameters FormalParametersT;
typedef typename Types::ForStatement ForStatementT;
typedef typename Types::FunctionLiteral FunctionLiteralT;
typedef typename Types::Identifier IdentifierT;
typedef typename Types::IterationStatement IterationStatementT;
typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT;
typedef typename Types::ObjectPropertyList ObjectPropertyListT;
typedef typename Types::Statement StatementT;
typedef typename Types::StatementList StatementListT;
typedef typename Types::Suspend SuspendExpressionT;
using BlockT = typename Types::Block;
using BreakableStatementT = typename Types::BreakableStatement;
using ClassLiteralPropertyT = typename Types::ClassLiteralProperty;
using ClassPropertyListT = typename Types::ClassPropertyList;
using ExpressionT = typename Types::Expression;
using ExpressionListT = typename Types::ExpressionList;
using FormalParametersT = typename Types::FormalParameters;
using ForStatementT = typename Types::ForStatement;
using FunctionLiteralT = typename Types::FunctionLiteral;
using IdentifierT = typename Types::Identifier;
using IterationStatementT = typename Types::IterationStatement;
using ObjectLiteralPropertyT = typename Types::ObjectLiteralProperty;
using ObjectPropertyListT = typename Types::ObjectPropertyList;
using StatementT = typename Types::Statement;
using StatementListT = typename Types::StatementList;
using SuspendExpressionT = typename Types::Suspend;
// For constructing objects returned by the traversing functions.
typedef typename Types::Factory FactoryT;
using FactoryT = typename Types::Factory;
// Other implementation-specific tasks.
typedef typename Types::FuncNameInferrer FuncNameInferrer;
typedef typename Types::FuncNameInferrer::State FuncNameInferrerState;
typedef typename Types::SourceRange SourceRange;
typedef typename Types::SourceRangeScope SourceRangeScope;
typedef typename Types::Target TargetT;
typedef typename Types::TargetScope TargetScopeT;
using FuncNameInferrer = typename Types::FuncNameInferrer;
using FuncNameInferrerState = typename Types::FuncNameInferrer::State;
using SourceRange = typename Types::SourceRange;
using SourceRangeScope = typename Types::SourceRangeScope;
using TargetT = typename Types::Target;
using TargetScopeT = typename Types::TargetScope;
// All implementation-specific methods must be called through this.
Impl* impl() { return static_cast<Impl*>(this); }
......
......@@ -137,36 +137,36 @@ struct ParserFormalParameters : FormalParametersBase {
template <>
struct ParserTypes<Parser> {
typedef ParserBase<Parser> Base;
typedef Parser Impl;
using Base = ParserBase<Parser>;
using Impl = Parser;
// Return types for traversing functions.
typedef v8::internal::Block* Block;
typedef v8::internal::BreakableStatement* BreakableStatement;
typedef ClassLiteral::Property* ClassLiteralProperty;
typedef ZonePtrList<ClassLiteral::Property>* ClassPropertyList;
typedef v8::internal::Expression* Expression;
typedef ScopedPtrList<v8::internal::Expression> ExpressionList;
typedef ParserFormalParameters FormalParameters;
typedef v8::internal::ForStatement* ForStatement;
typedef v8::internal::FunctionLiteral* FunctionLiteral;
typedef const AstRawString* Identifier;
typedef v8::internal::IterationStatement* IterationStatement;
typedef ObjectLiteral::Property* ObjectLiteralProperty;
typedef ScopedPtrList<v8::internal::ObjectLiteralProperty> ObjectPropertyList;
typedef v8::internal::Statement* Statement;
typedef ScopedPtrList<v8::internal::Statement> StatementList;
typedef v8::internal::Suspend* Suspend;
using Block = v8::internal::Block*;
using BreakableStatement = v8::internal::BreakableStatement*;
using ClassLiteralProperty = ClassLiteral::Property*;
using ClassPropertyList = ZonePtrList<ClassLiteral::Property>*;
using Expression = v8::internal::Expression*;
using ExpressionList = ScopedPtrList<v8::internal::Expression>;
using FormalParameters = ParserFormalParameters;
using ForStatement = v8::internal::ForStatement*;
using FunctionLiteral = v8::internal::FunctionLiteral*;
using Identifier = const AstRawString*;
using IterationStatement = v8::internal::IterationStatement*;
using ObjectLiteralProperty = ObjectLiteral::Property*;
using ObjectPropertyList = ScopedPtrList<v8::internal::ObjectLiteralProperty>;
using Statement = v8::internal::Statement*;
using StatementList = ScopedPtrList<v8::internal::Statement>;
using Suspend = v8::internal::Suspend*;
// For constructing objects returned by the traversing functions.
typedef AstNodeFactory Factory;
using Factory = AstNodeFactory;
// Other implementation-specific functions.
typedef v8::internal::FuncNameInferrer FuncNameInferrer;
typedef v8::internal::SourceRange SourceRange;
typedef v8::internal::SourceRangeScope SourceRangeScope;
typedef ParserTarget Target;
typedef ParserTargetScope TargetScope;
using FuncNameInferrer = v8::internal::FuncNameInferrer;
using SourceRange = v8::internal::SourceRange;
using SourceRangeScope = v8::internal::SourceRangeScope;
using Target = ParserTarget;
using TargetScope = ParserTargetScope;
};
class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
......@@ -496,7 +496,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
int pos_;
};
typedef TemplateLiteral* TemplateLiteralState;
using TemplateLiteralState = TemplateLiteral*;
TemplateLiteralState OpenTemplateLiteral(int pos);
// "should_cook" means that the span can be "cooked": in tagged template
......
......@@ -346,23 +346,23 @@ class PreParserExpression {
: code_(expression_code) {}
// The first three bits are for the Type.
typedef BitField<Type, 0, 3> TypeField;
using TypeField = BitField<Type, 0, 3>;
// The high order bit applies only to nodes which would inherit from the
// Expression ASTNode --- This is by necessity, due to the fact that
// Expression nodes may be represented as multiple Types, not exclusively
// through kExpression.
// TODO(caitp, adamk): clean up PreParserExpression bitfields.
typedef BitField<bool, TypeField::kNext, 1> IsParenthesizedField;
using IsParenthesizedField = BitField<bool, TypeField::kNext, 1>;
// The rest of the bits are interpreted depending on the value
// of the Type field, so they can share the storage.
typedef BitField<ExpressionType, IsParenthesizedField::kNext, 4>
ExpressionTypeField;
typedef BitField<PreParserIdentifier::Type, IsParenthesizedField::kNext, 8>
IdentifierTypeField;
typedef BitField<bool, IsParenthesizedField::kNext, 1>
HasCoverInitializedNameField;
using ExpressionTypeField =
BitField<ExpressionType, IsParenthesizedField::kNext, 4>;
using IdentifierTypeField =
BitField<PreParserIdentifier::Type, IsParenthesizedField::kNext, 8>;
using HasCoverInitializedNameField =
BitField<bool, IsParenthesizedField::kNext, 1>;
uint32_t code_;
friend class PreParser;
......@@ -873,36 +873,36 @@ class PreParserPropertyList {};
template <>
struct ParserTypes<PreParser> {
typedef ParserBase<PreParser> Base;
typedef PreParser Impl;
using Base = ParserBase<PreParser>;
using Impl = PreParser;
// Return types for traversing functions.
typedef PreParserExpression ClassLiteralProperty;
typedef PreParserExpression Expression;
typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpression Suspend;
typedef PreParserExpressionList ExpressionList;
typedef PreParserExpressionList ObjectPropertyList;
typedef PreParserFormalParameters FormalParameters;
typedef PreParserIdentifier Identifier;
typedef PreParserPropertyList ClassPropertyList;
typedef PreParserScopedStatementList StatementList;
typedef PreParserBlock Block;
typedef PreParserStatement BreakableStatement;
typedef PreParserStatement ForStatement;
typedef PreParserStatement IterationStatement;
typedef PreParserStatement Statement;
using ClassLiteralProperty = PreParserExpression;
using Expression = PreParserExpression;
using FunctionLiteral = PreParserExpression;
using ObjectLiteralProperty = PreParserExpression;
using Suspend = PreParserExpression;
using ExpressionList = PreParserExpressionList;
using ObjectPropertyList = PreParserExpressionList;
using FormalParameters = PreParserFormalParameters;
using Identifier = PreParserIdentifier;
using ClassPropertyList = PreParserPropertyList;
using StatementList = PreParserScopedStatementList;
using Block = PreParserBlock;
using BreakableStatement = PreParserStatement;
using ForStatement = PreParserStatement;
using IterationStatement = PreParserStatement;
using Statement = PreParserStatement;
// For constructing objects returned by the traversing functions.
typedef PreParserFactory Factory;
using Factory = PreParserFactory;
// Other implementation-specific tasks.
typedef PreParserFuncNameInferrer FuncNameInferrer;
typedef PreParserSourceRange SourceRange;
typedef PreParserSourceRangeScope SourceRangeScope;
typedef PreParserTarget Target;
typedef PreParserTargetScope TargetScope;
using FuncNameInferrer = PreParserFuncNameInferrer;
using SourceRange = PreParserSourceRange;
using SourceRangeScope = PreParserSourceRangeScope;
using Target = PreParserTarget;
using TargetScope = PreParserTargetScope;
};
......@@ -922,9 +922,9 @@ class PreParser : public ParserBase<PreParser> {
friend class ParserBase<PreParser>;
public:
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
typedef PreParserStatement Statement;
using Identifier = PreParserIdentifier;
using Expression = PreParserExpression;
using Statement = PreParserStatement;
enum PreParseResult {
kPreParseStackOverflow,
......
......@@ -54,14 +54,14 @@ struct CharTraits;
template <>
struct CharTraits<uint8_t> {
typedef SeqOneByteString String;
typedef ExternalOneByteString ExternalString;
using String = SeqOneByteString;
using ExternalString = ExternalOneByteString;
};
template <>
struct CharTraits<uint16_t> {
typedef SeqTwoByteString String;
typedef ExternalTwoByteString ExternalString;
using String = SeqTwoByteString;
using ExternalString = ExternalTwoByteString;
};
template <typename Char>
......@@ -79,7 +79,7 @@ struct Range {
template <typename Char>
class OnHeapStream {
public:
typedef typename CharTraits<Char>::String String;
using String = typename CharTraits<Char>::String;
OnHeapStream(Handle<String> string, size_t start_offset, size_t end)
: string_(string), start_offset_(start_offset), length_(end) {}
......@@ -109,7 +109,7 @@ class OnHeapStream {
// ExternalTwoByteString.
template <typename Char>
class ExternalStringStream {
typedef typename CharTraits<Char>::ExternalString ExternalString;
using ExternalString = typename CharTraits<Char>::ExternalString;
public:
ExternalStringStream(ExternalString string, size_t start_offset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment