-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite Rune to use a slot-based virtual machine
- Loading branch information
Showing
105 changed files
with
7,536 additions
and
3,839 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
members = [ | ||
"benches", | ||
"examples", | ||
"crates/rune", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use core::mem::take; | ||
|
||
use proc_macro2::Span; | ||
use rune_core::{ComponentRef, ItemBuf}; | ||
|
||
/// Construct a static item from a path. | ||
pub(crate) fn build_item(path: &syn::Path) -> syn::Result<syn::ExprArray> { | ||
let mut buf = ItemBuf::new(); | ||
let mut first = path.leading_colon.is_some(); | ||
|
||
for s in &path.segments { | ||
let ident = s.ident.to_string(); | ||
|
||
let c = if take(&mut first) { | ||
ComponentRef::Crate(&ident) | ||
} else { | ||
ComponentRef::Str(&ident) | ||
}; | ||
|
||
buf.push(c) | ||
.map_err(|error| syn::Error::new_spanned(s, error))?; | ||
|
||
match &s.arguments { | ||
syn::PathArguments::None => {} | ||
syn::PathArguments::AngleBracketed(generics) => { | ||
return Err(syn::Error::new_spanned( | ||
generics, | ||
"Generic arguments are not supported", | ||
)); | ||
} | ||
syn::PathArguments::Parenthesized(generics) => { | ||
return Err(syn::Error::new_spanned( | ||
generics, | ||
"Generic arguments are not supported", | ||
)); | ||
} | ||
} | ||
} | ||
|
||
let mut elems = syn::punctuated::Punctuated::new(); | ||
|
||
for &byte in buf.as_bytes() { | ||
let byte = syn::LitByte::new(byte, Span::call_site()); | ||
|
||
elems.push(syn::Expr::Lit(syn::ExprLit { | ||
attrs: Vec::new(), | ||
lit: syn::Lit::Byte(byte), | ||
})); | ||
} | ||
|
||
Ok(syn::ExprArray { | ||
attrs: Vec::new(), | ||
bracket_token: syn::token::Bracket::default(), | ||
elems, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[package] | ||
name = "rune" | ||
version = "0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.