Skip to content

Commit

Permalink
Renames typesMetadata to metadataTypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal committed Jul 23, 2024
1 parent 1eaec2c commit f44e59d
Show file tree
Hide file tree
Showing 252 changed files with 430 additions and 430 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

224 changes: 112 additions & 112 deletions sway-core/src/abi_generation/fuel_abi.rs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions sway-core/src/language/ty/ast_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ impl TypeCheckFinalization for TyAstNode {
}

impl CollectTypesMetadata for TyAstNode {
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
self.content.collect_types_metadata(handler, ctx)
self.content.collect_metadata_types(handler, ctx)
}
}

Expand Down Expand Up @@ -409,15 +409,15 @@ impl TypeCheckFinalization for TyAstNodeContent {
}

impl CollectTypesMetadata for TyAstNodeContent {
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
use TyAstNodeContent::*;
match self {
Declaration(decl) => decl.collect_types_metadata(handler, ctx),
Expression(expr) => expr.collect_types_metadata(handler, ctx),
Declaration(decl) => decl.collect_metadata_types(handler, ctx),
Expression(expr) => expr.collect_metadata_types(handler, ctx),
SideEffect(_) => Ok(vec![]),
Error(_, _) => Ok(vec![]),
}
Expand Down
12 changes: 6 additions & 6 deletions sway-core/src/language/ty/declaration/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,32 +396,32 @@ impl DebugWithEngines for TyDecl {

impl CollectTypesMetadata for TyDecl {
// this is only run on entry nodes, which must have all well-formed types
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
let decl_engine = ctx.engines.de();
let metadata = match self {
TyDecl::VariableDecl(decl) => {
let mut body = decl.body.collect_types_metadata(handler, ctx)?;
let mut body = decl.body.collect_metadata_types(handler, ctx)?;
body.append(
&mut decl
.type_ascription
.type_id
.collect_types_metadata(handler, ctx)?,
.collect_metadata_types(handler, ctx)?,
);
body
}
TyDecl::FunctionDecl(FunctionDecl { decl_id, .. }) => {
let decl = decl_engine.get_function(decl_id);
decl.collect_types_metadata(handler, ctx)?
decl.collect_metadata_types(handler, ctx)?
}
TyDecl::ConstantDecl(ConstantDecl { decl_id, .. }) => {
let decl = decl_engine.get_constant(decl_id);
let TyConstantDecl { value, .. } = &*decl;
if let Some(value) = value {
value.collect_types_metadata(handler, ctx)?
value.collect_metadata_types(handler, ctx)?
} else {
return Ok(vec![]);
}
Expand All @@ -430,7 +430,7 @@ impl CollectTypesMetadata for TyDecl {
let decl = decl_engine.get_configurable(decl_id);
let TyConfigurableDecl { value, .. } = &*decl;
if let Some(value) = value {
value.collect_types_metadata(handler, ctx)?
value.collect_metadata_types(handler, ctx)?
} else {
return Ok(vec![]);
}
Expand Down
10 changes: 5 additions & 5 deletions sway-core/src/language/ty/declaration/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,30 +249,30 @@ impl MonomorphizeHelper for TyFunctionDecl {
}

impl CollectTypesMetadata for TyFunctionDecl {
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
let mut body = vec![];
for content in self.body.contents.iter() {
body.append(&mut content.collect_types_metadata(handler, ctx)?);
body.append(&mut content.collect_metadata_types(handler, ctx)?);
}
body.append(
&mut self
.return_type
.type_id
.collect_types_metadata(handler, ctx)?,
.collect_metadata_types(handler, ctx)?,
);
for type_param in self.type_parameters.iter() {
body.append(&mut type_param.type_id.collect_types_metadata(handler, ctx)?);
body.append(&mut type_param.type_id.collect_metadata_types(handler, ctx)?);
}
for param in self.parameters.iter() {
body.append(
&mut param
.type_argument
.type_id
.collect_types_metadata(handler, ctx)?,
.collect_metadata_types(handler, ctx)?,
);
}
Ok(body)
Expand Down
70 changes: 35 additions & 35 deletions sway-core/src/language/ty/expression/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ impl TypeCheckFinalization for TyExpression {
}

impl CollectTypesMetadata for TyExpression {
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
use TyExpressionVariant::*;
let decl_engine = ctx.engines.de();
let mut res = self.return_type.collect_types_metadata(handler, ctx)?;
let mut res = self.return_type.collect_metadata_types(handler, ctx)?;
match &self.expression {
FunctionApplication {
arguments,
Expand All @@ -144,7 +144,7 @@ impl CollectTypesMetadata for TyExpression {
..
} => {
for arg in arguments.iter() {
res.append(&mut arg.1.collect_types_metadata(handler, ctx)?);
res.append(&mut arg.1.collect_metadata_types(handler, ctx)?);
}
let function_decl = decl_engine.get_function(fn_ref);

Expand All @@ -154,19 +154,19 @@ impl CollectTypesMetadata for TyExpression {
}

for content in function_decl.body.contents.iter() {
res.append(&mut content.collect_types_metadata(handler, ctx)?);
res.append(&mut content.collect_metadata_types(handler, ctx)?);
}
ctx.call_site_pop();
}
Tuple { fields } => {
for field in fields.iter() {
res.append(&mut field.collect_types_metadata(handler, ctx)?);
res.append(&mut field.collect_metadata_types(handler, ctx)?);
}
}
AsmExpression { registers, .. } => {
for register in registers.iter() {
if let Some(init) = register.initializer.as_ref() {
res.append(&mut init.collect_types_metadata(handler, ctx)?);
res.append(&mut init.collect_metadata_types(handler, ctx)?);
}
}
}
Expand All @@ -187,59 +187,59 @@ impl CollectTypesMetadata for TyExpression {
}
}
for field in fields.iter() {
res.append(&mut field.value.collect_types_metadata(handler, ctx)?);
res.append(&mut field.value.collect_metadata_types(handler, ctx)?);
}
}
LazyOperator { lhs, rhs, .. } => {
res.append(&mut lhs.collect_types_metadata(handler, ctx)?);
res.append(&mut rhs.collect_types_metadata(handler, ctx)?);
res.append(&mut lhs.collect_metadata_types(handler, ctx)?);
res.append(&mut rhs.collect_metadata_types(handler, ctx)?);
}
Array {
elem_type: _,
contents,
} => {
for content in contents.iter() {
res.append(&mut content.collect_types_metadata(handler, ctx)?);
res.append(&mut content.collect_metadata_types(handler, ctx)?);
}
}
ArrayIndex { prefix, index } => {
res.append(&mut (**prefix).collect_types_metadata(handler, ctx)?);
res.append(&mut (**index).collect_types_metadata(handler, ctx)?);
res.append(&mut (**prefix).collect_metadata_types(handler, ctx)?);
res.append(&mut (**index).collect_metadata_types(handler, ctx)?);
}
CodeBlock(block) => {
for content in block.contents.iter() {
res.append(&mut content.collect_types_metadata(handler, ctx)?);
res.append(&mut content.collect_metadata_types(handler, ctx)?);
}
}
MatchExp { desugared, .. } => {
res.append(&mut desugared.collect_types_metadata(handler, ctx)?)
res.append(&mut desugared.collect_metadata_types(handler, ctx)?)
}
IfExp {
condition,
then,
r#else,
} => {
res.append(&mut condition.collect_types_metadata(handler, ctx)?);
res.append(&mut then.collect_types_metadata(handler, ctx)?);
res.append(&mut condition.collect_metadata_types(handler, ctx)?);
res.append(&mut then.collect_metadata_types(handler, ctx)?);
if let Some(r#else) = r#else {
res.append(&mut r#else.collect_types_metadata(handler, ctx)?);
res.append(&mut r#else.collect_metadata_types(handler, ctx)?);
}
}
StructFieldAccess {
prefix,
resolved_type_of_parent,
..
} => {
res.append(&mut prefix.collect_types_metadata(handler, ctx)?);
res.append(&mut resolved_type_of_parent.collect_types_metadata(handler, ctx)?);
res.append(&mut prefix.collect_metadata_types(handler, ctx)?);
res.append(&mut resolved_type_of_parent.collect_metadata_types(handler, ctx)?);
}
TupleElemAccess {
prefix,
resolved_type_of_parent,
..
} => {
res.append(&mut prefix.collect_types_metadata(handler, ctx)?);
res.append(&mut resolved_type_of_parent.collect_types_metadata(handler, ctx)?);
res.append(&mut prefix.collect_metadata_types(handler, ctx)?);
res.append(&mut resolved_type_of_parent.collect_metadata_types(handler, ctx)?);
}
EnumInstantiation {
enum_ref,
Expand All @@ -252,55 +252,55 @@ impl CollectTypesMetadata for TyExpression {
ctx.call_site_insert(type_param.type_id, call_path_binding.inner.suffix.span())
}
if let Some(contents) = contents {
res.append(&mut contents.collect_types_metadata(handler, ctx)?);
res.append(&mut contents.collect_metadata_types(handler, ctx)?);
}
for variant in enum_decl.variants.iter() {
res.append(
&mut variant
.type_argument
.type_id
.collect_types_metadata(handler, ctx)?,
.collect_metadata_types(handler, ctx)?,
);
}
for type_param in enum_decl.type_parameters.iter() {
res.append(&mut type_param.type_id.collect_types_metadata(handler, ctx)?);
res.append(&mut type_param.type_id.collect_metadata_types(handler, ctx)?);
}
}
AbiCast { address, .. } => {
res.append(&mut address.collect_types_metadata(handler, ctx)?);
res.append(&mut address.collect_metadata_types(handler, ctx)?);
}
IntrinsicFunction(kind) => {
res.append(&mut kind.collect_types_metadata(handler, ctx)?);
res.append(&mut kind.collect_metadata_types(handler, ctx)?);
}
EnumTag { exp } => {
res.append(&mut exp.collect_types_metadata(handler, ctx)?);
res.append(&mut exp.collect_metadata_types(handler, ctx)?);
}
UnsafeDowncast {
exp,
variant,
call_path_decl: _,
} => {
res.append(&mut exp.collect_types_metadata(handler, ctx)?);
res.append(&mut exp.collect_metadata_types(handler, ctx)?);
res.append(
&mut variant
.type_argument
.type_id
.collect_types_metadata(handler, ctx)?,
.collect_metadata_types(handler, ctx)?,
);
}
WhileLoop { condition, body } => {
res.append(&mut condition.collect_types_metadata(handler, ctx)?);
res.append(&mut condition.collect_metadata_types(handler, ctx)?);
for content in body.contents.iter() {
res.append(&mut content.collect_types_metadata(handler, ctx)?);
res.append(&mut content.collect_metadata_types(handler, ctx)?);
}
}
ForLoop { desugared } => {
res.append(&mut desugared.collect_types_metadata(handler, ctx)?);
res.append(&mut desugared.collect_metadata_types(handler, ctx)?);
}
ImplicitReturn(exp) | Return(exp) => {
res.append(&mut exp.collect_types_metadata(handler, ctx)?)
res.append(&mut exp.collect_metadata_types(handler, ctx)?)
}
Ref(exp) | Deref(exp) => res.append(&mut exp.collect_types_metadata(handler, ctx)?),
Ref(exp) | Deref(exp) => res.append(&mut exp.collect_metadata_types(handler, ctx)?),
// storage access can never be generic
// variable expressions don't ever have return types themselves, they're stored in
// `TyExpression::return_type`. Variable expressions are just names of variables.
Expand All @@ -314,7 +314,7 @@ impl CollectTypesMetadata for TyExpression {
| Continue
| FunctionParameter => {}
Reassignment(reassignment) => {
res.append(&mut reassignment.rhs.collect_types_metadata(handler, ctx)?);
res.append(&mut reassignment.rhs.collect_metadata_types(handler, ctx)?);
}
}
Ok(res)
Expand Down
14 changes: 7 additions & 7 deletions sway-core/src/language/ty/expression/intrinsic_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ impl DebugWithEngines for TyIntrinsicFunctionKind {
}

impl CollectTypesMetadata for TyIntrinsicFunctionKind {
fn collect_types_metadata(
fn collect_metadata_types(
&self,
handler: &Handler,
ctx: &mut CollectTypesMetadataContext,
) -> Result<Vec<TypeMetadata>, ErrorEmitted> {
let mut types_metadata = vec![];
let mut metadata_types = vec![];
for type_arg in self.type_arguments.iter() {
types_metadata.append(&mut type_arg.type_id.collect_types_metadata(handler, ctx)?);
metadata_types.append(&mut type_arg.type_id.collect_metadata_types(handler, ctx)?);
}
for arg in self.arguments.iter() {
types_metadata.append(&mut arg.collect_types_metadata(handler, ctx)?);
metadata_types.append(&mut arg.collect_metadata_types(handler, ctx)?);
}

match self.kind {
Intrinsic::Log => {
let logged_type = self.get_logged_type(ctx.experimental.new_encoding).unwrap();
types_metadata.push(TypeMetadata::LoggedType(
metadata_types.push(TypeMetadata::LoggedType(
LogId::new(logged_type.get_abi_type_str(
&AbiStrContext {
program_name: ctx.program_name.clone(),
Expand All @@ -130,7 +130,7 @@ impl CollectTypesMetadata for TyIntrinsicFunctionKind {
));
}
Intrinsic::Smo => {
types_metadata.push(TypeMetadata::MessageType(
metadata_types.push(TypeMetadata::MessageType(
MessageId::new(ctx.message_id_counter()),
self.arguments[1].return_type,
));
Expand All @@ -139,6 +139,6 @@ impl CollectTypesMetadata for TyIntrinsicFunctionKind {
_ => {}
}

Ok(types_metadata)
Ok(metadata_types)
}
}
Loading

0 comments on commit f44e59d

Please sign in to comment.