Rename functions working on constraints
[openscop.git] / source / extension.sh
blobe272a9fd7f5a4929ef3a522810b8a5e2f4892d58
2 # /*+------------------------------------------------------------------**
3 # ** OpenScop Library **
4 # **------------------------------------------------------------------**
5 # ** extension.sh **
6 # **------------------------------------------------------------------**
7 # ** First version: 28/05/2011 **
8 # **------------------------------------------------------------------**
11 # ***************************************************************************
12 # * OpenScop: Structures and formats for polyhedral tools to talk together *
13 # ***************************************************************************
14 # * ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
15 # * / / / // // // // / / / // // / / // / /|,_, *
16 # * / / / // // // // / / / // // / / // / / / /\ *
17 # * |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
18 # * | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
19 # * | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
20 # * | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
21 # * | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
22 # * | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
23 # * | I | | | | e | | | | | | | | | | | | | \ \ \ *
24 # * | T | | | | | | | | | | | | | | | | | \ \ \ *
25 # * | E | | | | | | | | | | | | | | | | | \ \ \ *
26 # * | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
27 # * | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
28 # * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
29 # * *
30 # * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
31 # * *
32 # * (3-clause BSD license) *
33 # * Redistribution and use in source and binary forms, with or without *
34 # * modification, are permitted provided that the following conditions *
35 # * are met: *
36 # * *
37 # * 1. Redistributions of source code must retain the above copyright *
38 # * notice, this list of conditions and the following disclaimer. *
39 # * 2. Redistributions in binary form must reproduce the above copyright *
40 # * notice, this list of conditions and the following disclaimer in the *
41 # * documentation and/or other materials provided with the distribution. *
42 # * 3. The name of the author may not be used to endorse or promote *
43 # * products derived from this software without specific prior written *
44 # * permission. *
45 # * *
46 # * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
47 # * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
48 # * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
49 # * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, *
50 # * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
51 # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
52 # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
53 # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
54 # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING *
55 # * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
56 # * POSSIBILITY OF SUCH DAMAGE. *
57 # * *
58 # * OpenScop Library, a library to manipulate OpenScop formats and data *
59 # * structures. Written by: *
60 # * Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
61 # * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
62 # * *
63 # ***************************************************************************/
65 EXTENSIONS_DIR='./source/extensions'
66 EXTENSIONS_IN='./source/extension.c.in'
67 EXTENSIONS_TMP='./extension.tmp'
68 EXTENSIONS_OUT='./source/extension.c'
70 # ***************************************************************************
72 TEMPLATE_STRING[0]=
73 TEMPLATE_SUBSTITUTION[0]='@IDUMP1@'
74 TEMPLATE[0]='\
75 case OPENSCOP_EXTENSION_TEMPLATE: {\
76 fprintf(file, "|\\ttype = OPENSCOP_EXTENSION_TEMPLATE\\n");\
77 break;\
80 # ***************************************************************************
82 TEMPLATE_STRING[1]=
83 TEMPLATE_SUBSTITUTION[1]='@IDUMP2@'
84 TEMPLATE[1]='\
85 case OPENSCOP_EXTENSION_TEMPLATE: {\
86 openscop_template_idump(\
87 file,\
88 (openscop_template_p)extension->extension,\
89 level + 1);\
90 break;\
93 # ***************************************************************************
95 TEMPLATE_STRING[2]=
96 TEMPLATE_SUBSTITUTION[2]='@SPRINT@'
97 TEMPLATE[2]='\
98 case OPENSCOP_EXTENSION_TEMPLATE: {\
99 string = openscop_template_sprint(\
100 (openscop_template_p)extension->extension);\
101 break;\
104 # ***************************************************************************
106 TEMPLATE_STRING[3]=
107 TEMPLATE_SUBSTITUTION[3]='@SREAD@'
108 TEMPLATE[3]='\
109 x = (void *)openscop_template_sread(extension_string);\
110 openscop_extension_add(\&extension, OPENSCOP_EXTENSION_TEMPLATE, x);'
112 # ***************************************************************************
114 TEMPLATE_STRING[4]=
115 TEMPLATE_SUBSTITUTION[4]='@FREE@'
116 TEMPLATE[4]='\
117 case OPENSCOP_EXTENSION_TEMPLATE: {\
118 openscop_template_free(extension->extension);\
119 break;\
122 # ***************************************************************************
124 TEMPLATE_STRING[5]=
125 TEMPLATE_SUBSTITUTION[5]='@COPY@'
126 TEMPLATE[5]='\
127 case OPENSCOP_EXTENSION_TEMPLATE: {\
128 x = (void *)openscop_template_copy(extension->extension);\
129 break;\
132 # ***************************************************************************
134 TEMPLATE_STRING[6]=
135 TEMPLATE_SUBSTITUTION[6]='@EQUAL@'
136 TEMPLATE[6]='\
137 case OPENSCOP_EXTENSION_TEMPLATE: {\
138 equal = openscop_template_equal(x1->extension, x2->extension);\
139 break;\
142 # ***************************************************************************
144 # For each file in the extension directory.
145 for i in ${EXTENSIONS_DIR}/*.c;
147 # Get the extension name, lower case and upper case.
148 EXTENSION_LO=`basename ${i%.c}`
149 EXTENSION_UP=`echo ${EXTENSION_LO} | tr '[a-z]' '[A-Z]'`
151 # Replace the extension name in the templates.
152 for (( i = 0 ; i < ${#TEMPLATE[@]} ; i++ ))
154 TEMP1=`echo "${TEMPLATE[$i]}" | sed "s/TEMPLATE/${EXTENSION_UP}/g"`
155 TEMP2=`echo "${TEMP1}" | sed "s/template/${EXTENSION_LO}/g"`
156 TEMPLATE_STRING[$i]="${TEMPLATE_STRING[$i]}""${TEMP2}"
157 done
158 done
160 # Substitute the generated code parts in the source.
161 cp ${EXTENSIONS_IN} ${EXTENSIONS_TMP}
162 for (( i = 0 ; i < ${#TEMPLATE[@]} ; i++ ))
164 sed "s/${TEMPLATE_SUBSTITUTION[$i]}/${TEMPLATE_STRING[$i]}/g" \
165 <${EXTENSIONS_TMP} >${EXTENSIONS_OUT}
166 mv ${EXTENSIONS_OUT} ${EXTENSIONS_TMP}
167 done
168 mv ${EXTENSIONS_TMP} ${EXTENSIONS_OUT}