mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
update morphic
This commit is contained in:
parent
66a6080f25
commit
fbac262023
7 changed files with 637 additions and 343 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1927,6 +1927,7 @@ name = "morphic_lib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"smallvec",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn proc_spec(proc: &Proc) -> Result<FuncDef> {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Env {
|
struct Env {
|
||||||
symbols: MutMap<Symbol, ValueId>,
|
symbols: MutMap<Symbol, ValueId>,
|
||||||
join_points: MutMap<crate::ir::JoinPointId, morphic_lib::JoinPointId>,
|
join_points: MutMap<crate::ir::JoinPointId, morphic_lib::ContinuationId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stmt_spec(
|
fn stmt_spec(
|
||||||
|
@ -246,7 +246,7 @@ fn stmt_spec(
|
||||||
let jp_arg_type_id = builder.add_tuple_type(&type_ids)?;
|
let jp_arg_type_id = builder.add_tuple_type(&type_ids)?;
|
||||||
|
|
||||||
let (jpid, jp_argument) =
|
let (jpid, jp_argument) =
|
||||||
builder.declare_join_point(block, jp_arg_type_id, ret_type_id)?;
|
builder.declare_continuation(block, jp_arg_type_id, ret_type_id)?;
|
||||||
|
|
||||||
let join_body_sub_block = {
|
let join_body_sub_block = {
|
||||||
env.join_points.insert(*id, jpid);
|
env.join_points.insert(*id, jpid);
|
||||||
|
@ -270,7 +270,7 @@ fn stmt_spec(
|
||||||
let cont_value_id = stmt_spec(builder, env, cont_block, layout, continuation)?;
|
let cont_value_id = stmt_spec(builder, env, cont_block, layout, continuation)?;
|
||||||
|
|
||||||
env.join_points.remove(id);
|
env.join_points.remove(id);
|
||||||
builder.define_join_point(jpid, join_body_sub_block)?;
|
builder.define_continuation(jpid, join_body_sub_block)?;
|
||||||
|
|
||||||
builder.add_sub_block(block, BlockExpr(cont_block, cont_value_id))
|
builder.add_sub_block(block, BlockExpr(cont_block, cont_value_id))
|
||||||
}
|
}
|
||||||
|
|
1
vendor/morphic_lib/Cargo.toml
vendored
1
vendor/morphic_lib/Cargo.toml
vendored
|
@ -7,3 +7,4 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0.24"
|
thiserror = "1.0.24"
|
||||||
sha2 = "0.9.4"
|
sha2 = "0.9.4"
|
||||||
|
smallvec = "1.6.1"
|
||||||
|
|
934
vendor/morphic_lib/src/api.rs
vendored
934
vendor/morphic_lib/src/api.rs
vendored
File diff suppressed because it is too large
Load diff
19
vendor/morphic_lib/src/bindings.rs
vendored
19
vendor/morphic_lib/src/bindings.rs
vendored
|
@ -218,27 +218,28 @@ pub unsafe extern "C" fn Morphic_FuncDefBuilder_Build(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Morphic_FuncDefBuilder_DeclareJoinPoint(
|
pub unsafe extern "C" fn Morphic_FuncDefBuilder_DeclareContinuation(
|
||||||
self_: *mut FuncDefBuilder,
|
self_: *mut FuncDefBuilder,
|
||||||
block: BlockId,
|
block: BlockId,
|
||||||
arg_type: TypeId,
|
arg_type: TypeId,
|
||||||
ret_type: TypeId,
|
ret_type: TypeId,
|
||||||
out0: *mut JoinPointId,
|
out0: *mut ContinuationId,
|
||||||
out1: *mut ValueId,
|
out1: *mut ValueId,
|
||||||
) -> *mut Error {
|
) -> *mut Error {
|
||||||
let (join_point, value) = check_err!((*self_).declare_join_point(block, arg_type, ret_type));
|
let (continuation, value) =
|
||||||
*out0 = join_point;
|
check_err!((*self_).declare_continuation(block, arg_type, ret_type));
|
||||||
|
*out0 = continuation;
|
||||||
*out1 = value;
|
*out1 = value;
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Morphic_FuncDefBuilder_DefineJoinPoint(
|
pub unsafe extern "C" fn Morphic_FuncDefBuilder_DefineContinuation(
|
||||||
self_: *mut FuncDefBuilder,
|
self_: *mut FuncDefBuilder,
|
||||||
join_point: JoinPointId,
|
continuation: ContinuationId,
|
||||||
body: BlockExpr,
|
body: BlockExpr,
|
||||||
) -> *mut Error {
|
) -> *mut Error {
|
||||||
check_err!((*self_).define_join_point(join_point, body));
|
check_err!((*self_).define_continuation(continuation, body));
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,12 +247,12 @@ pub unsafe extern "C" fn Morphic_FuncDefBuilder_DefineJoinPoint(
|
||||||
pub unsafe extern "C" fn Morphic_FuncDefBuilder_AddJump(
|
pub unsafe extern "C" fn Morphic_FuncDefBuilder_AddJump(
|
||||||
self_: *mut FuncDefBuilder,
|
self_: *mut FuncDefBuilder,
|
||||||
block: BlockId,
|
block: BlockId,
|
||||||
join_point: JoinPointId,
|
continuation: ContinuationId,
|
||||||
arg: ValueId,
|
arg: ValueId,
|
||||||
unreachable_result_type: TypeId,
|
unreachable_result_type: TypeId,
|
||||||
out: *mut ValueId,
|
out: *mut ValueId,
|
||||||
) -> *mut Error {
|
) -> *mut Error {
|
||||||
*out = check_err!((*self_).add_jump(block, join_point, arg, unreachable_result_type));
|
*out = check_err!((*self_).add_jump(block, continuation, arg, unreachable_result_type));
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
vendor/morphic_lib/src/util/bytes_id.rs
vendored
10
vendor/morphic_lib/src/util/bytes_id.rs
vendored
|
@ -4,13 +4,15 @@ macro_rules! bytes_id {
|
||||||
$(#[$annot_borrowed:meta])* $borrowed_vis:vis $borrowed:ident;
|
$(#[$annot_borrowed:meta])* $borrowed_vis:vis $borrowed:ident;
|
||||||
$(#[$annot_owned:meta])* $owned_vis:vis $owned:ident;
|
$(#[$annot_owned:meta])* $owned_vis:vis $owned:ident;
|
||||||
) => {
|
) => {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
$(#[$annot_borrowed])*
|
$(#[$annot_borrowed])*
|
||||||
$borrowed_vis struct $borrowed<'a>($borrowed_vis &'a [u8]);
|
$borrowed_vis struct $borrowed<'a>($borrowed_vis &'a [u8]);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
// The stack-allocated array portion of a `SmallVec` shares a union with two `usize`s, so on
|
||||||
|
// 64-bit platforms we can make the array up to 16 bytes long with no space penalty.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
$(#[$annot_owned])*
|
$(#[$annot_owned])*
|
||||||
$owned_vis struct $owned($owned_vis ::std::vec::Vec<u8>);
|
$owned_vis struct $owned($owned_vis ::smallvec::SmallVec<[u8; 16]>);
|
||||||
|
|
||||||
impl $owned {
|
impl $owned {
|
||||||
fn borrowed<'a>(&'a self) -> $borrowed<'a> {
|
fn borrowed<'a>(&'a self) -> $borrowed<'a> {
|
||||||
|
@ -20,7 +22,7 @@ macro_rules! bytes_id {
|
||||||
|
|
||||||
impl<'a> ::std::convert::From<$borrowed<'a>> for $owned {
|
impl<'a> ::std::convert::From<$borrowed<'a>> for $owned {
|
||||||
fn from(borrowed: $borrowed<'a>) -> Self {
|
fn from(borrowed: $borrowed<'a>) -> Self {
|
||||||
$owned(<[u8]>::to_vec(&borrowed.0))
|
$owned(::smallvec::SmallVec::from_slice(&borrowed.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
vendor/morphic_lib/src/util/mod.rs
vendored
9
vendor/morphic_lib/src/util/mod.rs
vendored
|
@ -1,5 +1,14 @@
|
||||||
|
#[macro_use]
|
||||||
|
pub mod id_type;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod bytes_id;
|
pub mod bytes_id;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod forward_trait;
|
pub mod forward_trait;
|
||||||
|
|
||||||
|
pub mod blocks;
|
||||||
|
pub mod id_bi_map;
|
||||||
|
pub mod id_vec;
|
||||||
|
pub mod op_graph;
|
||||||
|
pub mod replace_none;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue