generate signature for foreign symbols

This commit is contained in:
Folkert 2020-11-06 23:46:31 +01:00
parent 4b8392696e
commit a6e39e66f1
8 changed files with 75 additions and 31 deletions

View file

@ -3,4 +3,4 @@ platform folkertdev/foo
requires [ main ]
imports []
effects
{ putChar Int -> Effect {} }
{ putChar Int -> Effect {}, putLine Str -> Effect {} }

View file

@ -2,7 +2,8 @@ app Main provides [ main ] imports [ Effect ]
main : Effect.Effect {} as Fx
main =
e = Effect.putChar 69
d = Effect.putChar 68
e |> Effect.after \{} -> d
Effect.putLine "Hello"
|> Effect.after \{} -> Effect.putChar 87
# |> Effect.after \{} -> Effect.putLine "orld"

View file

@ -1,5 +1,6 @@
use roc_std::alloca;
use roc_std::RocCallResult;
use roc_std::RocStr;
use std::alloc::Layout;
use std::time::SystemTime;
@ -25,6 +26,15 @@ pub fn roc_fx_putChar(foo: i64) -> () {
()
}
#[no_mangle]
pub fn roc_fx_putLine(line: RocStr) -> () {
let bytes = line.as_slice();
let string = unsafe { std::str::from_utf8_unchecked(bytes) };
println!("{}", string);
()
}
unsafe fn call_the_closure(function_pointer: *const u8, closure_data_ptr: *const u8) -> i64 {
let size = size_Fx() as usize;