mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-25 18:49:50 -04:00
feat: Func shape derivation
This commit is contained in:
parent
bdfa424545
commit
b07147367c
@ -701,7 +701,7 @@ impl<'a> From<&'a PositionedItem<String>> for PositionedItem<String> {
|
|||||||
|
|
||||||
/// Encodes a func expression in the UCG AST..
|
/// 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)]
|
#[derive(PartialEq, Debug, Clone)]
|
||||||
pub struct FuncDef {
|
pub struct FuncDef {
|
||||||
pub scope: Option<Scope>,
|
pub scope: Option<Scope>,
|
||||||
@ -710,6 +710,16 @@ pub struct FuncDef {
|
|||||||
pub pos: Position,
|
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
|
/// Specifies the types of binary operations supported in
|
||||||
/// UCG expression.
|
/// UCG expression.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
@ -1003,7 +1013,7 @@ impl Expression {
|
|||||||
Expression::Copy(def) => derive_copy_shape(def, symbol_table),
|
Expression::Copy(def) => derive_copy_shape(def, symbol_table),
|
||||||
Expression::Include(def) => derive_include_shape(def),
|
Expression::Include(def) => derive_include_shape(def),
|
||||||
Expression::Call(_) => todo!(),
|
Expression::Call(_) => todo!(),
|
||||||
Expression::Func(_) => todo!(),
|
Expression::Func(def) => def.derive_shape(),
|
||||||
Expression::Select(_) => todo!(),
|
Expression::Select(_) => todo!(),
|
||||||
Expression::FuncOp(_) => todo!(),
|
Expression::FuncOp(_) => todo!(),
|
||||||
Expression::Module(_) => todo!(),
|
Expression::Module(_) => todo!(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user