comparison interps/c-intercal/coopt.sh @ 996:859f9b4339e6

<Gregor> tar xf egobot.tar.xz
author HackBot
date Sun, 09 Dec 2012 19:30:08 +0000
parents
children
comparison
equal deleted inserted replaced
995:6883f5911eb7 996:859f9b4339e6
1 #! /bin/sh
2 ###########################################################################
3 #
4 # Name
5 # coopt.sh -- an inefficient optimizer that can produce very efficient
6 # code
7 #
8 # DESCRIPTION
9 # This optimizer is only run on noninteractive code that takes no
10 # output. (It's designed to run on executables produced by INTERCAL
11 # code, but will run on other executables that support the +mystery
12 # option). It optimizes the file by replacing it by one that simply
13 # produces the required output! Therefore, it creates fast but
14 # inefficient code. If the file to be optimized hits an error or
15 # is terminated by +mystery, then no changes are made.
16 #
17 # LICENSE TERMS
18 # Copyright (C) 2006 Alex Smith
19 #
20 # This program is free software; you can redistribute it and/or modify
21 # it under the terms of the GNU General Public License as published by
22 # the Free Software Foundation; either version 2 of the License, or
23 # (at your option) any later version.
24 #
25 # This program is distributed in the hope that it will be useful,
26 # but WITHOUT ANY WARRANTY; without even the implied warranty of
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 # GNU General Public License for more details.
29 #
30 # You should have received a copy of the GNU General Public License
31 # along with this program; if not, write to the Free Software
32 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #
34 ###########################################################################
35
36 rm icktemp.out >/dev/null 2>/dev/null
37 if $1 +mystery >icktemp.out 2>/dev/null ; then : ; else
38 rm icktemp.out ; exit 0 ; fi
39 if grep 'ickoutTERM???!' icktemp.out ; then rm icktemp.out ; exit 0 ; fi
40 echo 'ickoutTERM???!' >> icktemp.out
41 rm $1
42 echo "#! /bin/sh
43 cat <<'ickoutTERM???!'" | cat - icktemp.out > $1
44 chmod +x $1
45 rm icktemp.out
46 exit 0