Skip to content

Commit

Permalink
deserialize <OperandTypes>
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrain266 committed Aug 29, 2024
1 parent ba9cd18 commit a7d86e1
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 60 deletions.
60 changes: 60 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
# time = { version = "0.3.36", features = ["serde", "serde-human-readable"] }
time = { version = "0.3.36", features = ["serde", "serde-human-readable"] }

[dependencies.serde]
version = "1.0.209"
Expand Down
13 changes: 7 additions & 6 deletions src/dataformats/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::Deserialize;

#[derive(Debug, Default, PartialEq, Deserialize)]

#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Range {
#[serde(rename = "@Order")]
Expand All @@ -10,15 +11,15 @@ pub struct Range {
bit_offset: i8,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BitLayout {
#[serde(rename = "@RangeCount")]
range_count: i8,
range: Range,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Field {
#[serde(rename = "@Signedness")]
Expand All @@ -28,7 +29,7 @@ pub struct Field {
bit_layout: BitLayout,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BitMap {
#[serde(rename = "@Order")]
Expand All @@ -37,7 +38,7 @@ pub struct BitMap {
field: Option<Field>,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DataFormat {
pub data_format_name: String,
Expand All @@ -48,7 +49,7 @@ pub struct DataFormat {
pub data_attributes: BitMap,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DataFormats {
pub data_format: Vec<DataFormat>
Expand Down
24 changes: 12 additions & 12 deletions src/encodings/cond.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct SubExpressions {
pub expression: Vec<Expression>,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ValueType {
#[serde(rename = "@Name")]
pub name: String,
Expand All @@ -17,8 +17,8 @@ pub struct ValueType {
pub size: i8,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Expression {
#[serde(rename = "@Type")]
pub ty: Option<String>,
Expand All @@ -30,21 +30,21 @@ pub struct Expression {
pub value_type: Option<ValueType>,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ConditionExpression {
pub expression: Expression,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EncodingCondition {
pub condition_name: String,
pub condtion_expression: ConditionExpression,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EncodingConditions {
pub encoding_condition: Vec<EncodingCondition>,
}
8 changes: 4 additions & 4 deletions src/encodings/ident.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
pub struct EncodingIdentifier {
#[serde(rename = "@Radix")]
pub radix: i8,
#[serde(rename = "$text")]
pub text: String,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
pub struct EncodingIdentifierMask {
#[serde(rename = "@Radix")]
pub radix: i8,
#[serde(rename = "$text")]
pub text: String,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EncodingIdentifiers {
pub encoding_identifier: Vec<EncodingIdentifier>,
}
16 changes: 8 additions & 8 deletions src/encodings/microcode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Range {
#[serde(rename = "@Order")]
Expand All @@ -10,16 +10,16 @@ pub struct Range {
pub bit_offset: i8,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BitLayout {
#[serde(rename = "@RangeCount")]
pub range_count: i8,
pub range: Range,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Field {
#[serde(rename = "@IsConditional")]
pub is_conditional: bool,
Expand All @@ -29,14 +29,14 @@ pub struct Field {
pub bit_layout: BitLayout,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BitMap {
pub field: Vec<Field>,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct MicrocodeFormat {
pub bit_map: BitMap,
}
8 changes: 4 additions & 4 deletions src/encodings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod microcode;
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Encoding {
#[serde(rename = "@Order")]
pub order: i8,
Expand All @@ -22,8 +22,8 @@ pub struct Encoding {
pub microcode_format: microcode::MicrocodeFormat,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Encodings {
pub encoding: Vec<Encoding>,
}
12 changes: 6 additions & 6 deletions src/instructions/encodings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Operand {
#[serde(rename = "@Input")]
Expand All @@ -21,7 +21,7 @@ pub struct Operand {
pub operand_size: i16,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Operands {
pub operand: Option<Vec<Operand>>,
Expand All @@ -35,8 +35,8 @@ pub struct Opcode {
pub btext: i16,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct InstructionEncoding {
pub encoding_name: String,
pub encoding_condition: String,
Expand All @@ -45,8 +45,8 @@ pub struct InstructionEncoding {
}


#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct InstructionEncodings {
pub instruction_encoding: Vec<InstructionEncoding>,
}
12 changes: 6 additions & 6 deletions src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod encodings;
use serde::Deserialize;


#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct InstructionFlags {
pub is_branch: bool,
pub is_conditional_branch: bool,
Expand All @@ -13,8 +13,8 @@ pub struct InstructionFlags {
pub is_immediately_executed: bool,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Instruction {
pub instruction_name: String,
pub description: String,
Expand All @@ -23,8 +23,8 @@ pub struct Instruction {
pub functional_group: crate::FunctionalGroup,
}

#[derive(Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Instructions {
pub instruction: Vec<Instruction>,
}
Loading

0 comments on commit a7d86e1

Please sign in to comment.