blob: 4b435517818302069cc43ecb9bed29bb5db62016 (
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
|
(;module:
lux
(lux [io]
(control monad
pipe)
(data ["R" result])
["r" math/random "R/" Monad<Random>]
[type "Type/" Eq<Type>]
[macro #+ Monad<Lux>]
test)
(luxc ["&;" env]
["&;" module]
(lang ["~" analysis])
[analyser]
(analyser ["@" reference]
["@;" common]))
(.. common))
(test: "References"
[[ref-type _] gen-simple-primitive
module-name (r;text +5)
scope-name (r;text +5)
var-name (r;text +5)]
($_ seq
(assert "Can analyse relative reference."
(|> (&env;with-scope scope-name
(&env;with-local [var-name ref-type]
(@common;with-unknown-type
(@;analyse-reference ["" var-name]))))
(macro;run init-compiler)
(case> (#R;Success [_type (#~;Relative idx)])
(Type/= ref-type _type)
_
false)))
(assert "Can analyse absolute reference."
(|> (do Monad<Lux>
[_ (&module;create +0 module-name)
_ (&module;define [module-name var-name]
[ref-type (list) (:! Void [])])]
(@common;with-unknown-type
(@;analyse-reference [module-name var-name])))
(macro;run init-compiler)
(case> (#R;Success [_type (#~;Absolute idx)])
(Type/= ref-type _type)
_
false)))
))
|