mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
WIP
This commit is contained in:
parent
1c1112ec35
commit
98ba49baf6
6 changed files with 48 additions and 23 deletions
|
@ -97,6 +97,21 @@ union union_Op {
|
|||
_sizer: [u8; 8],
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct RocFunction_3 {
|
||||
closure_data: T
|
||||
}
|
||||
|
||||
impl RocFunction_3 {
|
||||
pub fn call(self) -> U {
|
||||
extern "C" {
|
||||
fn call_the_closure(T) -> U ;
|
||||
}
|
||||
|
||||
call_the_closure(self.closure_data)
|
||||
}
|
||||
}
|
||||
|
||||
impl Op {
|
||||
#[cfg(any(
|
||||
target_arch = "arm",
|
||||
|
|
|
@ -93,7 +93,7 @@ pub extern "C" fn rust_main() -> i32 {
|
|||
|
||||
println!("Let's do things!");
|
||||
|
||||
let op: Op = unsafe {
|
||||
let mut op: Op = unsafe {
|
||||
let mut mem = MaybeUninit::uninit();
|
||||
|
||||
roc_main(mem.as_mut_ptr());
|
||||
|
@ -101,26 +101,33 @@ pub extern "C" fn rust_main() -> i32 {
|
|||
mem.assume_init()
|
||||
};
|
||||
|
||||
match dbg!(op.discriminant()) {
|
||||
StdoutWrite => {
|
||||
let output: RocStr = unsafe { op.get_StdoutWrite_0() };
|
||||
// let _next = unsafe { op.get_StdoutWrite_1() };
|
||||
loop {
|
||||
match dbg!(op.discriminant()) {
|
||||
StdoutWrite => {
|
||||
let output: RocStr = unsafe { op.get_StdoutWrite_0() };
|
||||
op = unsafe { op.get_StdoutWrite_1() };
|
||||
|
||||
dbg!(&output);
|
||||
dbg!(&output);
|
||||
|
||||
if let Err(e) = std::io::stdout().write_all(output.as_bytes()) {
|
||||
panic!("Writing to stdout failed! {:?}", e);
|
||||
if let Err(e) = std::io::stdout().write_all(output.as_bytes()) {
|
||||
panic!("Writing to stdout failed! {:?}", e);
|
||||
}
|
||||
}
|
||||
StderrWrite => {
|
||||
let output: RocStr = unsafe { op.get_StderrWrite_0() };
|
||||
// let _next = unsafe { op.get_StderrWrite_1() };
|
||||
dbg!(&output);
|
||||
|
||||
break;
|
||||
|
||||
if let Err(e) = std::io::stderr().write_all(output.as_bytes()) {
|
||||
panic!("Writing to stderr failed! {:?}", e);
|
||||
}
|
||||
}
|
||||
Done => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
StderrWrite => {
|
||||
let output: RocStr = unsafe { op.get_StderrWrite_0() };
|
||||
// let _next = unsafe { op.get_StderrWrite_1() };
|
||||
|
||||
if let Err(e) = std::io::stderr().write_all(output.as_bytes()) {
|
||||
panic!("Writing to stderr failed! {:?}", e);
|
||||
}
|
||||
}
|
||||
Done => {}
|
||||
}
|
||||
|
||||
println!("Done!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue