From 2db36a953211d2b198600e706549e1615be82831 Mon Sep 17 00:00:00 2001 From: glyh Date: Tue, 17 Sep 2024 21:15:31 +0800 Subject: [PATCH] fix externals --- src/bin/externals.mbt | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/bin/externals.mbt b/src/bin/externals.mbt index 6b5699f..249cd91 100644 --- a/src/bin/externals.mbt +++ b/src/bin/externals.mbt @@ -186,22 +186,31 @@ fn add_closure_interpreter_fns( fn externals() -> @immut/hashmap.T[String, @types.Type] { @immut/hashmap.T::new() - .add("read_int", @types.Fun([], Int)) - .add("read_char", @types.Fun([], Int)) - .add("print_int", @types.Fun([Int], Unit)) - .add("print_char", @types.Fun([Int], Unit)) - .add("print_endline", @types.Fun([], Unit)) - .add("create_array", @types.Fun([Int, Int], @types.Type::Array(Int))) + .add("read_int", @types.Fun([], @types.t_int)) + .add("read_char", @types.Fun([], @types.t_int)) + .add("print_int", @types.Fun([@types.t_int], @types.t_unit)) + .add("print_char", @types.Fun([@types.t_int], @types.t_unit)) + .add("print_endline", @types.Fun([], @types.t_unit)) + .add( + "create_array", + @types.Fun([@types.t_int, @types.t_int], @types.Type::Array(@types.t_int)), + ) .add( "create_float_array", - @types.Fun([Int, Double], @types.Type::Array(Double)), - ) - .add("create_ptr_array", @types.Fun([Int, Ptr], @types.Type::Array(Ptr))) - .add("truncate", @types.Fun([Double], Int)) - .add("sin", @types.Fun([Double], Double)) - .add("cos", @types.Fun([Double], Double)) - .add("sqrt", @types.Fun([Double], Double)) - .add("abs_float", @types.Fun([Double], Double)) - .add("int_of_float", @types.Fun([Double], Int)) - .add("float_of_int", @types.Fun([Int], Double)) + @types.Fun( + [@types.t_int, @types.t_double], + @types.Type::Array(@types.t_double), + ), + ) + .add( + "create_ptr_array", + @types.Fun([@types.t_int, @types.t_ptr], @types.Type::Array(@types.t_ptr)), + ) + .add("truncate", @types.Fun([@types.t_double], @types.t_int)) + .add("sin", @types.Fun([@types.t_double], @types.t_double)) + .add("cos", @types.Fun([@types.t_double], @types.t_double)) + .add("sqrt", @types.Fun([@types.t_double], @types.t_double)) + .add("abs_float", @types.Fun([@types.t_double], @types.t_double)) + .add("int_of_float", @types.Fun([@types.t_double], @types.t_int)) + .add("float_of_int", @types.Fun([@types.t_int], @types.t_double)) }