source: to-imperative/trunk/runtime/rf_core.cc @ 583

Last change on this file since 583 was 583, checked in by pooh, 18 years ago
  • Vector implementation added.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
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
32namespace rfrt
33{
34
35using namespace rftype;
36
37class Init
38{
39
40public:
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
74Init init /* __attribute__ ((init_priority (600))) */ ;
75
76pxx::HeapAllocator& allocator = init.allocator ;
77
78TypeRegister rftype::Char::reg(&Char::funcs, type_char) ;
79TypeRegister rftype::ShortInt::reg(&ShortInt::funcs, type_short_int) ;
80
81ObjectRegister rftype::Box::reg(type_box) ;
82ObjectRegister rftype::Vector::reg(type_vector) ;
83
84const Expr empty;
85
86RetVal (*entry) () = null ;
87
88}
89
90using namespace rfrt;
91
92int 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
Note: See TracBrowser for help on using the repository browser.