fix sign error in shl on fixnum with n >= 63 (#499)
This commit is contained in:
@@ -781,9 +781,14 @@ impl MachineState {
|
|||||||
match (n1, n2) {
|
match (n1, n2) {
|
||||||
(Number::Fixnum(n1), Number::Fixnum(n2)) => {
|
(Number::Fixnum(n1), Number::Fixnum(n2)) => {
|
||||||
if let Ok(n2) = u32::try_from(n2) {
|
if let Ok(n2) = u32::try_from(n2) {
|
||||||
|
if n2 < 63 {
|
||||||
if let Some(result) = n1.checked_shl(n2) {
|
if let Some(result) = n1.checked_shl(n2) {
|
||||||
return Ok(Number::from(result));
|
return Ok(Number::from(result));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let n1 = Integer::from(n1);
|
||||||
|
return Ok(Number::from(n1 << n2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let n1 = Integer::from(n1);
|
let n1 = Integer::from(n1);
|
||||||
|
|||||||
@@ -462,32 +462,35 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wam.compile_scryerrc();
|
wam.compile_scryerrc();
|
||||||
|
wam.configure_streams();
|
||||||
wam.current_input_stream.options.alias = Some(clause_name!("user_input"));
|
|
||||||
|
|
||||||
wam.indices.stream_aliases.insert(
|
|
||||||
clause_name!("user_input"),
|
|
||||||
wam.current_input_stream.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
wam.indices.streams.insert(
|
|
||||||
wam.current_input_stream.clone()
|
|
||||||
);
|
|
||||||
|
|
||||||
wam.current_output_stream.options.alias = Some(clause_name!("user_output"));
|
|
||||||
|
|
||||||
wam.indices.stream_aliases.insert(
|
|
||||||
clause_name!("user_output"),
|
|
||||||
wam.current_output_stream.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
wam.indices.streams.insert(
|
|
||||||
wam.current_output_stream.clone()
|
|
||||||
);
|
|
||||||
|
|
||||||
wam
|
wam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn configure_streams(&mut self) {
|
||||||
|
self.current_input_stream.options.alias = Some(clause_name!("user_input"));
|
||||||
|
|
||||||
|
self.indices.stream_aliases.insert(
|
||||||
|
clause_name!("user_input"),
|
||||||
|
self.current_input_stream.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.indices.streams.insert(
|
||||||
|
self.current_input_stream.clone()
|
||||||
|
);
|
||||||
|
|
||||||
|
self.current_output_stream.options.alias = Some(clause_name!("user_output"));
|
||||||
|
|
||||||
|
self.indices.stream_aliases.insert(
|
||||||
|
clause_name!("user_output"),
|
||||||
|
self.current_output_stream.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.indices.streams.insert(
|
||||||
|
self.current_output_stream.clone()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn machine_flags(&self) -> MachineFlags {
|
pub fn machine_flags(&self) -> MachineFlags {
|
||||||
self.machine_st.flags
|
self.machine_st.flags
|
||||||
|
|||||||
@@ -42,10 +42,16 @@ pub mod readline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ReadlineStream {
|
impl ReadlineStream {
|
||||||
pub fn input_stream(pending_input: String) -> Stream {
|
#[inline]
|
||||||
|
pub fn new(pending_input: String) -> Self {
|
||||||
let mut rl = Editor::<()>::new();
|
let mut rl = Editor::<()>::new();
|
||||||
rl.bind_sequence(KeyPress::Tab, Cmd::Insert(1, "\t".to_string()));
|
rl.bind_sequence(KeyPress::Tab, Cmd::Insert(1, "\t".to_string()));
|
||||||
Stream::from(ReadlineStream { rl, pending_input: Cursor::new(pending_input) })
|
ReadlineStream { rl, pending_input: Cursor::new(pending_input) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn input_stream(pending_input: String) -> Stream {
|
||||||
|
Stream::from(Self::new(pending_input))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_readline(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
fn call_readline(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||||
|
|||||||
Reference in New Issue
Block a user