aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2019-04-16 20:53:41 -0400
committerEduardo Julian2019-04-16 20:53:41 -0400
commit697707d8560a5735be38fd9b1ff91a02c289d48f (patch)
tree7f9e81974c9ec3ede82e7f2392ebba037e3e9df8 /new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux
parent42248854f0cb5e3364e6aae25527cee65cbda3e8 (diff)
Made some new-luxc modules "old".
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux79
1 files changed, 0 insertions, 79 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux
deleted file mode 100644
index d7e706aaf..000000000
--- a/new-luxc/source/luxc/lang/translation/jvm/loop.jvm.lux
+++ /dev/null
@@ -1,79 +0,0 @@
-(.module:
- [lux #*
- [abstract
- ["." monad (#+ do)]]
- [control
- ["." function]]
- [data
- ["." text
- format]
- [collection
- ["." list ("#/." functor monoid)]]]
- [tool
- [compiler
- [reference (#+ Register)]
- ["." synthesis (#+ Synthesis)]
- ["." phase
- ["." generation]]]]]
- [luxc
- [lang
- [host
- [jvm (#+ Inst Operation Phase)
- ["_" inst]]]]]
- ["." //])
-
-(def: (constant? register changeS)
- (-> Register Synthesis Bit)
- (case changeS
- (^ (synthesis.variable/local var))
- (n/= register var)
-
- _
- #0))
-
-(def: #export (recur translate argsS)
- (-> Phase (List Synthesis) (Operation Inst))
- (do phase.monad
- [[@begin start] generation.anchor
- #let [end (|> argsS list.size dec (n/+ start))
- pairs (list.zip2 (list.n/range start end)
- argsS)]
- ## It may look weird that first I compile the values separately,
- ## and then I compile the stores/allocations.
- ## It must be done that way in order to avoid a potential bug.
- ## Let's say that you'll recur with 2 expressions: X and Y.
- ## If Y depends on the value of X, and you don't compile values
- ## and stores separately, then by the time Y is evaluated, it
- ## will refer to the new value of X, instead of the old value, as
- ## should be the case.
- valuesI+ (monad.map @ (function (_ [register argS])
- (: (Operation Inst)
- (if (constant? register argS)
- (wrap function.identity)
- (translate argS))))
- pairs)
- #let [storesI+ (list/map (function (_ [register argS])
- (: Inst
- (if (constant? register argS)
- function.identity
- (_.ASTORE register))))
- (list.reverse pairs))]]
- (wrap (|>> (_.fuse valuesI+)
- (_.fuse storesI+)
- (_.GOTO @begin)))))
-
-(def: #export (scope translate [start initsS+ iterationS])
- (-> Phase [Nat (List Synthesis) Synthesis] (Operation Inst))
- (do phase.monad
- [@begin _.make-label
- initsI+ (monad.map @ translate initsS+)
- iterationI (generation.with-anchor [@begin start]
- (translate iterationS))
- #let [initializationI (|> (list.enumerate initsI+)
- (list/map (function (_ [register initI])
- (|>> initI
- (_.ASTORE (n/+ start register)))))
- _.fuse)]]
- (wrap (|>> initializationI
- (_.label @begin)
- iterationI))))