Skip to content

Commit

Permalink
Better compilation of or and and for different targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Oct 4, 2023
1 parent b3b42fd commit 9858723
Show file tree
Hide file tree
Showing 19 changed files with 402 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
[encoding
["[0]" name (.only External)]]
["[1]" type (.only Type Argument Typed)
["[0]" category (.only Void Value' Value Return' Return Primitive Object Class Array Var Parameter Method)]
["[0]" category (.only Void Value Return Primitive Object Class Array Var Parameter Method)]
["[0]" box]
["[0]" reflection]
["[0]" descriptor]
Expand Down Expand Up @@ -198,7 +198,7 @@

(the reflection
(for_any (_ category)
(-> (Type (<| Return' Value' category))
(-> (Type (Value category))
Text))
(|>> jvm.reflection reflection.reflection))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
["_" bytecode (.only Bytecode) (.use "[1]#[0]" monad)
["__" instruction (.only Primitive_Array_Type)]]
["[0]" type (.only Type Typed Argument)
["[0]" category (.only Void Value' Value Return' Return Primitive Object Array Var Parameter)]
["[0]" category (.only Void Value Return Primitive Object Array Var Parameter)]
["[0]" box]
["[0]" reflection]
["[0]" signature]
Expand Down Expand Up @@ -362,7 +362,7 @@

(the reflection
(for_any (_ category)
(-> (Type (<| Return' Value' category))
(-> (Type (Value category))
Text))
(|>> type.reflection reflection.reflection))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@
(synthesis.let @ let)
(/when.let expression archive let)

(synthesis.if @ if)
(/when.if expression archive if)
(synthesis.if @ it)
(<| (when (synthesis.or it)
{.#Some it}
(/when.or expression archive it)

else)
(when (synthesis.and it)
{.#Some it}
(/when.and expression archive it)

else)
(/when.if expression archive it))

(synthesis.its @ get)
(/when.get expression archive get)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

(.require
[library
[lux (.except when exec let if)
[lux (.except when exec let if
or and)
[abstract
["[0]" monad (.only do)]]
[control
Expand Down Expand Up @@ -386,3 +387,15 @@
(phase#each (function (_ it)
(_.apply (_.closure (list) it)
(list))))))

(template.with [,lux ,host]
[(the .public (,lux expression archive [parameter subject])
(Translator [synthesis.Term synthesis.Term])
(do phase.monad
[parameter (expression archive parameter)
subject (expression archive subject)]
(in (,host parameter subject))))]

[or _.or]
[and _.and]
)
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,18 @@
(synthesis.let @ let)
(/when.let expression archive let)

(synthesis.if @ if)
(/when.if expression archive if)
(synthesis.if @ it)
(<| (when (synthesis.or it)
{.#Some it}
(/when.or expression archive it)

else)
(when (synthesis.and it)
{.#Some it}
(/when.and expression archive it)

else)
(/when.if expression archive it))

(synthesis.its @ get)
(/when.get expression archive get)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

(.require
[library
[lux (.except when exec let if)
[lux (.except when exec let if
or and)
[abstract
["[0]" monad (.only do)]]
[data
Expand Down Expand Up @@ -350,3 +351,15 @@
(|>> (multi_let! statement expression archive)
(phase#each (|>> (_.closure (list))
(_.apply (list))))))

(template.with [,lux ,host]
[(the .public (,lux expression archive [parameter subject])
(Translator [synthesis.Term synthesis.Term])
(do phase.monad
[parameter (expression archive parameter)
subject (expression archive subject)]
(in (,host parameter subject))))]

[or _.or]
[and _.and]
)
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

[synthesis.exec /when.exec]
[synthesis.let /when.let]
[synthesis.if /when.if]
[synthesis.its /when.get]

[synthesis.apply /function.apply]))
Expand All @@ -73,12 +72,25 @@
[synthesis.scope /loop.scope]
[synthesis.abstraction /function.function]))

(synthesis.if @ it)
(<| (when (synthesis.or it)
{.#Some it}
(/when.or expression archive it)

else)
(when (synthesis.and it)
{.#Some it}
(/when.and expression archive it)

else)
(/when.if expression archive it))

(synthesis.when @ it)
(when (synthesis.multi_let it)
{.#Some it}
(/when.multi_let expression archive it)

_
else
(/when.when ///extension/common.statement expression archive it))

(synthesis.again @ updates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

(.require
[library
[lux (.except when exec let if symbol)
[lux (.except when exec let if
or and)
[abstract
["[0]" monad (.only do)]]
[data
Expand Down Expand Up @@ -47,11 +48,6 @@
[dependency
["[1]" artifact]]]]]]]]])

(the .public (symbol prefix)
(-> Text (Operation SVar))
(phase#each (|>> %.natural (%.message prefix) _.var)
/////translation.next))

(the .public register
(-> Register SVar)
(|>> (///reference.local //reference.system) as_expected))
Expand Down Expand Up @@ -185,24 +181,24 @@
[right_choice //runtime.unit]
)

(the (with_looping in_closure? g!once body!)
(the (with_looping in_closure? 'once body!)
(-> Bit SVar Statement Statement)
(.if in_closure?
(_.while (_.bool true)
body!
{.#None})
(all _.then
(_.set (list g!once) (_.bool true))
(_.while g!once
(_.set (list 'once) (_.bool true))
(_.while 'once
(all _.then
(_.set (list g!once) (_.bool false))
(_.set (list 'once) (_.bool false))
body!)
{.#Some _.continue}))))

(the (alternation in_closure? g!once pre! post!)
(the (alternation in_closure? 'once pre! post!)
(-> Bit SVar Statement Statement Statement)
(all _.then
(..with_looping in_closure? g!once
(..with_looping in_closure? 'once
(all _.then
..save!
pre!))
Expand Down Expand Up @@ -318,8 +314,8 @@
(do !
[pre! (again preP)
post! (again postP)
g!once (..symbol "once")]
(in (..alternation in_closure? g!once pre! post!)))
'once (phase#each _.var (/////translation.symbol "once"))]
(in (..alternation in_closure? 'once pre! post!)))

_
(undefined)))))))
Expand All @@ -328,9 +324,9 @@
(-> Bit Phase! Phase Archive Path (Operation Statement))
(do phase.monad
[pattern_matching! (pattern_matching' in_closure? statement expression archive pathP)
g!once (..symbol "once")]
'once (phase#each _.var (/////translation.symbol "once"))]
(in (all _.then
(..with_looping in_closure? g!once
(..with_looping in_closure? 'once
pattern_matching!)
(_.raise (_.Exception/1 (_.string when.pattern_matching_error)))))))

Expand Down Expand Up @@ -377,10 +373,10 @@

(the .public (multi_let! statement expression archive [input bindings body])
(Translator! synthesis.Multi_Let)
(do phase.monad
(do [! phase.monad]
[input (expression archive input)
body (statement expression archive body)
'source (..symbol "source")]
'source (phase#each _.var (/////translation.symbol "source"))]
(in (all _.then
(list#mix (function (_ [register member] left)
(all _.then
Expand All @@ -395,7 +391,7 @@
(do phase.monad
[input (expression archive input)
body (expression archive body)
'source (..symbol "source")]
'source (phase#each _.var (/////translation.symbol "source"))]
(in (<| (_.apply (list input))
(_.lambda (list 'source))
(_.apply (list#each (function (_ [register member])
Expand All @@ -405,3 +401,15 @@
(..register register))
bindings))
body))))

(template.with [,lux ,host]
[(the .public (,lux expression archive [parameter subject])
(Translator [synthesis.Term synthesis.Term])
(do phase.monad
[parameter (expression archive parameter)
subject (expression archive subject)]
(in (,host parameter subject))))]

[or _.or]
[and _.and]
)
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@

[synthesis.exec /when.exec]
[synthesis.let /when.let]
[synthesis.if /when.if]
[synthesis.its /when.get]

[synthesis.apply /function.apply]))
Expand All @@ -74,6 +73,19 @@
[synthesis.scope /loop.scope]
[synthesis.abstraction /function.function]))

(synthesis.if @ it)
(<| (when (synthesis.or it)
{.#Some it}
(/when.or expression archive it)

else)
(when (synthesis.and it)
{.#Some it}
(/when.and expression archive it)

else)
(/when.if expression archive it))

(synthesis.when @ it)
(when (synthesis.multi_let it)
{.#Some it}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

(.require
[library
[lux (.except when exec let if symbol)
[lux (.except symbol
when exec let if
or and)
[abstract
["[0]" monad (.only do)]]
[data
Expand Down Expand Up @@ -43,10 +45,11 @@
[meta
[archive (.only Archive)]]]]]]])

(the .public (symbol prefix)
(-> Text (Operation LVar))
(phase#each (|>> %.natural (%.message prefix) _.local)
/////translation.next))
(the symbol
(-> Text
(Operation LVar))
(|>> /////translation.symbol
(phase#each _.local)))

(the .public register
(-> Register LVar)
Expand Down Expand Up @@ -424,3 +427,15 @@
(of phase.monad each
(|>> [(list)] (_.lambda {.#None})
(_.apply_lambda (list))))))

(template.with [,lux ,host]
[(the .public (,lux expression archive [parameter subject])
(Translator [synthesis.Term synthesis.Term])
(do phase.monad
[parameter (expression archive parameter)
subject (expression archive subject)]
(in (,host parameter subject))))]

[or _.or]
[and _.and]
)
Loading

0 comments on commit 9858723

Please sign in to comment.