From 7d539a83fd55f7ced7657302054e099955b55ae2 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 18 Apr 2018 01:28:24 -0400 Subject: - Initial Scheme back-end implementation. --- .../luxc/lang/translation/scheme/reference.jvm.lux | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 new-luxc/source/luxc/lang/translation/scheme/reference.jvm.lux (limited to 'new-luxc/source/luxc/lang/translation/scheme/reference.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/scheme/reference.jvm.lux b/new-luxc/source/luxc/lang/translation/scheme/reference.jvm.lux new file mode 100644 index 000000000..3ee8e472a --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/scheme/reference.jvm.lux @@ -0,0 +1,42 @@ +(.module: + lux + (lux [macro] + (data [text] + text/format)) + (luxc ["&" lang] + (lang [".L" variable #+ Variable Register] + (host ["_" scheme #+ Expression SVar @@]))) + [//] + (// [".T" runtime])) + +(do-template [ ] + [(def: #export ( register) + (-> Register SVar) + (_.var (format (%i (nat-to-int register))))) + + (def: #export ( register) + (-> Register (Meta Expression)) + (:: macro.Monad wrap (@@ ( register))))] + + [closure translate-captured "c"] + [variable translate-local "v"]) + +(def: #export (local var) + (-> Variable SVar) + (if (variableL.captured? var) + (closure (variableL.captured-register var)) + (variable (int-to-nat var)))) + +(def: #export (translate-variable var) + (-> Variable (Meta Expression)) + (if (variableL.captured? var) + (translate-captured (variableL.captured-register var)) + (translate-local (int-to-nat var)))) + +(def: #export global + (-> Ident SVar) + (|>> //.definition-name _.var)) + +(def: #export (translate-definition name) + (-> Ident (Meta Expression)) + (:: macro.Monad wrap (@@ (global name)))) -- cgit v1.2.3