add pipelines functionality
This commit is contained in:
parent
d11b8858ba
commit
aa0f258ea2
|
@ -218,50 +218,90 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
TypedExpr::Var {
|
TypedExpr::Var {
|
||||||
constructor, name, ..
|
constructor, name, ..
|
||||||
} => match (constructor.variant.clone(), (*constructor.tipo).clone()) {
|
} => {
|
||||||
(ValueConstructorVariant::LocalVariable { .. }, Type::App { module, .. }) => {
|
match constructor.variant.clone() {
|
||||||
if let Some(val) = self
|
ValueConstructorVariant::LocalVariable { .. } => {
|
||||||
.uplc_data_usage_holder_lookup
|
let mut is_app_type = false;
|
||||||
.get(&(module.to_string(), name.clone()))
|
let mut current_tipo: Type = (*constructor.tipo).clone();
|
||||||
{
|
let mut current_module = "".to_string();
|
||||||
if scope_level.is_less_than(val, false) {
|
while !is_app_type {
|
||||||
self.uplc_data_usage_holder_lookup
|
match current_tipo.clone() {
|
||||||
.insert((module, name.clone()), scope_level);
|
Type::App { module, .. } => {
|
||||||
|
is_app_type = true;
|
||||||
|
|
||||||
|
current_module = module.clone();
|
||||||
|
}
|
||||||
|
Type::Fn { .. } => todo!(),
|
||||||
|
Type::Var { tipo } => {
|
||||||
|
let x = tipo.borrow().clone();
|
||||||
|
|
||||||
|
match x {
|
||||||
|
tipo::TypeVar::Unbound { .. } => todo!(),
|
||||||
|
tipo::TypeVar::Link { tipo } => {
|
||||||
|
current_tipo = (*tipo).clone();
|
||||||
|
}
|
||||||
|
tipo::TypeVar::Generic { .. } => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(val) = self
|
||||||
|
.uplc_data_usage_holder_lookup
|
||||||
|
.get(&(current_module.to_string(), name.clone()))
|
||||||
|
{
|
||||||
|
if scope_level.is_less_than(val, false) {
|
||||||
|
self.uplc_data_usage_holder_lookup
|
||||||
|
.insert((current_module, name.clone()), scope_level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
ValueConstructorVariant::ModuleConstant { .. } => todo!(),
|
||||||
(ValueConstructorVariant::Record { .. }, Type::App { .. }) => {}
|
ValueConstructorVariant::ModuleFn { name, module, .. } => {
|
||||||
(ValueConstructorVariant::Record { .. }, Type::Fn { .. }) => {}
|
if self
|
||||||
(ValueConstructorVariant::ModuleFn { name, module, .. }, Type::Fn { .. }) => {
|
.uplc_function_holder_lookup
|
||||||
if self
|
|
||||||
.uplc_function_holder_lookup
|
|
||||||
.get(&(module.to_string(), name.to_string()))
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
let func_def = self
|
|
||||||
.functions
|
|
||||||
.get(&(module.to_string(), name.to_string()))
|
.get(&(module.to_string(), name.to_string()))
|
||||||
.unwrap();
|
.is_none()
|
||||||
|
{
|
||||||
|
let func_def = self
|
||||||
|
.functions
|
||||||
|
.get(&(module.to_string(), name.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
self.recurse_scope_level(
|
self.recurse_scope_level(
|
||||||
&func_def.body,
|
&func_def.body,
|
||||||
scope_level.scope_increment(func_def.arguments.len() as i32 + 1),
|
scope_level
|
||||||
);
|
.scope_increment_sequence(func_def.arguments.len() as i32 + 1),
|
||||||
|
);
|
||||||
|
|
||||||
self.uplc_function_holder_lookup
|
self.uplc_function_holder_lookup
|
||||||
.insert((module, name), scope_level);
|
.insert((module, name), scope_level);
|
||||||
} else if scope_level.is_less_than(
|
} else if scope_level.is_less_than(
|
||||||
self.uplc_function_holder_lookup
|
self.uplc_function_holder_lookup
|
||||||
.get(&(module.to_string(), name.to_string()))
|
.get(&(module.to_string(), name.to_string()))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
false,
|
false,
|
||||||
) {
|
) {
|
||||||
self.uplc_function_holder_lookup
|
let func_def = self
|
||||||
.insert((module, name), scope_level);
|
.functions
|
||||||
|
.get(&(module.to_string(), name.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
self.uplc_function_holder_lookup.insert(
|
||||||
|
(module, name),
|
||||||
|
scope_level
|
||||||
|
.scope_increment_sequence(func_def.arguments.len() as i32 + 1),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ValueConstructorVariant::Record { .. } => {
|
||||||
_ => todo!(),
|
match &*constructor.tipo {
|
||||||
},
|
Type::App { .. } => {}
|
||||||
|
Type::Fn { .. } | Type::Var { .. } => {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
TypedExpr::Fn { .. } => todo!(),
|
TypedExpr::Fn { .. } => todo!(),
|
||||||
TypedExpr::List { .. } => todo!(),
|
TypedExpr::List { .. } => todo!(),
|
||||||
TypedExpr::Call { fun, args, .. } => {
|
TypedExpr::Call { fun, args, .. } => {
|
||||||
|
@ -276,7 +316,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
self.recurse_scope_level(right, scope_level);
|
self.recurse_scope_level(right, scope_level);
|
||||||
}
|
}
|
||||||
TypedExpr::Assignment { value, pattern, .. } => {
|
TypedExpr::Assignment { value, pattern, .. } => {
|
||||||
self.recurse_scope_level_pattern(pattern, value, scope_level)
|
self.recurse_scope_level_pattern(pattern, value, scope_level.scope_increment(1))
|
||||||
}
|
}
|
||||||
TypedExpr::Try { .. } => todo!(),
|
TypedExpr::Try { .. } => todo!(),
|
||||||
TypedExpr::When {
|
TypedExpr::When {
|
||||||
|
@ -404,7 +444,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
self.recurse_scope_level(
|
self.recurse_scope_level(
|
||||||
&func_def.body,
|
&func_def.body,
|
||||||
scope_level.scope_increment(func_def.arguments.len() as i32 + 1),
|
scope_level
|
||||||
|
.scope_increment_sequence(func_def.arguments.len() as i32 + 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.uplc_function_holder_lookup
|
self.uplc_function_holder_lookup
|
||||||
|
@ -415,8 +456,16 @@ impl<'a> CodeGenerator<'a> {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
false,
|
false,
|
||||||
) {
|
) {
|
||||||
self.uplc_function_holder_lookup
|
let func_def = self
|
||||||
.insert((module.to_string(), name.to_string()), scope_level);
|
.functions
|
||||||
|
.get(&(module.to_string(), name.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
self.uplc_function_holder_lookup.insert(
|
||||||
|
(module.to_string(), name.to_string()),
|
||||||
|
scope_level
|
||||||
|
.scope_increment_sequence(func_def.arguments.len() as i32 + 1),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModuleValueConstructor::Constant { .. } => todo!(),
|
ModuleValueConstructor::Constant { .. } => todo!(),
|
||||||
|
@ -533,8 +582,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let mut term = self
|
let mut term = self
|
||||||
.recurse_code_gen(exp, scope_level.scope_increment_sequence(i as i32 + 1));
|
.recurse_code_gen(exp, scope_level.scope_increment_sequence(i as i32 + 1));
|
||||||
|
|
||||||
term =
|
term = self
|
||||||
self.maybe_insert_def(term, scope_level.scope_increment_sequence(i as i32));
|
.maybe_insert_def(term, scope_level.scope_increment_sequence(i as i32 + 1));
|
||||||
|
|
||||||
self.uplc_function_holder
|
self.uplc_function_holder
|
||||||
.push(("".to_string(), term.clone()));
|
.push(("".to_string(), term.clone()));
|
||||||
|
@ -554,7 +603,10 @@ impl<'a> CodeGenerator<'a> {
|
||||||
unique: 0.into(),
|
unique: 0.into(),
|
||||||
}),
|
}),
|
||||||
ValueConstructorVariant::ModuleConstant { .. } => todo!(),
|
ValueConstructorVariant::ModuleConstant { .. } => todo!(),
|
||||||
ValueConstructorVariant::ModuleFn { .. } => todo!(),
|
ValueConstructorVariant::ModuleFn { module, name, .. } => Term::Var(Name {
|
||||||
|
text: format!("{module}_{name}"),
|
||||||
|
unique: 0.into(),
|
||||||
|
}),
|
||||||
ValueConstructorVariant::Record { .. } => todo!(),
|
ValueConstructorVariant::Record { .. } => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,7 +959,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
argument: self
|
argument: self
|
||||||
.recurse_code_gen(value, scope_level.scope_increment_sequence(1))
|
.recurse_code_gen(value, scope_level.scope_increment(1))
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue