Fixing some showstoppers

- inertness now tracked separately from gas
- atomic_impl now correctly rolls over when the argument is inert
- syntax fixes
- tree shaking
This commit is contained in:
2023-05-08 20:27:52 +01:00
parent a604e40bad
commit 6a381c5b57
28 changed files with 112 additions and 445 deletions

View File

@@ -13,7 +13,7 @@ use super::boolean::Boolean;
#[derive(Clone)]
pub struct Equals2;
externfn_impl!(Equals2, |_: &Self, x: ExprInst| {Ok(Equals1{x})});
externfn_impl!(Equals2, |_: &Self, x: ExprInst| Ok(Equals1{x}));
/// Partially applied Equals function
///

View File

@@ -13,7 +13,7 @@ use super::Boolean;
#[derive(Clone)]
pub struct IfThenElse1;
externfn_impl!(IfThenElse1, |_: &Self, x: ExprInst| {Ok(IfThenElse0{x})});
externfn_impl!(IfThenElse1, |_: &Self, x: ExprInst| Ok(IfThenElse0{x}));
/// Partially applied IfThenElse function
///

View File

@@ -15,7 +15,7 @@ use crate::{atomic_impl, atomic_redirect, externfn_impl};
#[derive(Clone)]
pub struct ParseFloat1;
externfn_impl!(ParseFloat1, |_: &Self, x: ExprInst| {Ok(ParseFloat0{x})});
externfn_impl!(ParseFloat1, |_: &Self, x: ExprInst| Ok(ParseFloat0{x}));
/// Applied to_string function
///

View File

@@ -14,7 +14,7 @@ use crate::parse::int_parser;
#[derive(Clone)]
pub struct ParseUint1;
externfn_impl!(ParseUint1, |_: &Self, x: ExprInst| {Ok(ParseUint0{x})});
externfn_impl!(ParseUint1, |_: &Self, x: ExprInst| Ok(ParseUint0{x}));
/// Applied ParseUint function
///

View File

@@ -11,7 +11,7 @@ use crate::{atomic_impl, atomic_redirect, externfn_impl};
#[derive(Clone)]
pub struct ToString1;
externfn_impl!(ToString1, |_: &Self, x: ExprInst| {Ok(ToString0{x})});
externfn_impl!(ToString1, |_: &Self, x: ExprInst| Ok(ToString0{x}));
/// Applied ToString function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::{Clause, ExprInst};
#[derive(Clone)]
pub struct Print2;
externfn_impl!(Print2, |_: &Self, x: ExprInst| {Ok(Print1{x})});
externfn_impl!(Print2, |_: &Self, x: ExprInst| Ok(Print1{x}));
/// Partially applied Print function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::{Clause, ExprInst};
#[derive(Clone)]
pub struct Readln2;
externfn_impl!(Readln2, |_: &Self, x: ExprInst| {Ok(Readln1{x})});
externfn_impl!(Readln2, |_: &Self, x: ExprInst| Ok(Readln1{x}));
/// Partially applied Readln function
///
@@ -23,7 +23,8 @@ pub struct Readln1{ x: ExprInst }
atomic_redirect!(Readln1, x);
atomic_impl!(Readln1, |Self{ x }: &Self| {
let mut buf = String::new();
stdin().read_line(&mut buf).map_err(|e| RuntimeError::ext(e.to_string(), "reading from stdin"))?;
stdin().read_line(&mut buf)
.map_err(|e| RuntimeError::ext(e.to_string(), "reading from stdin"))?;
buf.pop();
Ok(Clause::Apply {
f: x.clone(),

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::ExprInst;
#[derive(Clone)]
pub struct Add2;
externfn_impl!(Add2, |_: &Self, x: ExprInst| {Ok(Add1{x})});
externfn_impl!(Add2, |_: &Self, x: ExprInst| Ok(Add1{x}));
/// Partially applied Add function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::ExprInst;
#[derive(Clone)]
pub struct Divide2;
externfn_impl!(Divide2, |_: &Self, x: ExprInst| {Ok(Divide1{x})});
externfn_impl!(Divide2, |_: &Self, x: ExprInst| Ok(Divide1{x}));
/// Partially applied Divide function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::ExprInst;
#[derive(Clone)]
pub struct Multiply2;
externfn_impl!(Multiply2, |_: &Self, x: ExprInst| {Ok(Multiply1{x})});
externfn_impl!(Multiply2, |_: &Self, x: ExprInst| Ok(Multiply1{x}));
/// Partially applied Multiply function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::ExprInst;
#[derive(Clone)]
pub struct Remainder2;
externfn_impl!(Remainder2, |_: &Self, x: ExprInst| {Ok(Remainder1{x})});
externfn_impl!(Remainder2, |_: &Self, x: ExprInst| Ok(Remainder1{x}));
/// Partially applied Remainder function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::ExprInst;
#[derive(Clone)]
pub struct Subtract2;
externfn_impl!(Subtract2, |_: &Self, x: ExprInst| {Ok(Subtract1{x})});
externfn_impl!(Subtract2, |_: &Self, x: ExprInst| Ok(Subtract1{x}));
/// Partially applied Subtract function
///

View File

@@ -12,7 +12,7 @@ use crate::representations::interpreted::{Clause, ExprInst};
#[derive(Clone)]
pub struct CharAt2;
externfn_impl!(CharAt2, |_: &Self, x: ExprInst| {Ok(CharAt1{x})});
externfn_impl!(CharAt2, |_: &Self, x: ExprInst| Ok(CharAt1{x}));
/// Partially applied CharAt function
///

View File

@@ -11,7 +11,7 @@ use crate::representations::interpreted::{Clause, ExprInst};
#[derive(Clone)]
pub struct Concatenate2;
externfn_impl!(Concatenate2, |_: &Self, c: ExprInst| {Ok(Concatenate1{c})});
externfn_impl!(Concatenate2, |_: &Self, c: ExprInst| Ok(Concatenate1{c}));
/// Partially applied Concatenate function
///