diff options
author | Eduardo Julian | 2021-11-16 03:15:39 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-11-16 03:15:39 -0400 |
commit | ce4ffdcecd271b9cebf62d71977a2d5cb5a1a0ee (patch) | |
tree | 895fb7d79ba3ba4440af47ac448a87ad815af3cc /stdlib/source/library/lux/target | |
parent | 1b110d177a8bc12776a6d24bd6d3f693abe5ba2a (diff) |
64-bit integers that work in both normal Ruby & DragonRuby.
Diffstat (limited to 'stdlib/source/library/lux/target')
-rw-r--r-- | stdlib/source/library/lux/target/js.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/target/ruby.lux | 42 |
2 files changed, 38 insertions, 12 deletions
diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 88ad9ff5e..6ee7a793c 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -243,14 +243,14 @@ [bit_and "&"] ) - (template [<name> <prefix>] + (template [<prefix> <name>] [(def: .public <name> (-> Expression Computation) (|>> :representation (text.prefix <prefix>) ..expression :abstraction))] - [not "!"] - [bit_not "~"] - [opposite "-"] + ["!" not] + ["~" bit_not] + ["-" opposite] ) (template [<name> <input> <format>] diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index eb0f542ac..3280ac134 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -221,18 +221,30 @@ (format content \n+ "end" ..statement_suffix)) - (def: .public (apply/* arguments block_lambda func) - (-> (List Expression) (Maybe Expression) Expression Computation) + (type: .public Block + [(List LVar) + Statement]) + + (def: .public (apply/* arguments block func) + (-> (List Expression) (Maybe Block) Expression Computation) (let [arguments (|> arguments (list#each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"])) - block (case block_lambda + block (case block {.#None} "" - {.#Some lambda} - (format " &" (:representation lambda)))] + {.#Some [inputs block]} + (|> block + :representation + nested + control_structure + (format " do " + (|> inputs + (list#each (|>> :representation)) + (text.interposed ..input_separator) + (text.enclosed' "|")))))] (:abstraction (format (:representation func) arguments block)))) (def: .public (the field object) @@ -413,6 +425,7 @@ (:abstraction (format "(" <unary> (:representation subject) ")")))] ["!" not] + ["~" bit_not] ["-" opposite] ) @@ -420,11 +433,24 @@ (All (_ brand) (-> Text (Code brand) (Code brand))) (:abstraction (format "# " (..safe commentary) \n+ (:representation on)))) + + (def: .public (class name definition) + (-> LVar Statement Statement) + (:abstraction + (format "class " (:representation name) + (control_structure + (nested + (:representation definition)))))) + + (def: .public (attribute_readers attributes) + (-> (List Text) Statement) + (..statement + (..apply/* (list#each ..string attributes) {.#None} (..local "attr_reader")))) ) -(def: .public (do method arguments block_lambda object) - (-> Text (List Expression) (Maybe Expression) Expression Computation) - (|> object (..the method) (..apply/* arguments block_lambda))) +(def: .public (do method arguments block object) + (-> Text (List Expression) (Maybe Block) Expression Computation) + (|> object (..the method) (..apply/* arguments block))) (def: .public (apply_lambda/* args lambda) (-> (List Expression) Expression Computation) |