Echo example in CLI

This commit is contained in:
Richard Feldman 2020-12-23 16:49:57 -05:00
parent 659966c878
commit 1de0918ba9
14 changed files with 59 additions and 188 deletions

View file

@ -28,6 +28,14 @@ extern "C" {
fn size_Fx_result() -> i64;
}
#[no_mangle]
pub fn roc_fx_putChar(foo: i64) -> () {
let character = foo as u8 as char;
print!("{}", character);
()
}
#[no_mangle]
pub fn roc_fx_putLine(line: RocStr) -> () {
let bytes = line.as_slice();
@ -78,7 +86,6 @@ pub fn rust_main() -> isize {
let size = unsafe { roc_main_size() } as usize;
let layout = Layout::array::<u8>(size).unwrap();
let answer = unsafe {
// TODO if this is 1024B or less, put it in a global scratch buffer
let buffer = std::alloc::alloc(layout);
roc_main(buffer);