diff --git a/src/compiler/definitions.rs b/src/compiler/definitions.rs index 2bf5c29..ffbafad 100644 --- a/src/compiler/definitions.rs +++ b/src/compiler/definitions.rs @@ -54,7 +54,7 @@ fn reduce(e: &AstNode, ctx: &mut Scope) -> Result<()> { .kind(match kind { Kind::Atomic => Kind::Atomic, Kind::Phantom => Kind::Phantom, - Kind::Composite(_) => Kind::Phantom, + Kind::Computed(_) => Kind::Phantom, }) .and_padding_value(*padding_value) .t(t.m()) diff --git a/src/compiler/generator.rs b/src/compiler/generator.rs index 91a8999..58cc43d 100644 --- a/src/compiler/generator.rs +++ b/src/compiler/generator.rs @@ -473,7 +473,8 @@ impl ConstraintSet { { match c { Computation::Interleaved { target, .. } - | Computation::CyclicFrom { target, .. } => { + | Computation::CyclicFrom { target, .. } + | Computation::Composite { target, .. } => { let col = self.columns.column(&target).unwrap(); let reg = self.columns.new_register(col.handle.clone(), col.t); self.columns.assign_register(&target, reg).unwrap(); @@ -1511,11 +1512,11 @@ pub fn reduce(e: &AstNode, ctx: &mut Scope, settings: &CompileSettings) -> Resul kind: k, .. } => match k { - Kind::Composite(e) => { + Kind::Computed(e) => { let n = reduce(e, ctx, settings)?.unwrap(); ctx.edit_symbol(name, &|x| { if let Expression::Column { kind, .. } = x { - *kind = Kind::Composite(Box::new(n.clone())) + *kind = Kind::Computed(Box::new(n.clone())) } })?; Ok(None) diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index da5cbdb..f588b1c 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -179,7 +179,7 @@ pub fn make, S2: AsRef>( let id = columns.insert_column(column)?; match k { Kind::Atomic | Kind::Phantom => (), - Kind::Composite(e) => computations + Kind::Computed(e) => computations .insert( &id, Computation::Composite { diff --git a/src/compiler/parser.rs b/src/compiler/parser.rs index de5b355..5e9afdc 100755 --- a/src/compiler/parser.rs +++ b/src/compiler/parser.rs @@ -152,14 +152,14 @@ pub enum Kind { Phantom, /// a composite column is similar to a phantom column, but the expression /// computing it is known - Composite(Box), + Computed(Box), } impl Kind { pub fn to_nil(&self) -> Kind<()> { match self { Kind::Atomic => Kind::Atomic, Kind::Phantom => Kind::Phantom, - Kind::Composite(_) => Kind::Composite(Box::new(())), + Kind::Computed(_) => Kind::Computed(Box::new(())), } } } @@ -618,6 +618,7 @@ struct ColumnAttributes { range: OnceCell, padding_value: OnceCell, base: OnceCell, + computation: Option, } impl std::convert::TryInto for ColumnAttributes { @@ -731,7 +732,10 @@ fn parse_column_attributes(source: AstNode) -> Result { })?; ColumnParser::Begin } - ColumnParser::Computation => todo!(), + ColumnParser::Computation => { + attributes.computation = Some(x); + ColumnParser::Begin + } ColumnParser::PaddingValue => { attributes.padding_value.set(x.as_i64()?).map_err(|_| { anyhow!( @@ -808,7 +812,10 @@ fn parse_defcolumns>>( .cloned() .unwrap_or(Magma::native()), ), - kind: Kind::Atomic, + kind: column_attributes + .computation + .map(|c| Kind::Computed(Box::new(c))) + .unwrap_or(Kind::Atomic), padding_value: column_attributes.padding_value.get().cloned(), base, } diff --git a/src/transformer.rs b/src/transformer.rs index 2bf7b9c..a4e5204 100644 --- a/src/transformer.rs +++ b/src/transformer.rs @@ -140,7 +140,7 @@ fn validate_computation(cs: &mut Vec, x_expr: &Node, x_col: &Handle) { x_expr.clone(), Node::column() .handle(x_col.to_owned()) - .kind(Kind::Composite(Box::new(x_expr.clone()))) + .kind(Kind::Computed(Box::new(x_expr.clone()))) .t(Magma::native()) .build(), ]) diff --git a/src/transformer/inverses.rs b/src/transformer/inverses.rs index 021bab7..e46df57 100644 --- a/src/transformer/inverses.rs +++ b/src/transformer/inverses.rs @@ -129,7 +129,7 @@ impl ConstraintSet { let inverted_id = self.columns.insert_column_and_register( Column::builder() .handle(inverted_handle.clone()) - .kind(Kind::Composite(Box::new(()))) + .kind(Kind::Computed(Box::new(()))) .build(), )?; diff --git a/src/transformer/splatter.rs b/src/transformer/splatter.rs index f65a9b1..a238089 100644 --- a/src/transformer/splatter.rs +++ b/src/transformer/splatter.rs @@ -277,7 +277,7 @@ impl ConstraintSet { .handle(new_handle.to_owned()) .t(new_magma) .base(Base::Hex) - .kind(Kind::Composite(Box::new(()))) + .kind(Kind::Computed(Box::new(()))) .build(), ) .unwrap();