[meta] Rename OperandKind::default_member to format_field_name;
This commit is contained in:
@@ -95,8 +95,8 @@ impl EncodingBuilder {
|
||||
&inst.inst.format,
|
||||
immediate_operand
|
||||
.kind
|
||||
.default_member()
|
||||
.expect("Immediates must always have a default member name set."),
|
||||
.rust_field_name()
|
||||
.expect("Immediates must always have a field name."),
|
||||
immediate_value.to_string(),
|
||||
);
|
||||
inst_predicate = if let Some(type_predicate) = inst_predicate {
|
||||
|
||||
@@ -127,7 +127,7 @@ impl InstructionFormatBuilder {
|
||||
pub fn imm(mut self, operand_kind: &OperandKind) -> Self {
|
||||
let field = FormatField {
|
||||
kind: operand_kind.clone(),
|
||||
member: operand_kind.default_member().unwrap(),
|
||||
member: operand_kind.rust_field_name().unwrap(),
|
||||
};
|
||||
self.imm_fields.push(field);
|
||||
self
|
||||
|
||||
@@ -112,7 +112,7 @@ pub(crate) enum OperandKindFields {
|
||||
pub(crate) struct OperandKind {
|
||||
pub name: &'static str,
|
||||
doc: Option<&'static str>,
|
||||
default_member: Option<&'static str>,
|
||||
rust_field_name: Option<&'static str>,
|
||||
/// The camel-cased name of an operand kind is also the Rust type used to represent it.
|
||||
pub rust_type: String,
|
||||
pub fields: OperandKindFields,
|
||||
@@ -122,7 +122,7 @@ impl OperandKind {
|
||||
fn new(
|
||||
name: &'static str,
|
||||
doc: Option<&'static str>,
|
||||
default_member: Option<&'static str>,
|
||||
rust_field_name: Option<&'static str>,
|
||||
rust_type: Option<&'static str>,
|
||||
fields: OperandKindFields,
|
||||
) -> Self {
|
||||
@@ -142,15 +142,15 @@ impl OperandKind {
|
||||
Self {
|
||||
name,
|
||||
doc,
|
||||
default_member,
|
||||
rust_field_name,
|
||||
rust_type,
|
||||
fields,
|
||||
}
|
||||
}
|
||||
|
||||
/// Name of this OperandKind in the format's member field.
|
||||
pub fn default_member(&self) -> Option<&'static str> {
|
||||
if let Some(member) = &self.default_member {
|
||||
pub fn rust_field_name(&self) -> Option<&'static str> {
|
||||
if let Some(member) = &self.rust_field_name {
|
||||
return Some(member);
|
||||
}
|
||||
match &self.fields {
|
||||
@@ -188,7 +188,7 @@ impl Into<OperandKind> for &OperandKind {
|
||||
pub(crate) struct OperandKindBuilder {
|
||||
name: &'static str,
|
||||
doc: Option<&'static str>,
|
||||
default_member: Option<&'static str>,
|
||||
rust_field_name: Option<&'static str>,
|
||||
rust_type: Option<&'static str>,
|
||||
fields: OperandKindFields,
|
||||
}
|
||||
@@ -198,7 +198,7 @@ impl OperandKindBuilder {
|
||||
Self {
|
||||
name,
|
||||
doc: None,
|
||||
default_member: None,
|
||||
rust_field_name: None,
|
||||
rust_type: None,
|
||||
fields,
|
||||
}
|
||||
@@ -207,7 +207,7 @@ impl OperandKindBuilder {
|
||||
Self {
|
||||
name,
|
||||
doc: None,
|
||||
default_member: None,
|
||||
rust_field_name: None,
|
||||
rust_type: None,
|
||||
fields: OperandKindFields::ImmValue,
|
||||
}
|
||||
@@ -216,7 +216,7 @@ impl OperandKindBuilder {
|
||||
Self {
|
||||
name,
|
||||
doc: None,
|
||||
default_member: None,
|
||||
rust_field_name: None,
|
||||
rust_type: None,
|
||||
fields: OperandKindFields::ImmEnum(values),
|
||||
}
|
||||
@@ -226,9 +226,9 @@ impl OperandKindBuilder {
|
||||
self.doc = Some(doc);
|
||||
self
|
||||
}
|
||||
pub fn default_member(mut self, default_member: &'static str) -> Self {
|
||||
assert!(self.default_member.is_none());
|
||||
self.default_member = Some(default_member);
|
||||
pub fn rust_field_name(mut self, rust_field_name: &'static str) -> Self {
|
||||
assert!(self.rust_field_name.is_none());
|
||||
self.rust_field_name = Some(rust_field_name);
|
||||
self
|
||||
}
|
||||
pub fn rust_type(mut self, rust_type: &'static str) -> Self {
|
||||
@@ -240,7 +240,7 @@ impl OperandKindBuilder {
|
||||
OperandKind::new(
|
||||
self.name,
|
||||
self.doc,
|
||||
self.default_member,
|
||||
self.rust_field_name,
|
||||
self.rust_type,
|
||||
self.fields,
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ impl EntityRefs {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
ebb: create("ebb", "An extended basic block in the same function.")
|
||||
.default_member("destination")
|
||||
.rust_field_name("destination")
|
||||
.build(),
|
||||
|
||||
stack_slot: create("stack_slot", "A stack slot").build(),
|
||||
@@ -48,7 +48,7 @@ impl EntityRefs {
|
||||
func_ref: create("func_ref", "An external function.").build(),
|
||||
|
||||
jump_table: create("jump_table", "A jump table.")
|
||||
.default_member("table")
|
||||
.rust_field_name("table")
|
||||
.build(),
|
||||
|
||||
heap: create("heap", "A heap.").build(),
|
||||
|
||||
@@ -95,13 +95,13 @@ impl Immediates {
|
||||
|
||||
pool_constant: Builder::new_imm("poolConstant")
|
||||
.doc("A constant stored in the constant pool.")
|
||||
.default_member("constant_handle")
|
||||
.rust_field_name("constant_handle")
|
||||
.rust_type("ir::Constant")
|
||||
.build(),
|
||||
|
||||
offset32: Builder::new_imm("offset32")
|
||||
.doc("A 32-bit immediate signed offset.")
|
||||
.default_member("offset")
|
||||
.rust_field_name("offset")
|
||||
.build(),
|
||||
|
||||
ieee32: Builder::new_imm("ieee32")
|
||||
@@ -133,7 +133,7 @@ impl Immediates {
|
||||
intcc_values.insert("nof", "NotOverflow");
|
||||
Builder::new_enum("intcc", intcc_values)
|
||||
.doc("An integer comparison condition code.")
|
||||
.default_member("cond")
|
||||
.rust_field_name("cond")
|
||||
.rust_type("ir::condcodes::IntCC")
|
||||
.build()
|
||||
},
|
||||
@@ -156,14 +156,14 @@ impl Immediates {
|
||||
floatcc_values.insert("uge", "UnorderedOrGreaterThanOrEqual");
|
||||
Builder::new_enum("floatcc", floatcc_values)
|
||||
.doc("A floating point comparison condition code")
|
||||
.default_member("cond")
|
||||
.rust_field_name("cond")
|
||||
.rust_type("ir::condcodes::FloatCC")
|
||||
.build()
|
||||
},
|
||||
|
||||
memflags: Builder::new_imm("memflags")
|
||||
.doc("Memory operation flags")
|
||||
.default_member("flags")
|
||||
.rust_field_name("flags")
|
||||
.rust_type("ir::MemFlags")
|
||||
.build(),
|
||||
|
||||
@@ -180,7 +180,7 @@ impl Immediates {
|
||||
trapcode_values.insert("int_divz", "IntegerDivisionByZero");
|
||||
Builder::new_enum("trapcode", trapcode_values)
|
||||
.doc("A trap reason code.")
|
||||
.default_member("code")
|
||||
.rust_field_name("code")
|
||||
.rust_type("ir::TrapCode")
|
||||
.build()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user