Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Dec 5, 2023
1 parent 8732b7b commit 5834d8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion macro/src/dialect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn generate_dialect_module(
.map(Operation::from_definition)
.collect::<Result<Vec<_>, _>>()?
.into_iter()
.filter(|operation| operation.dialect.name() == dialect.name())
.filter(|operation| operation.dialect_name() == dialect.name())
.collect::<Vec<_>>();

let doc = format!(
Expand Down
21 changes: 14 additions & 7 deletions macro/src/dialect/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use crate::dialect::{
use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote, ToTokens, TokenStreamExt};
use syn::{parse_quote, Type};
use tblgen::{error::WithLocation, record::Record};
use tblgen::{
error::{SourceError, TableGenError, WithLocation},
record::Record,
};

#[derive(Debug, Clone, Copy)]
pub enum ElementKind {
Expand Down Expand Up @@ -291,12 +294,12 @@ impl<'a> OperationField<'a> {

#[derive(Debug, Clone)]
pub struct Operation<'a> {
pub(crate) dialect: Record<'a>,
pub(crate) short_name: &'a str,
pub(crate) full_name: String,
pub(crate) class_name: &'a str,
pub(crate) summary: String,
pub(crate) can_infer_type: bool,
dialect: Record<'a>,
short_name: &'a str,
full_name: String,
class_name: &'a str,
summary: String,
can_infer_type: bool,
description: String,
regions: Vec<OperationField<'a>>,
successors: Vec<OperationField<'a>>,
Expand All @@ -307,6 +310,10 @@ pub struct Operation<'a> {
}

impl<'a> Operation<'a> {
pub fn dialect_name(&self) -> Result<&str, SourceError<TableGenError>> {
self.dialect.name()
}

pub fn fields(&self) -> impl Iterator<Item = &OperationField<'a>> + Clone {
self.results
.iter()
Expand Down

0 comments on commit 5834d8a

Please sign in to comment.