aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool
diff options
context:
space:
mode:
authorEduardo Julian2021-06-02 00:13:17 -0400
committerEduardo Julian2021-06-02 00:13:17 -0400
commit19b14056e95bbde2f852c5ce4ed16b36c9f85217 (patch)
tree2eab6ed877761866acbb20f48628d80f5d06e4f1 /stdlib/source/lux/tool
parent26c22f6a8dccb41c41ff9f64ac1b7b2d5340baef (diff)
Struggling against the lexing limitations of Renjin.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux67
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux112
2 files changed, 95 insertions, 84 deletions
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux
index cb82c6cb4..d9178d8c2 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux
@@ -92,25 +92,25 @@
## ## (-> Expression Expression Expression))
## ## (//runtime.i64//64 (operation parameter subject)))
-## (def: i64_procs
-## Bundle
-## (<| (/.prefix "i64")
-## (|> /.empty
-## (/.install "and" (binary _.logand/2))
-## (/.install "or" (binary _.logior/2))
-## (/.install "xor" (binary _.logxor/2))
-## (/.install "left-shift" (binary _.ash/2))
-## (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift)))
-## (/.install "=" (binary _.=/2))
-## (/.install "<" (binary _.</2))
-## (/.install "+" (binary _.+/2))
-## (/.install "-" (binary _.-/2))
-## (/.install "*" (binary _.*/2))
-## (/.install "/" (binary _.floor/2))
-## (/.install "%" (binary _.rem/2))
-## ## (/.install "f64" (unary (_.//2 (_.float +1.0))))
-## (/.install "char" (unary (|>> _.code-char/1 _.string/1)))
-## )))
+(def: i64_procs
+ Bundle
+ (<| (/.prefix "i64")
+ (|> /.empty
+ ## (/.install "and" (binary _.logand/2))
+ ## (/.install "or" (binary _.logior/2))
+ ## (/.install "xor" (binary _.logxor/2))
+ ## (/.install "left-shift" (binary _.ash/2))
+ ## (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift)))
+ ## (/.install "=" (binary _.=/2))
+ ## (/.install "<" (binary _.</2))
+ ## (/.install "+" (binary _.+/2))
+ ## (/.install "-" (binary _.-/2))
+ ## (/.install "*" (binary _.*/2))
+ ## (/.install "/" (binary _.floor/2))
+ ## (/.install "%" (binary _.rem/2))
+ ## (/.install "f64" (unary (_.//2 (_.float +1.0))))
+ (/.install "char" (unary (|>> //runtime.i64_low _.intToUtf8/1)))
+ )))
## (def: f64_procs
## Bundle
@@ -140,19 +140,18 @@
## (Binary (Expression Any))
## (_.char-code/1 (_.char/2 [text index])))
-## (def: text_procs
-## Bundle
-## (<| (/.prefix "text")
-## (|> /.empty
-## (/.install "=" (binary _.string=/2))
-## ## (/.install "<" (binary (product.uncurry _.string<?/2)))
-## (/.install "concat" (binary (function (_ [left right])
-## (_.concatenate/3 [(_.symbol "string") left right]))))
-## (/.install "index" (trinary ..text//index))
-## (/.install "size" (unary _.length/1))
-## (/.install "char" (binary ..text//char))
-## (/.install "clip" (trinary ..text//clip))
-## )))
+(def: text_procs
+ Bundle
+ (<| (/.prefix "text")
+ (|> /.empty
+ ## (/.install "=" (binary _.string=/2))
+ ## (/.install "<" (binary (product.uncurry _.string<?/2)))
+ (/.install "concat" (binary _.paste/2))
+ ## (/.install "index" (trinary ..text//index))
+ ## (/.install "size" (unary _.length/1))
+ ## (/.install "char" (binary ..text//char))
+ ## (/.install "clip" (trinary ..text//clip))
+ )))
## (def: (io//log! message)
## (Unary (Expression Any))
@@ -172,8 +171,8 @@
(<| (/.prefix "lux")
(|> /.empty
## (dictionary.merge lux_procs)
- ## (dictionary.merge i64_procs)
+ (dictionary.merge i64_procs)
## (dictionary.merge f64_procs)
- ## (dictionary.merge text_procs)
+ (dictionary.merge text_procs)
## (dictionary.merge io_procs)
)))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
index 1b7119378..326d688c2 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
@@ -94,43 +94,11 @@
(_.named_list (list [..i64_high_field (_.int high)]
[..i64_low_field (_.int low)]))))
-(def: #export variant_tag_field "luxVT")
-(def: #export variant_flag_field "luxVF")
-(def: #export variant_value_field "luxVV")
-
-(def: #export (flag value)
- (-> Bit Expression)
- (if value
- (_.string "")
- _.null))
-
-(def: (variant' tag last? value)
- (-> Expression Expression Expression Expression)
- (_.named_list (list [..variant_tag_field tag]
- [..variant_flag_field last?]
- [..variant_value_field value])))
-
-(def: #export (variant tag last? value)
- (-> Nat Bit Expression Expression)
- (variant' (_.int (.int tag))
- (flag last?)
- value))
-
-(def: #export none
- Expression
- (variant 0 #0 ..unit))
-
-(def: #export some
- (-> Expression Expression)
- (variant 1 #1))
-
-(def: #export left
- (-> Expression Expression)
- (variant 0 #0))
-
-(def: #export right
- (-> Expression Expression)
- (variant 1 #1))
+(def: #export (lux_i64 high low)
+ (-> Int Int Int)
+ (|> high
+ (i64.left_shift 32)
+ (i64.or low)))
(syntax: #export (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))}
body)
@@ -180,6 +148,47 @@
(_.function (list (~+ inputsC))
(~ code))))))))))))))
+(def: #export variant_tag_field "luxVT")
+(def: #export variant_flag_field "luxVF")
+(def: #export variant_value_field "luxVV")
+
+(def: #export (flag value)
+ (-> Bit Expression)
+ (if value
+ (_.string "")
+ _.null))
+
+(def: (variant' tag last? value)
+ (-> Expression Expression Expression Expression)
+ (_.named_list (list [..variant_tag_field tag]
+ [..variant_flag_field last?]
+ [..variant_value_field value])))
+
+(runtime: (adt::variant tag last? value)
+ (..variant' tag last? value))
+
+(def: #export (variant tag last? value)
+ (-> Nat Bit Expression Expression)
+ (adt::variant (_.int (.int tag))
+ (flag last?)
+ value))
+
+(def: #export none
+ Expression
+ (variant 0 #0 ..unit))
+
+(def: #export some
+ (-> Expression Expression)
+ (variant 1 #1))
+
+(def: #export left
+ (-> Expression Expression)
+ (variant 0 #0))
+
+(def: #export right
+ (-> Expression Expression)
+ (variant 1 #1))
+
(def: high_shift (_.bit_shl (_.int +32)))
(runtime: f2^32 (|> (_.int +2) (_.** (_.int +32))))
@@ -628,6 +637,7 @@
@tuple::left
@tuple::right
@sum::get
+ @adt::variant
))
(template [<name> <op>]
@@ -667,6 +677,21 @@
(def: runtime::i64
Expression
($_ _.then
+ @f2^32
+ @f2^63
+
+ @i64::new
+ @i64::from_float
+
+ @i64::and
+ @i64::or
+ @i64::xor
+ @i64::not
+ @i64::left_shift
+ @i64::arithmetic_right_shift_32
+ @i64::arithmetic_right_shift
+ @i64::right_shift
+
@i64::zero
@i64::one
@i64::min
@@ -682,15 +707,6 @@
@i64::*
@i64::/
@i64::%
-
- @i64::and
- @i64::or
- @i64::xor
- @i64::not
- @i64::left_shift
- @i64::arithmetic_right_shift_32
- @i64::arithmetic_right_shift
- @i64::right_shift
))
(runtime: (frac::decode input)
@@ -822,10 +838,6 @@
Expression
($_ _.then
runtime::lux
- @f2^32
- @f2^63
- @i64::new
- @i64::from_float
runtime::i64
runtime::adt
runtime::frac