1 package uk.co.codemist.jlisp.core;
2 
3 
4 // $Id: Reduce.java 3141 2015-06-21 19:23:30Z arthurcnorman $
5 
6 
7 // Reduce
8 //
9 // Standard Lisp system coded in Java. Actually this goes
10 // way beyond the Standard Lisp Report and includes a large fraction
11 // of that which is present in the CSL Lisp system.
12 //
13 // The purpose of this implementation is to support
14 // REDUCE. Early versions of jlisp were amazingly slow but
15 // performance is gradually improving! This version has hooks to load
16 // classes U01 to U60 which can contain parts of Reduce compiled into
17 // Java.
18 
19 //
20 // This file is part of the Jlisp implementation of Standard Lisp
21 // Copyright \u00a9 (C) Codemist Ltd, 1998-2015.
22 //
23 
24 /**************************************************************************
25  * Copyright (C) 1998-2015, Codemist Ltd.                A C Norman       *
26  *                            also contributions from Vijay Chauhan, 2002 *
27  *                                                                        *
28  * Redistribution and use in source and binary forms, with or without     *
29  * modification, are permitted provided that the following conditions are *
30  * met:                                                                   *
31  *                                                                        *
32  *     * Redistributions of source code must retain the relevant          *
33  *       copyright notice, this list of conditions and the following      *
34  *       disclaimer.                                                      *
35  *     * Redistributions in binary form must reproduce the above          *
36  *       copyright notice, this list of conditions and the following      *
37  *       disclaimer in the documentation and/or other materials provided  *
38  *       with the distribution.                                           *
39  *                                                                        *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS    *
41  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT      *
42  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS      *
43  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE         *
44  * COPYRIGHT OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,   *
45  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,   *
46  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS  *
47  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR  *
49  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF     *
50  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
51  * DAMAGE.                                                                *
52  *************************************************************************/
53 
54 import java.io.*;
55 import java.math.*;
56 import java.util.*;
57 import java.util.zip.*;
58 import java.text.*;
59 
60 public class Reduce extends JlispExtras
61 {
62 
63 static Uxx[] translatedCode =
64 {
65     new U01(),  new U02(),  new U03(),  new U04(),  new U05(),
66     new U06(),  new U07(),  new U08(),  new U09(),  new U10(),
67     new U11(),  new U12(),  new U13(),  new U14(),  new U15(),
68     new U16(),  new U17(),  new U18(),  new U19(),  new U20(),
69     new U21(),  new U22(),  new U23(),  new U24(),  new U25(),
70     new U26(),  new U27(),  new U28(),  new U29(),  new U30(),
71     new U31(),  new U32(),  new U33(),  new U34(),  new U35(),
72     new U36(),  new U37(),  new U38(),  new U39(),  new U40(),
73     new U41(),  new U42(),  new U43(),  new U44(),  new U45(),
74     new U46(),  new U47(),  new U48(),  new U49(),  new U50(),
75     new U51(),  new U52(),  new U53(),  new U54(),  new U55(),
76     new U56(),  new U57(),  new U58(),  new U59(),  new U60(),
77 };
78 
countFunctions()79 int countFunctions()
80 {
81     int n = 0;
82     for (Uxx u : translatedCode)
83         n += u.builtins.length;
84     return n;
85 }
86 
inituserfns()87 void inituserfns()
88 {
89     for (Uxx u : translatedCode)
90     {   Jlisp.inituserfns(u.builtins);
91     }
92 }
93 
record1(Object [][]builtins, HashMap builtinFunctions)94 private void record1(Object [][]builtins, HashMap builtinFunctions)
95 {
96     for (int i=0; i<builtins.length; i++)
97     {   ((LispFunction)builtins[i][1]).name = (String)builtins[i][0];
98         builtinFunctions.put(builtins[i][0], builtins[i][1]);
99     }
100 }
101 
recorduserfns(HashMap builtinFunctions)102 void recorduserfns(HashMap builtinFunctions)
103 {
104     for (Uxx u : translatedCode)
105     {   record1(u.builtins, builtinFunctions);
106     }
107 }
108 
main(String []args)109 public static void main(String []args)
110 {
111     Jlisp.extrabuiltins = new Reduce();
112     CWin.main(args);
113 }
114 
115 }
116 
117 // End of Reduce.java
118 
119