aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2018-01-08 21:29:02 -0400
committerEduardo Julian2018-01-08 21:29:02 -0400
commitf523bc14d43286348aeb200bd0554812dc6ef28d (patch)
tree58876df8fc7b6ec9384c8ed4239a290567120542
parentb7d53027deeb185fa7b4312ba7079aa566762513 (diff)
- Now using synthesis extensions during synthesis.
-rw-r--r--new-luxc/source/luxc/lang/eval.lux6
-rw-r--r--new-luxc/source/luxc/lang/extension.lux19
-rw-r--r--new-luxc/source/luxc/lang/extension/statement.lux19
-rw-r--r--new-luxc/source/luxc/lang/synthesis/expression.lux12
-rw-r--r--new-luxc/source/luxc/lang/translation.lux8
5 files changed, 45 insertions, 19 deletions
diff --git a/new-luxc/source/luxc/lang/eval.lux b/new-luxc/source/luxc/lang/eval.lux
index 62d6a438b..87cbadfa0 100644
--- a/new-luxc/source/luxc/lang/eval.lux
+++ b/new-luxc/source/luxc/lang/eval.lux
@@ -3,7 +3,8 @@
(lux (control [monad #+ do])
[macro])
(luxc ["&" lang]
- (lang (analysis [".A" expression])
+ (lang [".L" extension]
+ (analysis [".A" expression])
(synthesis [".S" expression])
(translation [".T" expression]
[".T" eval]))))
@@ -13,6 +14,7 @@
(do macro.Monad<Meta>
[exprA (&.with-type type
(expressionA.analyser eval exprC))
- #let [exprS (expressionS.synthesize exprA)]
+ syntheses extensionL.all-syntheses
+ #let [exprS (expressionS.synthesize syntheses exprA)]
exprI (expressionT.translate exprS)]
(evalT.eval exprI)))
diff --git a/new-luxc/source/luxc/lang/extension.lux b/new-luxc/source/luxc/lang/extension.lux
index 248bfbb71..ff3a4d24e 100644
--- a/new-luxc/source/luxc/lang/extension.lux
+++ b/new-luxc/source/luxc/lang/extension.lux
@@ -6,7 +6,9 @@
[text]
(coll [dict #+ Dict]))
[macro])
- [//])
+ [//]
+ (// ["la" analysis]
+ ["ls" synthesis]))
(exception: #export Unknown-Analysis)
(exception: #export Unknown-Synthesis)
@@ -24,7 +26,9 @@
(List Code) (Meta Code)))
(type: #export Synthesis
- (-> (List Code) (Meta Code)))
+ (-> (-> la.Analysis ls.Synthesis) (List Code) Code))
+
+(type: #export Syntheses (Dict Text Synthesis))
(type: #export Translation
(-> (List Code) (Meta Code)))
@@ -34,7 +38,7 @@
(type: #export Extensions
{#analysis (Dict Text Analysis)
- #synthesis (Dict Text Synthesis)
+ #synthesis Syntheses
#translation (Dict Text Translation)
#statement (Dict Text Statement)})
@@ -75,6 +79,15 @@
[find-statement Statement #statement Unknown-Statement]
)
+(do-template [<name> <type> <category>]
+ [(def: #export <name>
+ (Meta <type>)
+ (|> ..get
+ (:: macro.Monad<Meta> map (get@ <category>))))]
+
+ [all-syntheses (Dict Text Synthesis) #synthesis]
+ )
+
(do-template [<name> <type> <category> <exception>]
[(def: #export (<name> name extension)
(-> Text <type> (Meta Unit))
diff --git a/new-luxc/source/luxc/lang/extension/statement.lux b/new-luxc/source/luxc/lang/extension/statement.lux
index afabf867b..7eb2b36bf 100644
--- a/new-luxc/source/luxc/lang/extension/statement.lux
+++ b/new-luxc/source/luxc/lang/extension/statement.lux
@@ -9,7 +9,7 @@
[macro]
(lang (type ["tc" check]))
[io #+ IO])
- [//]
+ [// #+ Syntheses]
(luxc [lang]
(lang [".L" host]
[".L" scope]
@@ -36,13 +36,13 @@
(format "\n " (%n idx) " " (%code inputC))))
(text.join-with "")) "\n")))
-(def: (process-annotations annsC)
- (-> Code (Meta [$.Inst Code]))
+(def: (process-annotations syntheses annsC)
+ (-> Syntheses Code (Meta [$.Inst Code]))
(do macro.Monad<Meta>
[[_ annsA] (lang.with-scope
(lang.with-type Code
(expressionA.analyser evalL.eval annsC)))
- annsI (expressionT.translate (expressionS.synthesize annsA))
+ annsI (expressionT.translate (expressionS.synthesize syntheses annsA))
annsV (evalT.eval annsI)]
(wrap [annsI (:! Code annsV)])))
@@ -64,7 +64,8 @@
(hostL.with-context def-name
(lang.with-fresh-type-env
(do macro.Monad<Meta>
- [[annotationsI annotationsV] (process-annotations annotationsC)]
+ [syntheses //.all-syntheses
+ [annotationsI annotationsV] (process-annotations syntheses annotationsC)]
(case (macro.get-symbol-ann (ident-for #.alias) annotationsV)
(#.Some real-def)
(do @
@@ -85,7 +86,7 @@
(expressionA.analyser evalL.eval valueC))))
valueT (lang.with-type-env
(tc.clean valueT))
- valueI (expressionT.translate (expressionS.synthesize valueA))
+ valueI (expressionT.translate (expressionS.synthesize syntheses valueA))
_ (lang.with-scope
(statementT.translate-def def-name valueT valueI annotationsI annotationsV))]
(wrap []))))))
@@ -103,7 +104,8 @@
(scopeL.with-local [args (type (List Text))])
(lang.with-type (type (IO Unit)))
(expressionA.analyser evalL.eval programC))
- programI (expressionT.translate (expressionS.synthesize programA))
+ syntheses //.all-syntheses
+ programI (expressionT.translate (expressionS.synthesize syntheses programA))
_ (statementT.translate-program programI)]
(wrap []))
@@ -120,7 +122,8 @@
[[_ valueA] (lang.with-scope
(lang.with-type <type>
(expressionA.analyser evalL.eval valueC)))
- valueI (expressionT.translate (expressionS.synthesize valueA))
+ syntheses //.all-syntheses
+ valueI (expressionT.translate (expressionS.synthesize syntheses valueA))
valueV (evalT.eval valueI)
_ (<installer> name (:! <type> valueV))]
(wrap []))
diff --git a/new-luxc/source/luxc/lang/synthesis/expression.lux b/new-luxc/source/luxc/lang/synthesis/expression.lux
index b31a146a1..2dbf8ed5a 100644
--- a/new-luxc/source/luxc/lang/synthesis/expression.lux
+++ b/new-luxc/source/luxc/lang/synthesis/expression.lux
@@ -12,6 +12,7 @@
["s" syntax]))
(luxc (lang ["la" analysis]
["ls" synthesis]
+ [".L" extension #+ Syntheses]
(synthesis [".S" case]
[".S" function]
[".S" loop])
@@ -113,8 +114,8 @@
_
(call$ funcS argsS))))
-(def: #export (synthesize expressionA)
- (-> la.Analysis ls.Synthesis)
+(def: #export (synthesize syntheses expressionA)
+ (-> Syntheses la.Analysis ls.Synthesis)
(loop [arity +0
resolver init-resolver
direct? false
@@ -190,7 +191,12 @@
(synthesize-apply (recur arity resolver false num-locals) num-locals expressionA)
(^code ((~ [_ (#.Text name)]) (~+ args)))
- (procedure$ name (list/map (recur arity resolver false num-locals) args))
+ (case (dict.get name syntheses)
+ #.None
+ (procedure$ name (list/map (recur arity resolver false num-locals) args))
+
+ (#.Some synthesis)
+ (synthesis (recur arity resolver false num-locals) args))
_
expressionA)))
diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux
index 1a8ae9be0..9a2b27122 100644
--- a/new-luxc/source/luxc/lang/translation.lux
+++ b/new-luxc/source/luxc/lang/translation.lux
@@ -57,7 +57,8 @@
[[_ annsA] (&.with-scope
(&.with-type Code
(analyse annsC)))
- annsI (expressionT.translate (expressionS.synthesize annsA))
+ syntheses extensionL.all-syntheses
+ annsI (expressionT.translate (expressionS.synthesize syntheses annsA))
annsV (evalT.eval annsI)]
(wrap [annsI (:! Code annsV)])))
@@ -203,8 +204,9 @@
(wrap [module artifacts])))
(#e.Success [compiler [module artifacts]])
(do @
- [_ (&io.prepare-module target-dir module-name)
- _ (write-module target-dir file-name module-name module artifacts)]
+ [## _ (&io.prepare-module target-dir module-name)
+ ## _ (write-module target-dir file-name module-name module artifacts)
+ ]
(wrap compiler))
(#e.Error error)