feat: Func shape derivation

This commit is contained in:
Jeremy Wall 2023-09-02 09:27:01 -04:00 committed by Jeremy Wall
parent bdfa424545
commit b07147367c

View File

@ -701,7 +701,7 @@ impl<'a> From<&'a PositionedItem<String>> for PositionedItem<String> {
/// Encodes a func expression in the UCG AST..
///
/// A func is a pure function over a tuple.
/// A func is a pure function over a expression.
#[derive(PartialEq, Debug, Clone)]
pub struct FuncDef {
pub scope: Option<Scope>,
@ -710,6 +710,16 @@ pub struct FuncDef {
pub pos: Position,
}
impl FuncDef {
fn derive_shape(&self) -> Shape {
// 1. First set up our symbols.
let _table = self.argdefs.iter().map(|sym| (sym.val.clone(), Shape::Hole(sym.clone()))).collect::<BTreeMap<String, Shape>>();
// 2.Then determine the shapes of those symbols in our expression.
// 3. Finally determine what the return shape can be.
todo!();
}
}
/// Specifies the types of binary operations supported in
/// UCG expression.
#[derive(Debug, PartialEq, Clone)]
@ -1003,7 +1013,7 @@ impl Expression {
Expression::Copy(def) => derive_copy_shape(def, symbol_table),
Expression::Include(def) => derive_include_shape(def),
Expression::Call(_) => todo!(),
Expression::Func(_) => todo!(),
Expression::Func(def) => def.derive_shape(),
Expression::Select(_) => todo!(),
Expression::FuncOp(_) => todo!(),
Expression::Module(_) => todo!(),