aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/lua.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/target/lua.lux42
1 files changed, 33 insertions, 9 deletions
diff --git a/stdlib/source/lux/target/lua.lux b/stdlib/source/lux/target/lua.lux
index be46169dd..c1bceb634 100644
--- a/stdlib/source/lux/target/lua.lux
+++ b/stdlib/source/lux/target/lua.lux
@@ -1,5 +1,8 @@
(.module:
[lux (#- Location Code int if cond function or and not let)
+ [abstract
+ [equivalence (#+ Equivalence)]
+ [hash (#+ Hash)]]
[control
[pipe (#+ case> cond> new>)]]
[data
@@ -27,6 +30,18 @@
(abstract: #export (Code brand)
Text
+ (structure: #export equivalence
+ (All [brand] (Equivalence (Code brand)))
+
+ (def: (= reference subject)
+ (\ text.equivalence = (:representation reference) (:representation subject))))
+
+ (structure: #export hash
+ (All [brand] (Hash (Code brand)))
+
+ (def: &equivalence ..equivalence)
+ (def: hash (|>> :representation (\ text.hash hash))))
+
(def: #export manual
(-> Text Code)
(|>> :abstraction))
@@ -225,6 +240,10 @@
(local vars)
(set vars value)))
+ (def: #export (local/1 var value)
+ (-> Var Expression Statement)
+ (:abstraction (format "local " (:representation var) " = " (:representation value) ..statement_suffix)))
+
(def: #export (if test then! else!)
(-> Expression Statement Statement Statement)
(:abstraction (format "if " (:representation test)
@@ -280,15 +299,20 @@
(text.enclose ["(" ")"])
:abstraction))
- (def: #export (function name args body!)
- (-> Var (List Var) Statement Statement)
- (:abstraction
- (format "function " (:representation name)
- (|> args
- ..locations
- (text.enclose ["(" ")"]))
- (..nest (:representation body!))
- text.new_line "end" ..statement_suffix)))
+ (template [<name> <code>]
+ [(def: #export (<name> name args body!)
+ (-> Var (List Var) Statement Statement)
+ (:abstraction
+ (format <code> " " (:representation name)
+ (|> args
+ ..locations
+ (text.enclose ["(" ")"]))
+ (..nest (:representation body!))
+ text.new_line "end" ..statement_suffix)))]
+
+ [function "function"]
+ [local_function "local function"]
+ )
(def: #export break
Statement