Skip to content

Commit

Permalink
section_mangler: Derive Clone on SectionMangler
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Apr 12, 2024
1 parent 6f310be commit 48b88b4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compiler/section_mangler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ mod parser;
/// The main builder type of this crate. Use it to create mangling contexts, in
/// order to encode and decode binary type information.
// TODO: Add example code for using this builder
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub enum SectionMangler {
Function(FunctionMangler),
Variable(VariableMangler),
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub struct FunctionMangler {
name: String,
parameters: Vec<FunctionArgument>,
return_type: Option<Type>,
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub struct VariableMangler {
name: String,
ty: Type,
Expand Down Expand Up @@ -116,7 +116,7 @@ impl SectionMangler {
// NOTE: This is called `variable_linkage` in the `MemberInfo` struct.

/// We have to encode this because if it changes, the function needs to be reloaded - this is an ABI breakage
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub enum FunctionArgument {
ByValue(Type),
ByRef(Type),
Expand All @@ -133,7 +133,7 @@ impl fmt::Display for FunctionArgument {
}

// TODO: Do we have to encode this? Does that affect ABI? Probably
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub enum StringEncoding {
// TODO: Should we encode this differently? this could cause problems compared to encoding unsigned types
/// Encoded as `8u`
Expand All @@ -153,7 +153,7 @@ impl fmt::Display for StringEncoding {

// This maps directly to the [`DataTypeInformation`] enum in RuSTy - we simply remove some fields and add the ability to encode/decode serialize/deserialize
// TODO: Do we have to handle Generic?
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub enum Type {
/// Encoded as `v`
Void,
Expand Down

0 comments on commit 48b88b4

Please sign in to comment.