Skip to content

Commit

Permalink
ast: rename field macro_args to macros
Browse files Browse the repository at this point in the history
  • Loading branch information
feds01 committed Aug 23, 2023
1 parent 06207c5 commit ea996aa
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 97 deletions.
18 changes: 9 additions & 9 deletions compiler/hash-ast-desugaring/src/desugaring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'s> AstDesugaring<'s> {
spread: None,
fields: ast::AstNodes::new(
thin_vec![ast::AstNode::new(
ast::PatArg { name: None, pat, macro_args: None },
ast::PatArg { name: None, pat, macros: None },
pat_span
)],
pat_span,
Expand All @@ -90,7 +90,7 @@ impl<'s> AstDesugaring<'s> {
ast::Expr::Block(ast::BlockExpr { data: for_body }),
body_span
),
macro_args: None
macros: None
},
pat_span
),
Expand All @@ -104,7 +104,7 @@ impl<'s> AstDesugaring<'s> {
},),
pat_span,
),
macro_args: None,
macros: None,
expr: ast::AstNode::new(
ast::Expr::Break(ast::BreakStatement {}),
body_span
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'s> AstDesugaring<'s> {
),
args: ast::AstNodes::new(
thin_vec![ast::AstNode::new(
ast::ExprArg { name: None, value: iterator, macro_args: None },
ast::ExprArg { name: None, value: iterator, macros: None },
iter_span
)],
iter_span,
Expand Down Expand Up @@ -219,7 +219,7 @@ impl<'s> AstDesugaring<'s> {
ast::Expr::Block(ast::BlockExpr { data: while_body }),
body_span
),
macro_args: None
macros: None
},
condition_span
),
Expand All @@ -238,7 +238,7 @@ impl<'s> AstDesugaring<'s> {
ast::Expr::Break(ast::BreakStatement {}),
condition_span
),
macro_args: None
macros: None
},
condition_span
)
Expand Down Expand Up @@ -293,7 +293,7 @@ impl<'s> AstDesugaring<'s> {
ast::Expr::Block(ast::BlockExpr { data: if_body }),
body_span,
),
macro_args: None,
macros: None,
},
branch_span,
)
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'s> AstDesugaring<'s> {
ast::Expr::Block(ast::BlockExpr { data: block }),
else_block_span,
),
macro_args: None,
macros: None,
},
else_block_span,
)
Expand All @@ -424,7 +424,7 @@ impl<'s> AstDesugaring<'s> {
}),
parent_span,
),
macro_args: None,
macros: None,
},
parent_span,
)
Expand Down
18 changes: 9 additions & 9 deletions compiler/hash-ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ define_tree! {
#[node]
pub struct ExprMacroInvocation {
/// The directives that apply on the subject expression.
pub macro_args: Child!(MacroInvocations),
pub macros: Child!(MacroInvocations),

/// The subjection expression of the invocation.
pub subject: Child!(Expr),
Expand All @@ -478,7 +478,7 @@ define_tree! {
#[node]
pub struct TyMacroInvocation {
/// The directives that apply on the subject type.
pub macro_args: Child!(MacroInvocations),
pub macros: Child!(MacroInvocations),

/// The subject type of the invocation.
pub subject: Child!(Ty),
Expand All @@ -489,7 +489,7 @@ define_tree! {
#[node]
pub struct PatMacroInvocation {
/// The directives that apply on the subject pattern.
pub macro_args: Child!(MacroInvocations),
pub macros: Child!(MacroInvocations),

/// The subject pattern of the invocation.
pub subject: Child!(Pat),
Expand Down Expand Up @@ -559,7 +559,7 @@ define_tree! {
pub ty: Child!(Ty),

/// Any macros are invoked on the parameter.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

/// The tuple type.
Expand Down Expand Up @@ -948,7 +948,7 @@ define_tree! {
pub pat: Child!(Pat),

/// Any applied macro invocations on this argument.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

/// A tuple pattern, e.g. `(1, 2, x)`
Expand Down Expand Up @@ -1431,7 +1431,7 @@ define_tree! {
pub ty: OptionalChild!(Ty),

/// Any macro invocations that occur on the enum variant.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

/// An enum definition, e.g.
Expand Down Expand Up @@ -1498,7 +1498,7 @@ define_tree! {
pub expr: Child!(Expr),

/// Any macro invocations that occur on this match case.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

impl MatchCase {
Expand Down Expand Up @@ -1846,7 +1846,7 @@ define_tree! {
pub origin: ParamOrigin,

/// Any macros are invoked on the parameter.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

/// A function definition.
Expand Down Expand Up @@ -1875,7 +1875,7 @@ define_tree! {
pub value: Child!(Expr),

/// Any macros are invoked on the parameter.
pub macro_args: OptionalChild!(MacroInvocations),
pub macros: OptionalChild!(MacroInvocations),
}

/// A constructor call expression. This can either be a function
Expand Down
46 changes: 20 additions & 26 deletions compiler/hash-ast/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::TyArg>,
) -> Result<Self::TyArgRet, Self::Error> {
let walk::TyArg { name, ty, macro_args } = walk::walk_ty_arg(self, node)?;
let walk::TyArg { name, ty, macros } = walk::walk_ty_arg(self, node)?;

if name.is_some() || macro_args.is_some() {
if name.is_some() || macros.is_some() {
let children = iter::empty()
.chain(name.map(|t| TreeNode::branch("name", vec![t])))
.chain(iter::once(TreeNode::branch("type", vec![ty])))
.chain(macro_args)
.chain(macros)
.collect_vec();

Ok(TreeNode::branch("field", children))
Expand Down Expand Up @@ -515,13 +515,13 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::Param>,
) -> Result<Self::ParamRet, Self::Error> {
let walk::Param { name, ty, default, macro_args } = walk::walk_param(self, node)?;
let walk::Param { name, ty, default, macros } = walk::walk_param(self, node)?;

let children = iter::empty()
.chain(name.map(|t| TreeNode::branch("name", vec![t])))
.chain(ty.map(|t| TreeNode::branch("type", vec![t])))
.chain(default.map(|d| TreeNode::branch("default", vec![d])))
.chain(macro_args)
.chain(macros)
.collect_vec();

Ok(TreeNode::branch("param", children))
Expand All @@ -541,12 +541,12 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::MatchCase>,
) -> Result<Self::MatchCaseRet, Self::Error> {
let walk::MatchCase { expr, pat, macro_args } = walk::walk_match_case(self, node)?;
let walk::MatchCase { expr, pat, macros } = walk::walk_match_case(self, node)?;

let mut children = vec![pat, TreeNode::branch("branch", vec![expr])];

if let Some(macro_args) = macro_args {
children.push(macro_args)
if let Some(macros) = macros {
children.push(macros)
}

Ok(TreeNode::branch("case", children))
Expand Down Expand Up @@ -852,7 +852,7 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::EnumDefEntry>,
) -> Result<Self::EnumDefEntryRet, Self::Error> {
let walk::EnumDefEntry { name, fields, ty, macro_args } =
let walk::EnumDefEntry { name, fields, ty, macros } =
walk::walk_enum_def_entry(self, node)?;
let mut children = Vec::new();

Expand All @@ -864,8 +864,8 @@ impl AstVisitor for AstTreeGenerator {
children.push(TreeNode::branch("type", vec![ty]))
}

if let Some(macro_args) = macro_args {
children.push(macro_args)
if let Some(macros) = macros {
children.push(macros)
}

Ok(TreeNode::branch(labelled("variant", name.label, "\""), children))
Expand Down Expand Up @@ -962,16 +962,16 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::PatArg>,
) -> Result<Self::PatArgRet, Self::Error> {
let walk::PatArg { name, pat, macro_args } = walk::walk_pat_arg(self, node)?;
let walk::PatArg { name, pat, macros } = walk::walk_pat_arg(self, node)?;

let mut children = name
.map(|t| TreeNode::branch("name", vec![t]))
.into_iter()
.chain(iter::once(TreeNode::branch("pattern", vec![pat])))
.collect_vec();

if let Some(macro_args) = macro_args {
children.push(macro_args);
if let Some(macros) = macros {
children.push(macros);
}

Ok(TreeNode::branch("entry", children))
Expand Down Expand Up @@ -1194,12 +1194,12 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::PatMacroInvocation>,
) -> Result<Self::PatMacroInvocationRet, Self::Error> {
let walk::PatMacroInvocation { macro_args, subject } =
let walk::PatMacroInvocation { macros, subject } =
walk::walk_pat_macro_invocation(self, node)?;

Ok(TreeNode::branch(
"pattern_macro",
vec![macro_args, TreeNode::branch("pattern", vec![subject])],
vec![macros, TreeNode::branch("pattern", vec![subject])],
))
}

Expand All @@ -1209,13 +1209,10 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::ExprMacroInvocation>,
) -> Result<Self::ExprMacroInvocationRet, Self::Error> {
let walk::ExprMacroInvocation { macro_args, subject } =
let walk::ExprMacroInvocation { macros, subject } =
walk::walk_expr_macro_invocation(self, node)?;

Ok(TreeNode::branch(
"expr_macro",
vec![macro_args, TreeNode::branch("expr", vec![subject])],
))
Ok(TreeNode::branch("expr_macro", vec![macros, TreeNode::branch("expr", vec![subject])]))
}

type TyMacroInvocationRet = TreeNode;
Expand All @@ -1224,13 +1221,10 @@ impl AstVisitor for AstTreeGenerator {
&self,
node: ast::AstNodeRef<ast::TyMacroInvocation>,
) -> Result<Self::TyMacroInvocationRet, Self::Error> {
let walk::TyMacroInvocation { macro_args, subject } =
let walk::TyMacroInvocation { macros, subject } =
walk::walk_ty_macro_invocation(self, node)?;

Ok(TreeNode::branch(
"type_macro",
vec![macro_args, TreeNode::branch("type", vec![subject])],
))
Ok(TreeNode::branch("type_macro", vec![macros, TreeNode::branch("type", vec![subject])]))
}

type MacroInvocationArgsRet = TreeNode;
Expand Down
Loading

0 comments on commit ea996aa

Please sign in to comment.