remove empty dir
[ghc-hetmet.git] / compiler / ilxGen / tests / test2.hs
1 -- To start:
2 -- source /bin/devghc
3
4 -- To compile GHC
5 -- make ilxGen/IlxGen.o hsc
6
7 -- To compile ILXASM
8 -- (cd /devel/fcom/src; make bin/ilxasm.exe) 
9
10 -- To compile to ILX
11 -- (cd ilxGen/tests; ../../../driver/ghc-inplace --ilx test.hs) 
12
13
14
15 -- To generate a complete ILX file, including preludes for GHC and ILX:
16 -- (cd ilxGen/tests/; cat prelude.ilx test.ilx  /devel/fcom/src/ilxasm/stdlib-func.ilx > test.full.ilx)
17
18 -- Run ILXASM to get a IL
19 -- ( cd ilxGen/tests/; /devel/fcom/src/bin/ilxasm.exe --no-ilasm --no-stdlib test.full.ilx > test.il)
20
21 -- To compile IL to .EXE or .DLL:
22 -- With build of VS (e.g. Don & Andrew)
23 --   ( cd ilxGen/tests/; cmd /C "c:\\bin\\devvs.bat && ilasm test.il") 
24 -- With Lightning SDK, where env. variables are on path (e.g. Reuben):
25 --   ( cd ilxGen/tests/; ilasm test.il) 
26
27 -- To validate .EXE:
28 -- (cd /devel/fcom/src; make  bin/ilvalid.exe mscorlib.vlb)
29 -- (export ILVALID_HOME=/devel/fcom/src; cd ilxGen/tests/; /devel/fcom/src/bin/ilvalid.exe test.il) 
30
31 -- To run unverifiable code:
32 -- With build of VS (e.g. Don & Andrew)
33 --    (cd ilxGen/tests/;  cmd /C "c:\\bin\\devvs.bat && .\test.exe")
34 -- With Lightning SDK, where env. variables are on path (e.g. Reuben):
35 --    (cd ilxGen/tests/; ./test.exe)
36
37 -- To compile ILX to verifiable code and verify
38 -- (cd /devel/fcom/src; make bin/ilxasm.exe bin/ilverify.exe)  && (cd ilxGen/tests/; export ILVALID_HOME=/devel/fcom/src; cat prelude.ilx  test.ilx /devel/fcom/src/assem/stdlib-func.ilx > test.full.ilx && cd ilxGen/tests/; /devel/fcom/src/bin/ilxasm.exe --no-ilasm test.full.ilx > test.safe.il && /devel/fcom/src/bin/ilverify.exe test.safe.il) 
39
40 -- (cd ilxGen/tests/;  cmd /C "c:\\bin\\devvs.bat && .\test.safe.exe")
41
42 --append:: [Char] -> [Char] -> [Char]
43 --append [] l2 = l2
44 --append (h:t) l2 = h:append t l2
45
46 data N = Z | S N
47
48 chooseN n  = 
49   case n of 
50        Z -> "even\n"
51        S Z -> "odd\n"
52        S (S m) -> chooseN m 
53
54 add n m = 
55    case n of
56        Z -> m  
57        S nn -> S (add nn m)
58
59 mul n m = 
60    case n of
61        Z -> Z
62        S nn -> add m (mul nn m)
63
64 pow n m = 
65    case m of
66        Z -> S Z
67        S mm -> mul n (pow n mm)
68
69 sq n = mul n n
70
71 n1 = S Z
72 n2 = add n1 n1
73 n4 = add n2 n2
74 n6 = add n2 n4
75 n8 = add n2 n6
76 n10 = add n2 n8
77 n16 = add n6 n10
78 n17 = add n1 n16
79 n18 = add n8 n10
80 n19 = add n1 n18
81 n20 = add n4 n16
82
83 bign = pow n2 n10
84 bign1 = add bign n1
85
86 main = putStr (chooseN bign1)
87
88