Skip to content

Commit

Permalink
Refactor AST and interpreter, temporarily disable records (#48)
Browse files Browse the repository at this point in the history
* Flesh out new structure for interpreter (and eventual comp)

* Remove backup file

* Get everything building. This should be mostly correct

* Get most things back to working

* WIP

* Clean up

* Remove debug stuff
  • Loading branch information
maplant authored Dec 27, 2024
1 parent dd88133 commit f399324
Show file tree
Hide file tree
Showing 22 changed files with 2,164 additions and 2,116 deletions.
16 changes: 3 additions & 13 deletions benches/fib.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
use scheme_rs::{env::Env, lex::Token, syntax::ParsedSyntax};
use scheme_rs::env::Env;

use criterion::*;

async fn fib() {
let top = Env::top().await;

let r6rs_tok = Token::tokenize_file(include_str!("fib.scm"), "fib.scm").unwrap();
let r6rs_sexprs = ParsedSyntax::parse(&r6rs_tok).unwrap();
for sexpr in r6rs_sexprs {
sexpr
.compile(&top, &None)
.await
.unwrap()
.eval(&top, &None)
.await
.unwrap();
}
let _ = top.eval("fib.scm", include_str!("fib.scm")).await.unwrap();
}

fn fib_benchmark(c: &mut Criterion) {
c.bench_function("fib 100", |b| {
c.bench_function("fib 10000", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(fib)
});
Expand Down
2 changes: 1 addition & 1 deletion benches/fib.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
(iter b (+ a b) (- count 1))))
(iter 0 1 n))

(fib 100)
(fib 10000)
8 changes: 4 additions & 4 deletions proc-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub fn builtin(name: TokenStream, item: TokenStream) -> TokenStream {
fn #wrapper_name(
cont: Option<std::sync::Arc<::scheme_rs::continuation::Continuation>>,
args: Vec<::scheme_rs::gc::Gc<::scheme_rs::value::Value>>
) -> futures::future::BoxFuture<'static, Result<::scheme_rs::eval::ValuesOrPreparedCall, ::scheme_rs::error::RuntimeError>> {
) -> futures::future::BoxFuture<'static, Result<::scheme_rs::proc::ValuesOrPreparedCall, ::scheme_rs::error::RuntimeError>> {
Box::pin(
async move {
#impl_name(
&cont,
#( &args[#arg_indices], )*
).await.map(::scheme_rs::eval::ValuesOrPreparedCall::from)
).await.map(::scheme_rs::proc::ValuesOrPreparedCall::from)
}
)
}
Expand All @@ -50,15 +50,15 @@ pub fn builtin(name: TokenStream, item: TokenStream) -> TokenStream {
fn #wrapper_name(
cont: Option<std::sync::Arc<::scheme_rs::continuation::Continuation>>,
mut required_args: Vec<::scheme_rs::gc::Gc<::scheme_rs::value::Value>>
) -> futures::future::BoxFuture<'static, Result<::scheme_rs::eval::ValuesOrPreparedCall, ::scheme_rs::error::RuntimeError>> {
) -> futures::future::BoxFuture<'static, Result<::scheme_rs::proc::ValuesOrPreparedCall, ::scheme_rs::error::RuntimeError>> {
let var_args = required_args.split_off(#num_args);
Box::pin(
async move {
#impl_name(
&cont,
#( &required_args[#arg_indices], )*
var_args
).await.map(::scheme_rs::eval::ValuesOrPreparedCall::from)
).await.map(::scheme_rs::proc::ValuesOrPreparedCall::from)
}
)
}
Expand Down
211 changes: 0 additions & 211 deletions src/ast.rs

This file was deleted.

Loading

0 comments on commit f399324

Please sign in to comment.