From f3acc0d67e6cd4e7245c1e169a3c0469da4373a3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 12 Oct 2017 01:27:48 -0400 Subject: - Compilation and tests for primitive conversions. --- .../source/luxc/generator/procedure/common.jvm.lux | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'new-luxc/source/luxc/generator/procedure/common.jvm.lux') diff --git a/new-luxc/source/luxc/generator/procedure/common.jvm.lux b/new-luxc/source/luxc/generator/procedure/common.jvm.lux index ffbe69708..70f38f962 100644 --- a/new-luxc/source/luxc/generator/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/generator/procedure/common.jvm.lux @@ -34,22 +34,22 @@ (#static NEGATIVE_INFINITY Double)) ## [Types] -(type: Generator +(type: #export Generator (-> ls;Synthesis (Lux $;Inst))) -(type: Proc +(type: #export Proc (-> Generator (List ls;Synthesis) (Lux $;Inst))) -(type: Bundle +(type: #export Bundle (Dict Text Proc)) (syntax: (Vector [size s;nat] elemT) (wrap (list (` [(~@ (list;repeat size elemT))])))) -(type: Nullary (-> (Vector +0 $;Inst) $;Inst)) -(type: Unary (-> (Vector +1 $;Inst) $;Inst)) -(type: Binary (-> (Vector +2 $;Inst) $;Inst)) -(type: Trinary (-> (Vector +3 $;Inst) $;Inst)) +(type: #export Nullary (-> (Vector +0 $;Inst) $;Inst)) +(type: #export Unary (-> (Vector +1 $;Inst) $;Inst)) +(type: #export Binary (-> (Vector +2 $;Inst) $;Inst)) +(type: #export Trinary (-> (Vector +3 $;Inst) $;Inst)) ## [Utils] (def: $Object $;Type ($t;class "java.lang.Object" (list))) @@ -58,12 +58,19 @@ (def: $CharSequence $;Type ($t;class "java.lang.CharSequence" (list))) (def: $Function $;Type ($t;class &runtime;function-class (list))) -(def: (install name unnamed) +(def: #export (install name unnamed) (-> Text (-> Text Proc) (-> Bundle Bundle)) (dict;put name (unnamed name))) -(def: (wrong-amount-error proc expected actual) +(def: #export (prefix prefix bundle) + (-> Text Bundle Bundle) + (|> bundle + dict;entries + (list/map (function [[key val]] [(format prefix " " key) val])) + (dict;from-list text;Hash))) + +(def: (wrong-arity proc expected actual) (-> Text Nat Nat Text) (format "Wrong number of arguments for " (%t proc) "\n" "Expected: " (|> expected nat-to-int %i) "\n" @@ -73,7 +80,7 @@ (with-gensyms [g!proc g!name g!generate g!inputs] (do @ [g!input+ (monad;seq @ (list;repeat arity (macro;gensym "input")))] - (wrap (list (` (def: ((~ (code;local-symbol name)) (~ g!proc)) + (wrap (list (` (def: #export ((~ (code;local-symbol name)) (~ g!proc)) (-> (-> (Vector (~ (code;nat arity)) $;Inst) $;Inst) (-> Text Proc)) (function [(~ g!name)] @@ -88,7 +95,7 @@ ((~' wrap) ((~ g!proc) [(~@ g!input+)]))) (~' _) - (macro;fail (wrong-amount-error (~ g!name) +1 (list;size (~ g!inputs)))))))))))))) + (macro;fail (wrong-arity (~ g!name) +1 (list;size (~ g!inputs)))))))))))))) (arity: nullary +0) (arity: unary +1) -- cgit v1.2.3