1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
|
-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries
--
-- SmartEiffel is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License, as published by the
-- Free Software Foundation; either version 2, or (at your option) any later
-- version.
-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-- more details. You should have received a copy of the GNU General Public
-- License along with SmartEiffel; see the file COPYING. If not, write to
-- the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-- MA 02111-1307, USA.
--
-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.
-- - University of Nancy 1 - FRANCE
-- Copyright(C) 2003: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne
-- - University of Nancy 2 - FRANCE
--
-- Dominique COLNET, Suzanne COLLIN, Olivier ZENDRA,
-- Philippe RIBET, Cyril ADRIAN
--
-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
--
class CREATION_CLAUSE
--
-- The store the contents of one creation clause.
-- example 1
-- creation {ANY} make
-- example 2
-- creation make, foo
-- example 3
-- creation {NONE,ANY} make, foo
-- example 4
-- creation
--
-- Note : The original text of the source file can be stored
-- for pretty pretty_printing to be fine.
--
inherit
GLOBALS
VISITABLE
creation make
feature
start_position: POSITION
-- Of the corresponding keyword.
clients: CLIENT_LIST
comment: COMMENT
feature {NONE}
make(sp: like start_position; c: like clients
cm: like comment; pl: like procedure_list) is
require
not sp.is_unknown
c /= Void
do
start_position := sp
clients := c
comment := cm
procedure_list := pl
ensure
clients = c
comment = cm
procedure_list = pl
end
feature
pretty_print is
do
pretty_printer.set_indent_level(0)
if not pretty_printer.zen_mode then
pretty_printer.skip_one_line
else
pretty_printer.indent
end
pretty_printer.keyword(once "creation")
pretty_printer.set_indent_level(1)
if clients /= Void then
clients.pretty_print
end
if comment /= void then
comment.pretty_print
end
pretty_printer.set_indent_level(1)
if not pretty_printer.zen_mode then
pretty_printer.indent
end
if procedure_list /= Void then
procedure_list.pretty_print
end
end
short(heading_done: BOOLEAN; client: CLASS_NAME): BOOLEAN is
-- True when at least one creation list is printed.
do
if clients.gives_permission_to(client) then
if not heading_done then
short_print.hook_or("hook100","creation%N")
end
if procedure_list /= Void then
procedure_list.short_for_creation
end
short_print.hook_or("hook101","")
Result := true
else
error_handler.cancel
end
end
has(fn: FEATURE_NAME): BOOLEAN is
require
fn /= Void
do
if procedure_list /= Void then
Result := procedure_list.has(fn)
end
end
feature {CREATION_CLAUSE_VISITOR}
procedure_list: FEATURE_NAME_LIST
accept(visitor: CREATION_CLAUSE_VISITOR) is
do
visitor.visit_creation_clause(Current)
end
feature {CREATION_CLAUSE_LIST}
default_root: STRING is
-- Return the default creation procedure name to be used as the root
-- procedure (the execution entry point of the system).
do
if procedure_list /= Void then
if procedure_list.has_make then
Result := as_make
else
Result := procedure_list.first.to_string
end
end
end
root_creation_search(a_name: STRING): FEATURE_NAME is
do
if procedure_list /= Void then
Result := procedure_list.root_creation_search(a_name)
end
end
check_expanded_with(t: E_TYPE) is
require
t.is_expanded
local
rf: RUN_FEATURE; rf3: RUN_FEATURE_3; rc: RUN_CLASS
do
if procedure_list = Void then
error_handler.add_position(start_position)
error_handler.append(
"Cannot create a class with an empty creation list.")
error_handler.print_as_fatal_error
end
if procedure_list.count > 1 then
error_handler.add_type(t,fz_cbe)
error_handler.add_position(start_position)
fatal_error_vtec_2
end
rc := t.run_class
rf := rc.get_feature(procedure_list.first)
if rf = Void then
error_handler.add_position(start_position)
error_handler.append("Creation procedure for ")
error_handler.add_type(t," not found.")
error_handler.print_as_fatal_error
end
rf3 ?= rf
if rf3 = Void then
error_handler.add_position(start_position)
error_handler.add_position(rf.start_position)
error_handler.append("Feature found is not a procedure.")
error_handler.print_as_fatal_error
end
if rf3.arguments /= Void then
error_handler.add_type(t,fz_cbe)
error_handler.add_position(start_position)
error_handler.add_position(rf3.start_position)
error_handler.append("Procedure found has arguments. ")
fatal_error_vtec_2
end
end
a_default_create(type: E_TYPE): RUN_FEATURE_3 is
require
type /= Void
local
i: INTEGER; fn, rfn: FEATURE_NAME
rc: RUN_CLASS; rf: RUN_FEATURE
do
if procedure_list /= Void then
rc := type.run_class
from
i := procedure_list.count
until
rf /= Void or else i <= 0
loop
fn := procedure_list.item(i)
if fn.to_string = as_default_create then
rf := rc.get_feature(fn)
rfn := fn
end
i := i - 1
end
if rf = Void and then type.is_expanded then
from
i := procedure_list.count
until
rf /= Void or else i <= 0
loop
fn := procedure_list.item(i)
rf := rc.get_feature(fn)
rfn := fn
if rf /= Void then
if rf.arguments /= Void then
rf := Void
end
end
i := i - 1
end
end
if rf /= Void then
Result ?= rf
if Result = Void then
error_handler.add_position(rf.start_position)
error_handler.add_position(rfn.start_position)
error_handler.append(fz_ffinap)
error_handler.print_as_fatal_error
end
end
end
end
invariant
clients /= Void
end -- CREATION_CLAUSE
|