-
Notifications
You must be signed in to change notification settings - Fork 26
Conversation
- Move binaries into `bin` folder - History support - Command hinting - Matching bracket highlighting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good skeleton to add more features onto :)
- repl history is now saved in data_dir
- Any expression will be wrapped in a function - This function will be transmute'd into a rust function and then be called. - NOTE: Code doesn't compile right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick look, I haven't seen all of it.
src/bin/repl/helper.rs
Outdated
if !start.starts_with(PREFIX) { | ||
return None; | ||
} | ||
let start = &start[1..]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you need to abstract over the prefix, but if you do, be consistent:
let start = &start[1..]; | |
let start = &start[PREFIX.len()..]; |
src/bin/repl/mod.rs
Outdated
}), | ||
storage_class: data::StorageClass::Extern, | ||
qualifiers: Default::default(), | ||
id: saltwater::InternedStr::get_or_intern("execute"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id: saltwater::InternedStr::get_or_intern("execute"), | |
id: "execute".into(), |
src/bin/repl/mod.rs
Outdated
// FIXME: Currently doesn't work. Just make insert() pub? | ||
symbol: fun.insert(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the reason I make this private was because I was thinking about parsing and didn't want people to accidentally add a new identifier ... but it does seem like that would be a major use case for any programmatic use. I'm fine with making it public :)
// FIXME: error_handler is private so this doesn't work right now. | ||
// Please review and propose a solution. | ||
// if let Some(err) = analyzer.error_handler.pop_front() { | ||
// return Err(err); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, there isn't actually a way to get errors from PureAnalyzer
.
@pythondude325 I think we could add an errors()
method here? Where it just returns mem::take(&mut self.error_handler)
?
src/bin/swcc.rs
Outdated
@@ -554,7 +554,7 @@ mod backtrace { | |||
|
|||
#[cfg(feature = "salty")] | |||
fn play_scream() -> Result<(), ()> { | |||
const SCREAM: &[u8] = include_bytes!("data/R2D2-Scream.ogg"); | |||
const SCREAM: &[u8] = include_bytes!("../data/R2D2-Scream.ogg"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SCREAM: &[u8] = include_bytes!("../data/R2D2-Scream.ogg"); | |
const SCREAM: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "data/R2D2-Scream.ogg"))); |
- Add errors method to ErrorHandler - Make `Variable::insert` pub
macro_rules! execute { | ||
($fun:ident, $ty:path, $action:expr) => { | ||
$action(unsafe { | ||
let execute: unsafe extern "C" fn() -> $ty = std::mem::transmute($fun); | ||
execute() | ||
}); | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used like
execute!(fun, bool, |b| println!("=> {}", b)),
I think it would be easier and simpler to do println!("=> {}", execute!(fun, bool))
, which means you don't need $action
or to create a new closure.
Type::Float => execute!(fun, f32, |f| println!("=> {}", f)), | ||
Type::Double => execute!(fun, f64, |f| println!("=> {}", f)), | ||
|
||
Type::Char(_) => execute!(fun, char, |c| println!("=> {}", c)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look quite right ... in Rust, char
is a unicode scalar character which is represented as 4 bytes. In C, it's an arbitrary byte, which could be invalid utf8 (0xff
).
Type::Char(_) => execute!(fun, char, |c| println!("=> {}", c)), | |
Type::Char(_) => execute!(fun, u8, |c| println!("=> {}", if c.is_ascii() { c as char } else { `hex::encode(&[c]) })), |
Type::Void => unsafe { | ||
let execute: unsafe extern "C" fn() = std::mem::transmute(fun); | ||
execute() | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type::Void => unsafe { | |
let execute: unsafe extern "C" fn() = std::mem::transmute(fun); | |
execute() | |
}, | |
Type::Void => execute!(fun, (), |_| {}), |
I have to reopen because I accidentally deleted my fork (:sweat_smile:) |
This PR will introduce a proper Repl using rustyline and the
jit
backend.Only merge if #493 is merged
Resolves #372