aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux.lux75
1 files changed, 57 insertions, 18 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index e31e96e7c..205f1a543 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -662,12 +662,12 @@
#Nil))))]
default-def-meta-exported)))
-## (type: Compiler-Mode
+## (type: Mode
## #Build
## #Eval
## #REPL)
-(_lux_def Compiler-Mode
- (#Named ["lux" "Compiler-Mode"]
+(_lux_def Mode
+ (#Named ["lux" "Mode"]
(#Sum ## Build
#Unit
(#Sum ## Eval
@@ -683,31 +683,31 @@
(text$ "A sign that shows the conditions under which the compiler is running.")]
default-def-meta-exported))))
-## (type: Compiler-Info
-## {#compiler-name Text
-## #compiler-version Text
-## #compiler-mode Compiler-Mode})
-(_lux_def Compiler-Info
- (#Named ["lux" "Compiler-Info"]
+## (type: Info
+## {#target Text
+## #version Text
+## #mode Mode})
+(_lux_def Info
+ (#Named ["lux" "Info"]
(#Product
- ## compiler-name
+ ## target
Text
(#Product
- ## compiler-version
+ ## version
Text
- ## compiler-mode
- Compiler-Mode)))
+ ## mode
+ Mode)))
(record$ (#Cons [(tag$ ["lux" "tags"])
- (tuple$ (#Cons (text$ "compiler-name")
- (#Cons (text$ "compiler-version")
- (#Cons (text$ "compiler-mode")
+ (tuple$ (#Cons (text$ "target")
+ (#Cons (text$ "version")
+ (#Cons (text$ "mode")
#Nil))))]
(#Cons [(tag$ ["lux" "doc"])
(text$ "Information about the current version and type of compiler that is running.")]
default-def-meta-exported))))
## (type: Compiler
-## {#info Compiler-Info
+## {#info Info
## #source Source
## #cursor Cursor
## #modules (List [Text Module])
@@ -720,7 +720,7 @@
(_lux_def Compiler
(#Named ["lux" "Compiler"]
(#Product ## "lux;info"
- Compiler-Info
+ Info
(#Product ## "lux;source"
Source
(#Product ## "lux;cursor"
@@ -5867,3 +5867,42 @@
(type: #export (Array a)
{#;doc "Mutable arrays."}
(#;Host "#Array" (#;Cons a #;Nil)))
+
+(def: target
+ (Meta Text)
+ (function [compiler]
+ (#;Right [compiler (get@ [#info #target] compiler)])))
+
+(def: (pick-for-target target options)
+ (-> Text (List [Code Code]) (Maybe Code))
+ (case options
+ #;Nil
+ #;None
+
+ (#;Cons [key value] options')
+ (case key
+ (^multi [_ (#Text platform)]
+ (text/= target platform))
+ (#;Some value)
+
+ _
+ (pick-for-target target options'))
+ ))
+
+(macro: #export (for tokens)
+ (do Monad<Meta>
+ [target target]
+ (case tokens
+ (^ (list [_ (#Record options)]))
+ (case (pick-for-target target options)
+ (#;Some pick)
+ (wrap (list pick))
+
+ #;None
+ (wrap (list)))
+
+ (^ (list [_ (#Record options)] default))
+ (wrap (list (;;default default (pick-for-target target options))))
+
+ _
+ (fail "Wrong syntax for 'for'"))))