Skip to content

Commit

Permalink
Merge rebuild of types onto this merge branch
Browse files Browse the repository at this point in the history
  • Loading branch information
prozacchiwawa committed Mar 6, 2024
1 parent b68405a commit 1b4d3c0
Show file tree
Hide file tree
Showing 20 changed files with 488 additions and 1,660 deletions.
36 changes: 14 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,3 @@ path = "src/classic/bins/clisp_to_json.rs"
[[bin]]
name = "repl"
path = "src/classic/bins/repl.rs"

[[bin]]
name = "typetest"
path = "src/classic/bins/typetest.rs"
66 changes: 0 additions & 66 deletions src/classic/bins/typetest.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/classic/clvm_tools/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul
.and_then(|pre_forms| {
let context = standard_type_context();
let compileform = frontend(opts.clone(), &pre_forms)?;
let target_type = context.typecheck_chialisp_program(&compileform)?;
let target_type = context.typecheck_chialisp_program(opts, &compileform)?;
Ok(context.reify(&target_type, None))
})
{
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ fn codegen_(
compiler: &PrimaryCodegen,
h: &HelperForm,
) -> Result<PrimaryCodegen, CompileErr> {
match &h {
match h {
HelperForm::Defun(inline, defun) => {
if *inline {
// Note: this just replaces a dummy function inserted earlier.
Expand Down Expand Up @@ -1326,7 +1326,7 @@ pub fn hoist_body_let_binding(
// new_expr is the generated code at the call site. The reference
// to the actual function additionally is enriched by a left-env
// reference that gives it access to the program.
let new_expr = lambda_codegen(&new_function_name, letdata);
let new_expr = lambda_codegen(&new_function_name, letdata)?;
Ok((new_helpers_from_body, Rc::new(new_expr)))
}
_ => Ok((Vec::new(), body.clone())),
Expand Down
7 changes: 7 additions & 0 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ lazy_static! {
(defmac list ARGS (__chia__compile-list ARGS))
(defun-inline / (A B) (f (divmod A B)))
(defun-inline c* (A B) (c A B))
(defun-inline a* (A B) (a A B))
(defun-inline coerce (X) : (Any -> Any) X)
(defun-inline explode (X) : (forall a ((Exec a) -> a)) X)
(defun-inline bless (X) : (forall a ((Pair a Unit) -> (Exec a))) (coerce X))
(defun-inline lift (X V) : (forall a (forall b ((Pair (Exec a) (Pair b Unit)) -> (Exec (Pair a b))))) (coerce X))
(defun-inline unlift (X) : (forall a (forall b ((Pair (Exec (Pair a b)) Unit) -> (Exec b)))) (coerce X))
)
"}
.to_string()
Expand Down
13 changes: 9 additions & 4 deletions src/compiler/comptypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ pub enum BodyForm {
Lambda(Box<LambdaData>),
}

/// Convey information about synthetically generated helper forms.
#[derive(Clone, Debug, Serialize)]
pub enum SyntheticType {
NoInlinePreference,
Expand Down Expand Up @@ -236,7 +235,7 @@ pub struct DefunData {
pub body: Rc<BodyForm>,
/// Whether this defun was created during desugaring.
pub synthetic: Option<SyntheticType>,
/// Type of this defun, if specified.
/// Type annotation if given.
pub ty: Option<Polytype>,
}

Expand Down Expand Up @@ -279,7 +278,7 @@ pub struct DefconstData {
pub body: Rc<BodyForm>,
/// This constant should exist in the left env rather than be inlined.
pub tabled: bool,
/// Type given of this constant if any.
/// Type annotation if given.
pub ty: Option<Polytype>,
}

Expand Down Expand Up @@ -401,6 +400,7 @@ pub struct CompileForm {
pub helpers: Vec<HelperForm>,
/// The expression the program evaluates, using the declared helpers.
pub exp: Rc<BodyForm>,
/// Type if specified.
pub ty: Option<Polytype>,
}

Expand Down Expand Up @@ -520,6 +520,7 @@ pub struct ModAccum {
pub loc: Srcloc,
pub includes: Vec<IncludeDesc>,
pub helpers: Vec<HelperForm>,
pub left_capture: bool,
pub exp_form: Option<CompileForm>,
}

Expand Down Expand Up @@ -556,6 +557,7 @@ impl ModAccum {
loc: self.loc.clone(),
includes: self.includes.clone(),
helpers: self.helpers.clone(),
left_capture: self.left_capture,
exp_form: Some(c.clone()),
}
}
Expand All @@ -567,6 +569,7 @@ impl ModAccum {
loc: self.loc.clone(),
includes: new_includes,
helpers: self.helpers.clone(),
left_capture: self.left_capture,
exp_form: self.exp_form.clone(),
}
}
Expand All @@ -579,15 +582,17 @@ impl ModAccum {
loc: self.loc.clone(),
includes: self.includes.clone(),
helpers: hs,
left_capture: self.left_capture,
exp_form: self.exp_form.clone(),
}
}

pub fn new(loc: Srcloc) -> ModAccum {
pub fn new(loc: Srcloc, left_capture: bool) -> ModAccum {
ModAccum {
loc,
includes: Vec::new(),
helpers: Vec::new(),
left_capture,
exp_form: None,
}
}
Expand Down
Loading

0 comments on commit 1b4d3c0

Please sign in to comment.