diff options
author | Eduardo Julian | 2018-04-14 13:32:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-04-14 13:32:43 -0400 |
commit | 0bba53ceb52502510e0f6ba4c53a951933532a61 (patch) | |
tree | 82bd7fe239dc7996e9542fc9b5fea5768579bd0f /new-luxc/source/luxc/lang/translation/r.lux | |
parent | 1a3fa23f5c0444f0f8273cbc21875eeabdc321aa (diff) |
- Made everything an expression for R translation.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/r.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/r.lux | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/new-luxc/source/luxc/lang/translation/r.lux b/new-luxc/source/luxc/lang/translation/r.lux index aba64bc87..446df095d 100644 --- a/new-luxc/source/luxc/lang/translation/r.lux +++ b/new-luxc/source/luxc/lang/translation/r.lux @@ -15,7 +15,7 @@ (world [file #+ File])) (luxc [lang] (lang [".L" variable #+ Register] - (host [r #+ Expression Statement])) + (host [r #+ Expression])) [".C" io])) (do-template [<name>] @@ -56,7 +56,7 @@ (type: #export Host {#context [Text Nat] #anchor (Maybe Anchor) - #loader (-> Statement (Error Unit)) + #loader (-> Expression (Error Unit)) #interpreter (-> Expression (Error Object)) #module-buffer (Maybe StringBuilder) #program-buffer StringBuilder}) @@ -69,7 +69,7 @@ #anchor #.None #loader (function (_ code) (do e.Monad<Error> - [_ (ScriptEngine::eval [(r.statement code)] interpreter)] + [_ (ScriptEngine::eval [(r.expression code)] interpreter)] (wrap []))) #interpreter (function (_ code) (do e.Monad<Error> @@ -164,21 +164,20 @@ (function (_ compiler) (#e.Success [compiler (|> compiler (get@ #.host) (:! Host) (get@ #program-buffer))]))) -(do-template [<name> <field> <inputT> <outputT> <unwrap>] +(do-template [<name> <field> <outputT>] [(def: (<name> code) - (-> <inputT> (Meta <outputT>)) + (-> Expression (Meta <outputT>)) (function (_ compiler) (let [runner (|> compiler (get@ #.host) (:! Host) (get@ <field>))] (case (runner code) (#e.Error error) - (exec ## (log! (<unwrap> code)) - ((lang.throw Cannot-Execute error) compiler)) + ((lang.throw Cannot-Execute error) compiler) (#e.Success output) (#e.Success [compiler output])))))] - [load! #loader Statement Unit r.statement] - [interpret #interpreter Expression Object r.expression] + [load! #loader Unit] + [interpret #interpreter Object] ) (def: #export variant-tag-field "luxVT") @@ -194,18 +193,15 @@ (-> Ident Text) (lang.normalize-name (format module "$" name))) -(do-template [<name> <eval> <un-wrap> <inputT> <outputT>] - [(def: #export (<name> code) - (-> <inputT> (Meta <outputT>)) - (do macro.Monad<Meta> - [module-buffer module-buffer - #let [_ (Appendable::append [(:! CharSequence (<un-wrap> code))] - module-buffer)]] - (<eval> code)))] - - [save load! r.statement Statement Unit] - [run interpret r.expression Expression Object] - ) +(def: #export (save code) + (-> Expression (Meta Unit)) + (do macro.Monad<Meta> + [module-buffer module-buffer + #let [_ (Appendable::append [(:! CharSequence (r.expression code))] + module-buffer)]] + (load! code))) + +(def: #export run interpret) (def: #export (save-module! target) (-> File (Meta (Process Unit))) |