aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler
diff options
context:
space:
mode:
authorEduardo Julian2021-11-04 02:54:45 -0400
committerEduardo Julian2021-11-04 02:54:45 -0400
commit305a3b5bca562601ee37b4cac69dd02f245830db (patch)
tree05bb9afc3345e5f9570c5d4ec3c4461def637061 /stdlib/source/library/lux/tool/compiler
parent0dd20865adaf872d63aea1037034d22a3b906aba (diff)
Better method calls in Ruby.
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler')
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux12
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux14
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux21
5 files changed, 30 insertions, 27 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
index a32f4ad15..9ea3621e3 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
@@ -144,7 +144,7 @@
(|> /.empty
(/.install "syntax char case!" lux::syntax_char_case!)
(/.install "is" (binary (function (_ [reference subject])
- (_.do "equal?" {_.#Arguments (list reference)} subject))))
+ (_.do "equal?" (list reference) {.#None} subject))))
(/.install "try" (unary //runtime.lux//try))))
(def: (capped operation parameter subject)
@@ -169,10 +169,10 @@
(/.install "*" (binary (product.uncurried (..capped _.*))))
(/.install "/" (binary (product.uncurried //runtime.i64//division)))
(/.install "%" (binary (function (_ [parameter subject])
- (_.do "remainder" {_.#Arguments (list parameter)} subject))))
+ (_.do "remainder" (list parameter) {.#None} subject))))
(/.install "f64" (unary (_./ (_.float +1.0))))
- (/.install "char" (unary (_.do "chr" {_.#Arguments (list (_.string "UTF-8"))})))
+ (/.install "char" (unary (_.do "chr" (list (_.string "UTF-8")) {.#None})))
)))
(def: f64_procs
@@ -184,11 +184,11 @@
(/.install "*" (binary (product.uncurried _.*)))
(/.install "/" (binary (product.uncurried _./)))
(/.install "%" (binary (function (_ [parameter subject])
- (_.do "remainder" {_.#Arguments (list parameter)} subject))))
+ (_.do "remainder" (list parameter) {.#None} subject))))
(/.install "=" (binary (product.uncurried _.=)))
(/.install "<" (binary (product.uncurried _.<)))
- (/.install "i64" (unary (_.do "floor" {_.#Arguments (list)})))
- (/.install "encode" (unary (_.do "to_s" {_.#Arguments (list)})))
+ (/.install "i64" (unary (_.do "floor" (list) {.#None})))
+ (/.install "encode" (unary (_.do "to_s" (list) {.#None})))
(/.install "decode" (unary //runtime.f64//decode)))))
(def: (text//char [subjectO paramO])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux
index 99c008a2f..ab9718b40 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux
@@ -35,7 +35,7 @@
(def: (array::new [size])
(Unary Expression)
- (_.do "new" {_.#Arguments (list size)} (_.local "Array")))
+ (_.do "new" (list size) {.#None} (_.local "Array")))
(def: array::length
(Unary Expression)
@@ -81,7 +81,7 @@
(do [! ////////phase.monad]
[objectG (phase archive objectS)
inputsG (monad.each ! (phase archive) inputsS)]
- (in (_.do methodS {_.#Arguments inputsG} objectG))))]))
+ (in (_.do methodS inputsG {.#None} objectG))))]))
(template [<!> <?> <unit>]
[(def: <!> (Nullary Expression) (function.constant <unit>))
@@ -113,7 +113,7 @@
(do [! ////////phase.monad]
[abstractionG (phase archive abstractionS)
inputsG (monad.each ! (phase archive) inputsS)]
- (in (_.apply/* {_.#Arguments inputsG} abstractionG))))]))
+ (in (_.apply/* inputsG {.#None} abstractionG))))]))
(def: ruby::import
(custom
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux
index 8b60ef65a..766b4fa43 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux
@@ -107,11 +107,11 @@
(def: (push! value)
(-> Expression Statement)
- (_.statement (|> @cursor (_.do "push" {_.#Arguments (list value)}))))
+ (_.statement (|> @cursor (_.do "push" (list value) {.#None}))))
(def: peek_and_pop
Expression
- (|> @cursor (_.do "pop" {_.#Arguments (list)})))
+ (|> @cursor (_.do "pop" (list) {.#None})))
(def: pop!
Statement
@@ -124,18 +124,20 @@
(def: save!
Statement
(.let [cursor (_.array_range (_.int +0) (_.int -1) @cursor)]
- (_.statement (|> @savepoint (_.do "push" {_.#Arguments (list cursor)})))))
+ (_.statement (|> @savepoint (_.do "push" (list cursor) {.#None})))))
(def: restore!
Statement
- (_.set (list @cursor) (|> @savepoint (_.do "pop" {_.#Arguments (list)}))))
+ (_.set (list @cursor) (|> @savepoint (_.do "pop" (list) {.#None}))))
(def: fail! _.break)
(def: (multi_pop! pops)
(-> Nat Statement)
- (_.statement (_.do "slice!" {_.#Arguments (list (_.int (i.* -1 (.int pops)))
- (_.int (.int pops)))}
+ (_.statement (_.do "slice!"
+ (list (_.int (i.* -1 (.int pops)))
+ (_.int (.int pops)))
+ {.#None}
@cursor)))
(template [<name> <flag>]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
index 2053b6628..32c78830d 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
@@ -110,8 +110,8 @@
(_.return (_.lambda {.#None} (list (_.variadic @missing))
(_.return (|> @self
(_.apply_lambda/* (list (_.splat (|> (_.array (list))
- (_.do "concat" {_.#Arguments (list @curried)})
- (_.do "concat" {_.#Arguments (list @missing)})))))))))))
+ (_.do "concat" (list @curried) {.#None})
+ (_.do "concat" (list @missing) {.#None})))))))))))
)))]
_ (/////generation.execute! declaration)
_ (/////generation.save! function_artifact {.#None} declaration)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
index e0c33442d..e3d1e8dff 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
@@ -114,7 +114,7 @@
inputs)]
(in (list (` (def: .public ((~ g!name) (~+ inputsC))
(-> (~+ inputs_typesC) Computation)
- (_.apply/* {_.#Arguments (list (~+ inputsC))}
+ (_.apply/* (list (~+ inputsC)) {.#None}
(~ runtime_name))))
(` (def: (~ (code.local_symbol (format "@" name)))
@@ -304,7 +304,7 @@
)
(runtime: (i64//division parameter subject)
- (let [extra (_.do "remainder" {_.#Arguments (list parameter)} subject)]
+ (let [extra (_.do "remainder" (list parameter) {.#None} subject)]
(_.return (|> subject
(_.- extra)
(_./ parameter)))))
@@ -326,7 +326,7 @@
(with_vars [@input @temp]
($_ _.then
(_.set (list @input) inputG)
- (_.set (list @temp) (_.do "to_f" {_.#Arguments (list)} @input))
+ (_.set (list @temp) (_.do "to_f" (list) {.#None} @input))
(_.if ($_ _.or
(_.not (_.= (_.float +0.0) @temp))
(_.= (_.string "0") @input)
@@ -344,7 +344,7 @@
(runtime: (text//index subject param start)
(with_vars [idx]
($_ _.then
- (_.set (list idx) (|> subject (_.do "index" {_.#Arguments (list param start)})))
+ (_.set (list idx) (|> subject (_.do "index" (list param start) {.#None})))
(_.if (_.= _.nil idx)
(_.return ..none)
(_.return (..some idx))))))
@@ -361,7 +361,7 @@
(runtime: (text//char idx text)
(_.if (|> idx (within? (_.the "length" text)))
- (_.return (|> text (_.array_range idx idx) (_.do "ord" {_.#Arguments (list)})))
+ (_.return (|> text (_.array_range idx idx) (_.do "ord" (list) {.#None})))
(_.statement (_.raise (_.string "[Lux Error] Cannot get char from text.")))))
(def: runtime//text
@@ -386,15 +386,16 @@
(def: runtime
Statement
($_ _.then
- (_.when (_.and (_.not (_.do "method_defined?" {_.#Arguments (list (_.string "remainder"))}
+ (_.when (_.and (_.not (_.do "method_defined?" (list (_.string "remainder")) {.#None}
(_.local "Numeric")))
- (_.do "method_defined?" {_.#Arguments (list (_.string "remainder_of_divide"))}
+ (_.do "method_defined?" (list (_.string "remainder_of_divide")) {.#None}
(_.local "Numeric")))
... We're in DragonRuby territory.
(_.statement
- (_.do "class_eval" {_.#Block (_.statement
- (_.alias_method/2 (_.string "remainder")
- (_.string "remainder_of_divide")))}
+ (_.do "class_eval" (list) {.#Some (_.lambda {.#None} (list (_.local "_"))
+ (_.statement
+ (_.alias_method/2 (_.string "remainder")
+ (_.string "remainder_of_divide"))))}
(_.local "Numeric"))))
runtime//adt
runtime//lux