From 950ac7c3311ad8ff4499164a30610fca2e57d5c9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 21 Feb 2019 21:25:14 -0400 Subject: Moved extension machinery over. --- .../lang/translation/js/procedure/host.jvm.lux | 149 --------------------- 1 file changed, 149 deletions(-) delete mode 100644 new-luxc/source/luxc/lang/translation/js/procedure/host.jvm.lux (limited to 'new-luxc/source/luxc/lang/translation/js/procedure/host.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/host.jvm.lux deleted file mode 100644 index 00c2429a4..000000000 --- a/new-luxc/source/luxc/lang/translation/js/procedure/host.jvm.lux +++ /dev/null @@ -1,149 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do]) - (data [text] - text/format - (coll [list "list/" Functor] - (dictionary ["dict" unordered #+ Dict]))) - [macro "macro/" Monad]) - (luxc ["&" lang] - (lang ["la" analysis] - ["ls" synthesis])) - [///] - (/// [".T" runtime]) - (// ["@" common])) - -(do-template [ ] - [(def: ( _) @.Nullary )] - - [js//null "null"] - [js//undefined "undefined"] - [js//object "{}"] - ) - -(def: (js//global proc translate inputs) - (-> Text @.Proc) - (case inputs - (^ (list [_ (#.Text name)])) - (do macro.Monad - [] - (wrap name)) - - _ - (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) - -(def: (js//call proc translate inputs) - (-> Text @.Proc) - (case inputs - (^ (list& functionS argsS+)) - (do macro.Monad - [functionJS (translate functionS) - argsJS+ (monad.map @ translate argsS+)] - (wrap (format "(" functionJS ")(" - (text.join-with "," argsJS+) - ")"))) - - _ - (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) - -(def: js-procs - @.Bundle - (|> (dict.new text.Hash) - (@.install "null" (@.nullary js//null)) - (@.install "undefined" (@.nullary js//undefined)) - (@.install "object" (@.nullary js//object)) - (@.install "global" js//global) - (@.install "call" js//call))) - -(def: (object//new proc translate inputs) - (-> Text @.Proc) - (case inputs - (^ (list& constructorS argsS+)) - (do macro.Monad - [constructorJS (translate constructorS) - argsJS+ (monad.map @ translate argsS+)] - (wrap (format "new (" constructorJS ")(" - (text.join-with "," argsJS+) - ")"))) - - _ - (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) - -(def: (object//call proc translate inputs) - (-> Text @.Proc) - (case inputs - (^ (list& objectS fieldS argsS+)) - (do macro.Monad - [objectJS (translate objectS) - fieldJS (translate fieldS) - argsJS+ (monad.map @ translate argsS+)] - (wrap (format runtimeT.js//call - "(" objectJS - "," fieldJS - "," "[" (text.join-with "," argsJS+) "]" - ")"))) - - _ - (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) - -(def: (object//get [fieldJS objectJS]) - @.Binary - (format runtimeT.js//get "(" objectJS "," fieldJS ")")) - -(def: (object//set [fieldJS valueJS objectJS]) - @.Trinary - (format runtimeT.js//set "(" objectJS "," fieldJS "," valueJS ")")) - -(def: (object//delete [fieldJS objectJS]) - @.Binary - (format runtimeT.js//delete "(" objectJS "," fieldJS ")")) - -(def: object-procs - @.Bundle - (<| (@.prefix "object") - (|> (dict.new text.Hash) - (@.install "new" object//new) - (@.install "call" object//call) - (@.install "get" (@.binary object//get)) - (@.install "set" (@.trinary object//set)) - (@.install "delete" (@.binary object//delete)) - ))) - -(def: (array//literal elementsJS+) - @.Variadic - (format "[" (text.join-with "," elementsJS+) "]")) - -(def: (array//read [indexJS arrayJS]) - @.Binary - (format runtimeT.array//get "(" arrayJS "," indexJS ")")) - -(def: (array//write [indexJS valueJS arrayJS]) - @.Trinary - (format runtimeT.array//put "(" arrayJS "," indexJS "," valueJS ")")) - -(def: (array//delete [indexJS arrayJS]) - @.Binary - (format runtimeT.array//remove "(" arrayJS "," indexJS ")")) - -(def: (array//length arrayJS) - @.Unary - (format arrayJS ".length")) - -(def: array-procs - @.Bundle - (<| (@.prefix "array") - (|> (dict.new text.Hash) - (@.install "literal" (@.variadic array//literal)) - (@.install "read" (@.binary array//read)) - (@.install "write" (@.trinary array//write)) - (@.install "delete" (@.binary array//delete)) - (@.install "length" (@.unary array//length)) - ))) - -(def: #export procedures - @.Bundle - (<| (@.prefix "js") - (|> js-procs - (dict.merge object-procs) - (dict.merge array-procs) - ))) -- cgit v1.2.3