1 | // |
---|
2 | // Copyright (C) 2000 Refal+ Development Group |
---|
3 | // |
---|
4 | // Refal+ is free software; you can redistribute it and/or modify |
---|
5 | // it under the terms of the GNU General Public License as published by |
---|
6 | // the Free Software Foundation; either version 2 of the License, or |
---|
7 | // (at your option) any later version. |
---|
8 | // |
---|
9 | // Refal+ is distributed in the hope that it will be useful, |
---|
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | // GNU General Public License for more details. |
---|
13 | // |
---|
14 | // You should have received a copy of the GNU General Public License |
---|
15 | // along with Refal+; if not, write to the Free Software |
---|
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | // |
---|
18 | // $Source$ |
---|
19 | // $Revision: 583 $ |
---|
20 | // $Date: 2003-03-05 10:19:51 +0000 (Wed, 05 Mar 2003) $ |
---|
21 | // Author: Andrey Slepuhin <pooh@msu.ru> |
---|
22 | |
---|
23 | #include "rf_core.hh" |
---|
24 | #include "rf_types.ih" |
---|
25 | #include "pxx_default_allocator.ih" |
---|
26 | |
---|
27 | |
---|
28 | #include <time.h> |
---|
29 | #include <stdlib.h> |
---|
30 | #include <locale.h> |
---|
31 | |
---|
32 | namespace rfrt |
---|
33 | { |
---|
34 | |
---|
35 | using namespace rftype; |
---|
36 | |
---|
37 | class Init |
---|
38 | { |
---|
39 | |
---|
40 | public: |
---|
41 | |
---|
42 | pxx::HeapAllocator allocator ; |
---|
43 | |
---|
44 | Init () : |
---|
45 | allocator (pxx::page_size, default_heap_size, heap_start) |
---|
46 | { |
---|
47 | default_allocator.set(allocator); |
---|
48 | char* s = getenv("LANG"); |
---|
49 | if (s != null) setlocale(LC_ALL, s); |
---|
50 | s = getenv("LC_CTYPE"); |
---|
51 | if (s != null) setlocale(LC_CTYPE, s); |
---|
52 | s = getenv("LC_ALL"); |
---|
53 | if (s != null) setlocale(LC_ALL, s); |
---|
54 | } |
---|
55 | |
---|
56 | ~Init () |
---|
57 | { |
---|
58 | #if DEBUG |
---|
59 | wprintf(L"Concatenation statistics:\n"); |
---|
60 | printf("- no copy: %u\n", empty_copy); |
---|
61 | printf("- left copy: %u\n", lt_copy); |
---|
62 | printf("- right copy: %u\n", rt_copy); |
---|
63 | printf("- both copy: %u\n", both_copy); |
---|
64 | printf("- unifications: %u\n", unifications); |
---|
65 | printf("- identical: %u\n", identical); |
---|
66 | #if PARANOIA |
---|
67 | allocator.memory_dump(); |
---|
68 | #endif // PARANOIA |
---|
69 | #endif // DEBUG |
---|
70 | } |
---|
71 | |
---|
72 | }; |
---|
73 | |
---|
74 | Init init /* __attribute__ ((init_priority (600))) */ ; |
---|
75 | |
---|
76 | pxx::HeapAllocator& allocator = init.allocator ; |
---|
77 | |
---|
78 | TypeRegister rftype::Char::reg(&Char::funcs, type_char) ; |
---|
79 | TypeRegister rftype::ShortInt::reg(&ShortInt::funcs, type_short_int) ; |
---|
80 | |
---|
81 | ObjectRegister rftype::Box::reg(type_box) ; |
---|
82 | ObjectRegister rftype::Vector::reg(type_vector) ; |
---|
83 | |
---|
84 | const Expr empty; |
---|
85 | |
---|
86 | RetVal (*entry) () = null ; |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | using namespace rfrt; |
---|
91 | |
---|
92 | int main () |
---|
93 | { |
---|
94 | double start = clock (); |
---|
95 | Expr res; |
---|
96 | RF_CALL ((*rfrt::entry), (), (res)); |
---|
97 | printf ("Time elapsed: %.2fs\n", (clock () - start) / CLOCKS_PER_SEC); |
---|
98 | return 0; |
---|
99 | } |
---|
100 | |
---|