From ab1829d77c7d12af344af68d6c50d391f1126640 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Jan 2023 02:33:52 -0400 Subject: Compilation of simple literals in C++. --- lux-c++/source/program.lux | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lux-c++') diff --git a/lux-c++/source/program.lux b/lux-c++/source/program.lux index 6bfa65d4f..cb2b96029 100644 --- a/lux-c++/source/program.lux +++ b/lux-c++/source/program.lux @@ -11,10 +11,7 @@ ["[0]" maybe (.use "[1]#[0]" monad)] ["[0]" try (.only Try)] ["[0]" exception (.only Exception)] - ["[0]" io (.only IO io)] - ["[0]" function] - [concurrency - ["[0]" async (.only Async)]]] + ["[0]" io (.only IO io)]] [data ["[0]" product] [text @@ -32,8 +29,8 @@ ["[0]" file] ["[1]/[0]" environment]] [meta - ["@" target (.only) - ["_" js]] + [target + ["_" c++]] [macro ["^" pattern] ["[0]" template]] @@ -54,9 +51,8 @@ ["[1]" js]]] [translation ["[0]" reference] - ["[0]" js (.only) - ["[0]" runtime] - ["[1]/[0]" reference]]]]]] + [c++ + ["[0]" primitive]]]]]] [default ["[0]" platform (.only Platform)]] [meta @@ -74,10 +70,22 @@ ("static" cppdef [Text] "io" Bit) ("static" gbl (ffi.Object Any))) +(def (print it) + (-> _.Expression + Text) + (%.format "std::cout << " + (_.code it) + " << std::endl;")) + (def _ (program [] (do io.monad - [? (cppyy::cppdef ["void say_hello() { std::cout << 123 << std::endl; }"]) + [? (cppyy::cppdef [(%.format "void say_hello() { " + (print (primitive.bit true)) + (print (primitive.i64 +123)) + (print (primitive.f64 -456.789)) + (print (primitive.text "YOLO")) + " }")]) .let [_ (debug.log! (%.format "BEFORE " (%.bit ?)))] global (cppyy::gbl) .let [say_hello (as ffi.Function -- cgit v1.2.3