Coder Social home page Coder Social logo

artichoke / artichoke Goto Github PK

View Code? Open in Web Editor NEW
3.0K 3.0K 111.0 58.19 MB

๐Ÿ’Ž Artichoke is a Ruby made with Rust

Home Page: https://www.artichokeruby.org/

License: MIT License

Rust 92.30% Ruby 7.03% C 0.64% Shell 0.03%
artichoke language programming-language ruby ruby-language rust rust-application rust-crate wasm webassembly

artichoke's Issues

Implement the Ruby 2.6 standard library tracking ticket

Implement the Ruby 2.6.3 Standard Library.

This ticket tracks the scheduling and completion of the [Standard Library Milestone]. Checkmarks mean a ticket to track package implementation has been created.

Remove dependency on mruby-*-ext mrbgems

These implementations of Ruby core methods have been mostly buggy and not spec-compliant.

Use them as a starting point to implement them natively in Rust/evaled Ruby with the goal of passing ruby/spec.

  • mruby-compar-ext
  • mruby-enum-ext
  • mruby-numeric-ext
  • mruby-array-ext
  • mruby-hash-ext
  • mruby-range-ext
  • mruby-proc-ext
  • mruby-symbol-ext
  • mruby-object-ext
  • mruby-kernel-ext
  • mruby-class-ext

Split global (singleton) functions out of method.rs

Global functions are always implemented on top_self so they do not take a parent sys::RClass *. We also likely want to keep a separate registry for them to make them easier to create.

Once we implement support for proc-macros (see #38), these functions will have a separate creation pathway, too.

Artichoke tracking ticket

The focus of this repository is changing and the scope is growing. We are building a Ruby ๐Ÿ’Ž!

Artichoke aims to be a source-compatible, ruby/spec compliant implementation of Ruby 2.6.3 written in safe Rust (excluding crate dependencies).

Go get there, we'll use the mruby base and continue to rip parts of it out of libmruby.a into the mruby crate with the goal of passing as many of the core specs as possible only by removing dependencies on mrbgems.

Complete the implementation of Ruby stdlib.

Implement File and IO in Ruby core.

Once the mrbgem dependencies are minimized, start reimplmenting the mruby C API in Rust one header at a time. There are 311 C functions.

Then we'll be left with the compiler, parser, GC, mrb_state, and VM. Figure out a way to migrate these into Rust.

Build a ruby CLI frontend.

Build support for concurrent Threads.

Implement $LOAD_PATH

Currently, the load path for require is hardcoded as /src/lib. This value should be exposed via the $LOAD_PATH global and Kernel#require should respect this configuration.

  • $LOAD_PATH global
  • read $LOAD_PATH in require Rust implementation
  • support trying multiple load locations

NOTE: mruby does not support aliasing globals so we should punt on implementing the $: shorthand alias (even though we could with shared Rust state and the proposed global registry, see artichoke/ferrocarril#14).

Implement File

Implement the File class in Rust so that it is backed by the vfs on the State.

Turn MRB_TT_EXCEPTION Values into MrbError::Exec

If an exception is thrown in the context of a C API call, the returned mrb_value is of type mrb_vtype::MRB_TT_EXCEPTION. Turn this exception into an Err(MrbError::Exec(_)).

Maybe as part of a funcall interface on Value?

Implement Convert<HashMap<Value, Value>>

Once #28 lands, Value is a valid key for a HashMap.

Implementing Convert<HashMap<Value, Value>> allows us to follow the same approach as Array and massively simplify the macro madness in hash.rs.

I think this should also unify the special-cased &str converters.

Revendor mruby and re-enable thread test when upstream bug is fixed

The vendored version of mruby has a bug where in some situations comments do not increment the line number in the parser. This breaks tests which test stack traces. thread.rs has one of these tests that has been disabled. Pull in the upstream bugfix and re-enable the test.

Upstream bug: mruby/mruby#4513

Disabled test:

https://github.com/lopopolo/ferrocarril/blob/329c544006b619b7b4fac9c96b6b5ec51a311a84/mruby/src/extn/core/thread.rs#L155-L194

Remove RefCell from Class and Module specs

Just make Define mutable and store the RClass. In ClassLike::rclass, short circuit if rclass is Some and resolve the RClass using the mruby C API. Don't store this result to keep the API simple and not require mutability.

Move path canonicalization into fs module

Right now path canonicalization and absolutifying lives in the implementation of Kernel#require. This means that I think this code behaves unexpectedly:

interp.def_rb_source_file("../spec_helper.rb", "")

Move path canonicalization into the fs layer.

Don't mutably borrow in Define::define

This code looks like it should work but it panics:

let metrics = interp
            .borrow()
            .module_spec::<Metrics>();
            .and_then(|spec| spec.borrow().value(&interp));

See if there is a way to fix this. Maybe by interning the symbol when we have the mutable borrow in def_module and passing it to module::Spec?

see also #21.

Implement PartialEq, Eq, and Hash on Value

Now that each Value has an interpreter associated with it (did not used to be the case), we can implement Hash with funcall("hash") and PartialEq with funcall("==", &[other])

This will enable storing Value in a HashMap, see artichoke/ferrocarril#160.

Add tests for regexp::opts::parse_pattern

There is a gnarly state machine and String processing going on. Needs tests, which should help as we modify this function to be backed by a nom parser.

// TODO: Add tests for this parse_pattern, see GH-157.
pub fn parse_pattern(pattern: &str, mut opts: Options) -> (String, Options) {
let orig_opts = opts;
let mut chars = pattern.chars();
let mut enabled = true;
let mut pat_buf = String::new();
let mut pointer = 0;
match chars.next() {
None => {
pat_buf.push_str("(?");
pat_buf.push_str(opts.onig_string().as_str());
pat_buf.push(':');
pat_buf.push(')');
return (pat_buf, opts);
}
Some(token) if token != '(' => {
pat_buf.push_str("(?");
pat_buf.push_str(opts.onig_string().as_str());
pat_buf.push(':');
pat_buf.push_str(pattern);
pat_buf.push(')');
return (pat_buf, opts);
}
_ => (),
};
pointer += 1;
match chars.next() {
None => {
pat_buf.push_str("(?");
pat_buf.push_str(opts.onig_string().as_str());
pat_buf.push(':');
pat_buf.push_str(pattern);
pat_buf.push(')');
return (pat_buf, opts);
}
Some(token) if token != '?' => {
pat_buf.push_str("(?");
pat_buf.push_str(opts.onig_string().as_str());
pat_buf.push(':');
pat_buf.push_str(pattern);
pat_buf.push(')');
return (pat_buf, opts);
}
_ => (),
};
pointer += 1;
for token in chars {
pointer += 1;
match token {
'-' => enabled = false,
'i' => {
opts.ignore_case = enabled;
}
'm' => {
opts.multiline = enabled;
}
'x' => {
opts.extended = enabled;
}
':' => break,
_ => {
pat_buf.push_str("(?");
pat_buf.push_str(opts.onig_string().as_str());
pat_buf.push(':');
pat_buf.push_str(pattern);
pat_buf.push(')');
return (pat_buf, opts);
}
}
}
let mut chars = pattern[pointer..].chars();
let mut token = chars.next();
let mut nest = 1;
while token.is_some() {
match token {
Some(token) if token == '(' => nest += 1,
Some(token) if token == ')' => {
nest -= 1;
if nest == 0 && chars.next().is_some() {
return (
format!("(?{}:{})", orig_opts.onig_string(), pattern),
orig_opts,
);
}
break;
}
_ => (),
}
token = chars.next();
}
(
format!("(?{}:{}", opts.onig_string(), &pattern[pointer..]),
opts,
)
}

Fix behavior of String#ord when String contains invalid UTF-8 byte sequence

CRuby:

[2.6.3] > "\xFE".ord
Traceback (most recent call last):
        5: from /usr/local/var/rbenv/versions/2.6.3/bin/irb:23:in `<main>'
        4: from /usr/local/var/rbenv/versions/2.6.3/bin/irb:23:in `load'
        3: from /usr/local/var/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        2: from (irb):2
        1: from (irb):2:in `ord'
ArgumentError (invalid byte sequence in UTF-8)

rirb:

>>> "\xFE".ord
=> nil

Make MrbError::Exec wrap an Exception

Right now, MrbError::Exec wraps a stringified stack trace.

The MrbExceptionHandler exposes a nice Exception struct that exposes exception class, message, optional backtrace, and the result of exc.inspect. It also implements display.

Wrap this Exception struct instead.

Add support for the wasm32-unknown-unknown build target

Support the wasm32-unknown-unknown target, which would enable using a native web Wasm runtime and unlock the ability to use wasm-bindgen, stdweb, and lots of other goodies in the playground.

With our fork of rust-onig, the only thing remaining to support this is getting mruby building under wasm32-unknown-unknown.

Implement Object#object_id

This is the algorithm for Fixnum:

[2.6.0] > 122732743347.object_id
=> 245465486695
[2.6.0] > ((122732743347 << 1) | 0x1)
=> 245465486695
[2.6.0] > -122732743347.object_id
=> -245465486693
[2.6.0] > (0x1 << 1) - ((122732743347 << 1) | 0x1)
=> -245465486693

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.