1 : |
dbm |
2527 |
mkVBs
|
2 : |
|
|
|
3 : |
|
|
case: val x = x (simple variable to variable binding)
|
4 : |
|
|
Question: to do explice type abstraction wrapping (mkPE) or not.
|
5 : |
|
|
- avoid type eta-expansion?
|
6 : |
|
|
- inst param tyvars are always going to equal VB boundtvs?
|
7 : |
|
|
- avoid using mkVar if exp is primop var, since mkVar looses
|
8 : |
|
|
primop
|
9 : |
|
|
|
10 : |
|
|
|
11 : |
|
|
mkExp
|
12 : |
|
|
calls mkVE for variable expression
|
13 : |
|
|
|
14 : |
|
|
mkPE
|
15 : |
|
|
Wraps an expression with a type abstraction corresponding to
|
16 : |
|
|
the boundtvs of a VB
|
17 : |
|
|
|
18 : |
|
|
|
19 : |
|
|
mkVar
|
20 : |
|
|
Translates a VALvar into default dynamic access path via mkAccInfo.
|
21 : |
|
|
prim property is discarded.
|
22 : |
|
|
|
23 : |
|
|
|
24 : |
|
|
mkVE(e = VALvar, ts = inst types, d=depth)
|
25 : |
|
|
Translate variable that might be bound to a primop.
|
26 : |
|
|
|
27 : |
|
|
Prim case:
|
28 : |
|
|
(1) determines the type instantiation parameters relative
|
29 : |
|
|
to the primop intrinsice type (intrinsicParams).
|
30 : |
|
|
(2) case on primop: performs special immediate translations
|
31 : |
|
|
of certain primops, supplying instantiation types: [POLYEQ,
|
32 : |
|
|
POLYNEQ, INLMKARRAY, RAW_CCALL).
|
33 : |
|
|
For all other primops, calls transPrim with primop, translated
|
34 : |
|
|
intrinsic type, and translated intrinsic params.
|
35 : |
|
|
|
36 : |
|
|
Nonprim case:
|
37 : |
|
|
calls mkVar if there are no instantiation
|
38 : |
|
|
parameters, otherwise calls mkVar and wraps result with appropriate
|
39 : |
|
|
TAPP (type application) to translated instantiation types.
|
40 : |
|
|
|
41 : |
|
|
|
42 : |
|
|
Control Flow
|
43 : |
|
|
|
44 : |
|
|
For simple variable bindings like
|
45 : |
|
|
|
46 : |
|
|
val x = y
|
47 : |
|
|
|
48 : |
|
|
VB{pat=VARpat(V.VALvar{access=DA.LVAR v, ...}), (* x *)
|
49 : |
|
|
exp as VARexp _, boundtvs=btvs, ...}, (* y *)
|
50 : |
|
|
|
51 : |
|
|
The flow is:
|
52 : |
|
|
|
53 : |
|
|
mkVBs --> mkPE --> mkExp -> mkVE
|
54 : |
|
|
|
55 : |
|
|
mkPE wraps the rhs variable expression in an n-ary TFN abstraction,
|
56 : |
|
|
where n = length(btvs), the polymorphically bound tyvars.
|
57 : |
|
|
|
58 : |
|
|
mkVE takes care of calculating the type instantiation parameters for
|
59 : |
|
|
primops relative to their intrinsic types.
|
60 : |
gkuan |
3293 |
|
61 : |
|
|
|
62 : |
|
|
========================================
|
63 : |
|
|
|
64 : |
|
|
RepTycProps
|
65 : |
|
|
|
66 : |
|
|
In order to translate functors into FLINT type abstractions, the
|
67 : |
|
|
compiler needs to identify the primary type components that
|
68 : |
|
|
need to be translated into PLambda types.
|
69 : |
|
|
|
70 : |
|
|
Tycpaths encode the higher-order kind information for the
|
71 : |
|
|
primary type components of functors. This information is
|
72 : |
|
|
transmitted throughout Translate by a flextycmap which is
|
73 : |
|
|
a map from stamps to tycpaths.
|
74 : |
|
|
|
75 : |
|
|
Translate currently uses this functionality in three places.
|
76 : |
|
|
1. TransTypes uses RepTycProps.getTk to compute primary type
|
77 : |
|
|
component information which in turn is used to obtain
|
78 : |
|
|
PLambda kinds in TransTypes.fctRlznLty.
|
79 : |
|
|
2. In Translate.mkStrexp we compute tycpaths for the arguments
|
80 : |
|
|
in an APPstr. These tycpaths can be translated into PLambda types tycs
|
81 : |
|
|
for the PLambda/FLINT-level type application APP(TAPP(e1, tycs), e2).
|
82 : |
|
|
3. In Translate.mkFctexp we compute tycpaths for the primary
|
83 : |
|
|
formal parameters in the FCTfct case in order to obtain the kinds knds
|
84 : |
|
|
for use in the PLambda/FLINT-level type abstraction:
|
85 : |
|
|
TFN(knds, FN(v, ...))
|