aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux')
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux145
1 files changed, 145 insertions, 0 deletions
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux
new file mode 100644
index 000000000..855f5754d
--- /dev/null
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/host.lux
@@ -0,0 +1,145 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ ["[0]" monad (.only do)]]
+ [control
+ ["<>" parser]
+ ["[0]" function]]
+ [data
+ [collection
+ ["[0]" dictionary]
+ ["[0]" list]]
+ [text
+ ["%" \\format (.only format)]]]
+ [meta
+ [target
+ ["_" php (.only Var Expression)]]]]]
+ ["[0]" //
+ ["[1][0]" common (.only custom)]
+ ["//[1]" ///
+ ["/" bundle]
+ ["/[1]" //
+ ["[0]" extension]
+ [generation
+ [extension (.only Nullary Unary Binary Trinary
+ nullary unary binary trinary)]
+ ["[0]" reference]
+ ["//" php
+ ["[1][0]" runtime (.only Operation Phase Handler Bundle
+ with_vars)]]]
+ ["/[1]" //
+ ["[0]" generation]
+ [synthesis
+ ["<s>" \\parser (.only Parser)]]
+ ["//[1]" ///
+ ["[1][0]" phase]]]]]])
+
+(def (array::new size)
+ (Unary Expression)
+ (//runtime.tuple//make size (_.array_fill/3 [(_.int +0) size _.null])))
+
+(def (array::read [indexG arrayG])
+ (Binary Expression)
+ (_.item indexG arrayG))
+
+(def (array::write [indexG valueG arrayG])
+ (Trinary Expression)
+ (//runtime.array//write indexG valueG arrayG))
+
+(def (array::delete [indexG arrayG])
+ (Binary Expression)
+ (//runtime.array//write indexG _.null arrayG))
+
+(def array
+ Bundle
+ (<| (/.prefix "array")
+ (|> /.empty
+ (/.install "new" (unary array::new))
+ (/.install "length" (unary //runtime.array//length))
+ (/.install "read" (binary array::read))
+ (/.install "write" (trinary array::write))
+ (/.install "delete" (binary array::delete))
+ )))
+
+(def object::new
+ (custom
+ [(all <>.and <s>.text (<>.some <s>.any))
+ (function (_ extension phase archive [constructor inputsS])
+ (do [! ////////phase.monad]
+ [inputsG (monad.each ! (phase archive) inputsS)]
+ (in (_.new (_.constant constructor) inputsG))))]))
+
+(def object::get
+ Handler
+ (custom
+ [(all <>.and <s>.text <s>.any)
+ (function (_ extension phase archive [fieldS objectS])
+ (do ////////phase.monad
+ [objectG (phase archive objectS)]
+ (in (_.the fieldS objectG))))]))
+
+(def object::do
+ Handler
+ (custom
+ [(all <>.and <s>.text <s>.any (<>.some <s>.any))
+ (function (_ extension phase archive [methodS objectS inputsS])
+ (do [! ////////phase.monad]
+ [objectG (phase archive objectS)
+ inputsG (monad.each ! (phase archive) inputsS)]
+ (in (_.do methodS inputsG objectG))))]))
+
+(with_template [<!> <?> <unit>]
+ [(def <!> (Nullary Expression) (function.constant <unit>))
+ (def <?> (Unary Expression) (_.=== <unit>))]
+
+ [object::null object::null? _.null]
+ )
+
+(def object
+ Bundle
+ (<| (/.prefix "object")
+ (|> /.empty
+ (/.install "new" object::new)
+ (/.install "get" object::get)
+ (/.install "do" object::do)
+ (/.install "null" (nullary object::null))
+ (/.install "null?" (unary object::null?))
+ )))
+
+(def php::constant
+ (custom
+ [<s>.text
+ (function (_ extension phase archive name)
+ (at ////////phase.monad in (_.constant name)))]))
+
+(def php::apply
+ (custom
+ [(all <>.and <s>.any (<>.some <s>.any))
+ (function (_ extension phase archive [abstractionS inputsS])
+ (do [! ////////phase.monad]
+ [abstractionG (phase archive abstractionS)
+ inputsG (monad.each ! (phase archive) inputsS)]
+ (in (_.apply inputsG abstractionG))))]))
+
+(def php::pack
+ (custom
+ [(all <>.and <s>.any <s>.any)
+ (function (_ extension phase archive [formatS dataS])
+ (do [! ////////phase.monad]
+ [formatG (phase archive formatS)
+ dataG (phase archive dataS)]
+ (in (_.pack/2 [formatG (_.splat dataG)]))))]))
+
+(def .public bundle
+ Bundle
+ (<| (/.prefix "php")
+ (|> /.empty
+ (dictionary.composite ..array)
+ (dictionary.composite ..object)
+
+ (/.install "constant" php::constant)
+ (/.install "apply" php::apply)
+ (/.install "pack" php::pack)
+ (/.install "script universe" (nullary (function.constant (_.bool reference.universe))))
+ )))