aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux39
1 files changed, 18 insertions, 21 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
index 43dcbe716..9102dd30d 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
@@ -177,33 +177,30 @@
@lux//program-args
))
-(runtime: (tuple//left tuple lefts)
- (with-vars [index-right]
+(runtime: (tuple//left lefts tuple)
+ (with-vars [last-index-right]
($_ _.then
- (_.define index-right (..last-index tuple))
- (_.if (_.> lefts index-right)
+ (_.define last-index-right (..last-index tuple))
+ (_.if (_.> lefts last-index-right)
## No need for recursion
(_.return (_.at lefts tuple))
## Needs recursion
- (_.return (tuple//left (_.at index-right tuple)
- (_.- index-right lefts)))))))
+ (_.return (tuple//left (_.- last-index-right lefts)
+ (_.at last-index-right tuple)))))))
-(runtime: (product//right product index)
- (with-vars [index-min-length]
+(runtime: (tuple//right lefts tuple)
+ (with-vars [last-index-right right-index]
($_ _.then
- (_.define index-min-length (_.+ (_.i32 +1) index))
- (_.cond (list [(_.= index-min-length
- (..length product))
- ## Last element.
- (_.return (_.at index product))]
- [(_.< index-min-length
- (..length product))
+ (_.define last-index-right (..last-index tuple))
+ (_.define right-index (_.+ (_.i32 +1) lefts))
+ (_.cond (list [(_.= right-index last-index-right)
+ (_.return (_.at right-index tuple))]
+ [(_.> right-index last-index-right)
## Needs recursion.
- (_.return (product//right (last-element product)
- (_.- (..length product)
- index-min-length)))])
- ## Must slice
- (_.return (_.do "slice" (list index) product))))))
+ (_.return (tuple//right (_.- last-index-right lefts)
+ (_.at last-index-right tuple)))])
+ (_.return (_.do "slice" (list right-index) tuple)))
+ )))
(runtime: (sum//get sum wants-last wanted-tag)
(let [no-match! (_.return _.null)
@@ -232,7 +229,7 @@
Statement
($_ _.then
@tuple//left
- @product//right
+ @tuple//right
@sum//get
))