Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
sisshiki1969 committed Dec 29, 2023
1 parent 1c9b7d7 commit 0e2a9bf
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 213 deletions.
577 changes: 383 additions & 194 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ruruby-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"

[dependencies]
fxhash = "0.2.1"
console = "0.15.0"
console = "0.15.0"
once_cell = "1.19.0"
File renamed without changes.
6 changes: 3 additions & 3 deletions ruruby-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![feature(once_cell)]
#![feature(lazy_cell)]
#![feature(pattern)]
pub mod arg_flag;
pub mod code_context;
pub mod error;
pub mod func_id;
pub mod id_table;
pub mod iseq;
pub mod iseq_util;
pub mod lvar_collector;
pub mod source_info;
pub mod vm_inst;
Expand All @@ -14,7 +14,7 @@ pub use code_context::*;
pub use error::*;
pub use func_id::FnId;
pub use id_table::IdentId;
pub use iseq::*;
pub use iseq_util::*;
pub use lvar_collector::*;
pub use source_info::*;
pub use vm_inst::Inst;
4 changes: 2 additions & 2 deletions ruruby/src/builtin/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub(crate) fn init(globals: &mut Globals) -> Value {

fn time_now(_: &mut VM, self_val: Value, args: &Args2) -> VMResult {
args.check_args_num(0)?;
let t = Utc::now().with_timezone(&FixedOffset::east(9 * 3600));
let t = Utc::now().with_timezone(&FixedOffset::east_opt(9 * 3600).unwrap());
let time_info = TimeInfo::Local(t);
let new_obj = Value::time(Module::new(self_val), time_info);
Ok(new_obj)
Expand Down Expand Up @@ -144,7 +144,7 @@ fn time_utc(vm: &mut VM, self_val: Value, args: &Args2) -> VMResult {
.ok_or_else(|| RubyError::argument("Out of range."))?
.and_hms_micro_opt(h as u32, min as u32, sec as u32, usec as u32)
.ok_or_else(|| RubyError::argument("Out of range."))?;
let time = TimeInfo::UTC(DateTime::<Utc>::from_utc(native_dt, Utc));
let time = TimeInfo::UTC(DateTime::<Utc>::from_naive_utc_and_offset(native_dt, Utc));
Ok(Value::time(Module::new(self_val), time))
}

Expand Down
3 changes: 1 addition & 2 deletions ruruby/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(box_patterns)]
#![feature(pattern)]
#![feature(naked_functions)]
#![feature(once_cell)]
#![feature(int_roundings)]
#![feature(new_uninit)]
extern crate arrayvec;
Expand Down Expand Up @@ -61,7 +60,7 @@ impl<T> Ref<T> {
}

pub(crate) fn free(self) {
unsafe { Box::from_raw(self.as_ptr()) };
let _ = unsafe { Box::from_raw(self.as_ptr()) };
}

#[inline(always)]
Expand Down
1 change: 0 additions & 1 deletion ruruby/src/vm/executor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::coroutine::FiberHandle;
use crate::*;
use fancy_regex::Captures;
pub use frame::arg_handler::*;
pub use frame::*;
use std::ops::Index;

Expand Down
28 changes: 18 additions & 10 deletions ruruby/src/vm/iseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ enum DestKind {
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) struct ISeqPtr(pub *const u8);
pub(crate) struct ISeqPtr(*const u8);

impl std::ops::Add<usize> for ISeqPtr {
type Output = Self;
Expand Down Expand Up @@ -491,23 +491,31 @@ impl ISeqPtr {

#[inline(always)]
pub(crate) fn read16(&mut self) -> u16 {
let u = unsafe { *(self.0 as *const u16) };
*self += 2;
u
let u1 = self.read8();
let u2 = self.read8();
u16::from_ne_bytes([u1, u2])
}

#[inline(always)]
pub(crate) fn read32(&mut self) -> u32 {
let u = unsafe { *(self.0 as *const u32) };
*self += 4;
u
let u1 = self.read8();
let u2 = self.read8();
let u3 = self.read8();
let u4 = self.read8();
u32::from_ne_bytes([u1, u2, u3, u4])
}

#[inline(always)]
pub(crate) fn read64(&mut self) -> u64 {
let u = unsafe { *(self.0 as *const u64) };
*self += 8;
u
let u1 = self.read8();
let u2 = self.read8();
let u3 = self.read8();
let u4 = self.read8();
let u5 = self.read8();
let u6 = self.read8();
let u7 = self.read8();
let u8 = self.read8();
u64::from_ne_bytes([u1, u2, u3, u4, u5, u6, u7, u8])
}

#[inline(always)]
Expand Down

0 comments on commit 0e2a9bf

Please sign in to comment.