aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/lua
diff options
context:
space:
mode:
authorEduardo Julian2018-07-31 20:22:15 -0400
committerEduardo Julian2018-07-31 20:22:15 -0400
commit7e44ee8a2cfb14e35f6283a9eb8d6a2ddc8bd99a (patch)
tree98a12aa5a9fd347c1070612a2a1dae69dae879b1 /new-luxc/source/luxc/lang/translation/lua
parenteea58ee669f69fddf2cef9e1675c41959e2e0a55 (diff)
Now implementing process functionality in stdlib instead of the compiler.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux18
-rw-r--r--new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux45
2 files changed, 0 insertions, 63 deletions
diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
index 356adb5c3..4b128f946 100644
--- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux
@@ -319,15 +319,6 @@
Binary
(runtimeT.box//write valueO boxO))
-## [[Processes]]
-(def: (process//parallelism-level [])
- Nullary
- (lua.int 1))
-
-(def: (process//schedule [milli-secondsO procedureO])
- Binary
- (runtimeT.process//schedule milli-secondsO procedureO))
-
## [Bundles]
(def: lux-procs
Bundle
@@ -424,14 +415,6 @@
(install "read" (unary box//read))
(install "write" (binary box//write)))))
-(def: process-procs
- Bundle
- (<| (prefix "process")
- (|> (dict.new text.Hash<Text>)
- (install "parallelism-level" (nullary process//parallelism-level))
- (install "schedule" (binary process//schedule))
- )))
-
(def: #export procedures
Bundle
(<| (prefix "lux")
@@ -443,5 +426,4 @@
(dict.merge array-procs)
(dict.merge io-procs)
(dict.merge box-procs)
- (dict.merge process-procs)
)))
diff --git a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux
index 3a18f98e7..ce9c37db5 100644
--- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux
@@ -258,50 +258,6 @@
Runtime
(format @@box//write))
-(def: process//incoming
- Text
- (lang.normalize-name "process//incoming"))
-
-(runtime: (process//loop _)
- (let [migrate-incoming! (lua.block! (list (lua.for-step! "idx" (lua.int 1) (lua.length process//incoming) (lua.int 1)
- (lua.apply "table.insert" (list "queue" (lua.nth "idx" process//incoming))))
- (lua.set! process//incoming (lua.array (list)))))
- consume-queue! (lua.block! (list (lua.local! "survivors" (#.Some (lua.array (list))))
- (lua.local! "active_processes" (#.Some (lua.length "queue")))
- (lua.for-step! "idx" (lua.int 1) "active_processes" (lua.int 1)
- (lua.block! (list (lua.local! "process" (#.Some (lua.nth "idx" "queue")))
- (lua.when! (lua.apply "coroutine.resume" (list "process"))
- (lua.apply "table.insert" (list "survivors" "process"))))))
- (lua.set! "queue" "survivors")))
- loop-body! (lua.block! (list migrate-incoming!
- consume-queue!))]
- (lua.block! (list (lua.local! "queue" (#.Some (lua.array (list))))
- loop-body!
- (lua.while! (|> (lua.length "queue") (lua.> (lua.int 0)))
- loop-body!)))))
-
-(runtime: (process//schedule milli-seconds procedure)
- (let [now (lua.apply "os.time" (list))]
- (lua.if! (lua.= (lua.int 0) milli-seconds)
- (lua.apply "table.insert" (list process//incoming
- (lua.function (list)
- (lua.return! (lua.apply procedure (list unit))))))
- (lua.block! (list (lua.local! "start" (#.Some now))
- (lua.local! "seconds" (#.Some (lua.// (lua.int 1_000)
- milli-seconds)))
- (lua.apply "table.insert" (list process//incoming
- (lua.function (list)
- (lua.block! (list (lua.while! (lua.< "seconds" (lua.- "start" now))
- (lua.apply "coroutine.yield" (list)))
- (lua.return! (lua.apply procedure (list unit))))))))
- (lua.return! unit))))))
-
-(def: runtime//process
- Runtime
- (format (lua.global! process//incoming (#.Some (lua.array (list))))
- @@process//loop
- @@process//schedule))
-
(runtime: (lua//get object field)
(lua.block! (list (lua.local! "value" (#.Some (lua.nth field object)))
(lua.if! (lua.= lua.nil "value")
@@ -325,7 +281,6 @@
runtime//text
runtime//array
runtime//box
- runtime//process
runtime//lua))
(def: #export artifact Text (format prefix ".lua"))