aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/common.jvm.lux
blob: b01a68c3dd29df53a77947968816a620979b5299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(.module:
  [lux #*
   [control
    [monad (#+ do)]
    ["ex" exception (#+ exception:)]]
   [io]
   [concurrency
    [atom (#+ Atom atom)]]
   [data
    [error (#+ Error)]
    [text ("text/" Hash<Text>)
     format]
    [collection
     [dictionary (#+ Dictionary)]]]
   [macro]
   [host (#+ import:)]
   [world
    [blob (#+ Blob)]]
   [language
    [name]
    [reference (#+ Register)]
    ["." compiler]]]
  ## [luxc
  ##  [lang
  ##   [host
  ##    ["." jvm
  ##     [type]]]]]
  )

## (def: #export (with-artifacts action)
##   (All [a] (-> (Meta a) (Meta [Artifacts a])))
##   (function (_ compiler)
##     (case (action (update@ #.host
##                            (|>> (:coerce Host)
##                                 (set@ #artifacts (dictionary.new text.Hash<Text>))
##                                 (:coerce Nothing))
##                            compiler))
##       (#error.Success [compiler' output])
##       (#error.Success [(update@ #.host
##                                 (|>> (:coerce Host)
##                                      (set@ #artifacts (|> (get@ #.host compiler) (:coerce Host) (get@ #artifacts)))
##                                      (:coerce Nothing))
##                                 compiler')
##                        [(|> compiler' (get@ #.host) (:coerce Host) (get@ #artifacts))
##                         output]])

##       (#error.Error error)
##       (#error.Error error))))

## (def: #export (load-definition compiler)
##   (-> Lux (-> Ident Blob (Error Any)))
##   (function (_ (^@ def-ident [def-module def-name]) def-bytecode)
##     (let [normal-name (format (name.normalize def-name) (%n (text/hash def-name)))
##           class-name (format (text.replace-all "/" "." def-module) "." normal-name)]
##       (<| (macro.run compiler)
##           (do macro.Monad<Meta>
##             [_ (..store-class class-name def-bytecode)
##              class (..load-class class-name)]
##             (case (do error.Monad<Error>
##                     [field (Class::getField [..value-field] class)]
##                     (Field::get [#.None] field))
##               (#error.Success (#.Some def-value))
##               (wrap def-value)

##               (#error.Success #.None)
##               (compiler.throw invalid-definition-value (%ident def-ident))

##               (#error.Error error)
##               (compiler.throw cannot-load-definition
##                               (format "Definition: " (%ident def-ident) "\n"
##                                       "Error:\n"
##                                       error))))))))