Using rc we now get code that runs much faster and

can run jpg contract with no inputs
This commit is contained in:
Kasey White
2022-08-17 05:21:40 -04:00
committed by Lucas
parent fb81955f51
commit 2bb482d9ec
11 changed files with 219 additions and 190 deletions

View File

@@ -1,3 +1,5 @@
use std::rc::Rc;
use crate::ast::{Name, Term};
use crate::program_builder::WithTerm;
@@ -30,8 +32,8 @@ impl<T: WithTerm> WithTerm for ApplyBuilderArgument<T> {
fn next(self, term: Term<Name>) -> Self::Next {
let term = Term::Apply {
function: Box::new(self.function),
argument: Box::new(term),
function: Rc::new(self.function),
argument: Rc::new(term),
};
self.outer.next(term)
}

View File

@@ -1,3 +1,5 @@
use std::rc::Rc;
use crate::ast::{Name, Term};
use crate::program_builder::WithTerm;
@@ -9,7 +11,7 @@ impl<T: WithTerm> WithTerm for DelayBuilder<T> {
type Next = T::Next;
fn next(self, term: Term<Name>) -> Self::Next {
let term = Term::Delay(Box::new(term));
let term = Term::Delay(Rc::new(term));
self.outer.next(term)
}

View File

@@ -1,3 +1,5 @@
use std::rc::Rc;
use crate::ast::{Name, Term};
use crate::program_builder::WithTerm;
@@ -9,7 +11,7 @@ impl<T: WithTerm> WithTerm for ForceBuilder<T> {
type Next = T::Next;
fn next(self, term: Term<Name>) -> Self::Next {
let term = Term::Force(Box::new(term));
let term = Term::Force(Rc::new(term));
self.outer.next(term)
}

View File

@@ -1,3 +1,5 @@
use std::rc::Rc;
use crate::ast::{Name, Term};
use crate::program_builder::WithTerm;
@@ -12,7 +14,7 @@ impl<T: WithTerm> WithTerm for LambdaBuilder<T> {
fn next(self, term: Term<Name>) -> Self::Next {
let term = Term::Lambda {
parameter_name: self.parameter_name,
body: Box::new(term),
body: Rc::new(term),
};
self.outer.next(term)
}