File: type_separate.e

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (400 lines) | stat: -rw-r--r-- 9,355 bytes parent folder | download | duplicates (2)
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
-- 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
--
deferred class TYPE_SEPARATE
   --
   -- Handling of the "separate FOO" type mark.
   --
   -- The subclasses of TYPE_SEPARATE are the different kinds of processors:
   --  - TYPE_THREAD         processors implemented as Threads
   --  - TYPE_PROXY          processors implemented as Proxies
   --  - TYPE_SERVER         processors implemented as Servers
   --
   -- (see scoop.html)
   --
   -- The compilation either compiles all the types in (with the CCF read at 
   -- runtime, acting as factory parameter), or only the relevant types if 
   -- the CCF is used at compile-time.

inherit E_TYPE

feature

   start_position: POSITION
         -- Of first letter of keyword `separate'.

   written_mark: STRING

   mapped: E_TYPE
         -- Corresponding mapped type (usualy the reference type).

   run_time_mark: STRING

   run_type: E_TYPE
         -- When runnable only.

   is_expanded: BOOLEAN is false

   is_reference: BOOLEAN is true

   is_separate: BOOLEAN is true

   local_from_separate: E_TYPE is
      do
	 Result := mapped
      end

   is_array: BOOLEAN is
      do
         Result := mapped.is_array
      end

   is_none: BOOLEAN is
      do
         Result := mapped.is_none
      end

   is_any: BOOLEAN is
      do
         Result := mapped.is_any
      end

   is_like_current: BOOLEAN is false

   is_like_argument: BOOLEAN is false

   is_like_feature: BOOLEAN is false

   jvm_method_flags: INTEGER is 17

   actual_reference(destination: E_TYPE): E_TYPE is
      do
         Result := mapped
      end

   actual_separate(destination: E_TYPE): E_TYPE is
      do
         Result := destination
      end

   start_lookup_name: CLASS_NAME is
      do
         Result := base_class_name
      end

   is_basic_eiffel_expanded: BOOLEAN is false

   stupid_switch(run_time_set: RUN_TIME_SET): BOOLEAN is
      do
         Result := mapped.stupid_switch(run_time_set)
      end

   is_generic: BOOLEAN is
      do
         Result := mapped.is_generic
      end

   generic_list: ARRAY[E_TYPE] is
      do
         Result := mapped.generic_list
      end

   is_user_expanded: BOOLEAN is false

   is_dummy_expanded: BOOLEAN is false

   id: INTEGER is
      do
         Result := run_class.id
      end

   smallest_ancestor(other: E_TYPE): E_TYPE is
      do
         if run_time_mark = other.run_time_mark then
            Result := run_type
         else
            Result := mapped.smallest_ancestor(other).run_type
         end
      end

   is_a(other: E_TYPE): BOOLEAN is
      do
         if other.is_separate then
            Result := mapped = other or else mapped.is_a(other)
         end
         if not Result then
            error_handler.type_error(Current,other)
         end
      end

   is_run_type: BOOLEAN is
      do
         Result := run_type /= Void
      end

   base_class_name: CLASS_NAME is
      do
         Result := mapped.base_class_name
      end

   to_runnable(rt: E_TYPE): like Current is
      local
         m: like mapped
      do
         if mapped.base_class.is_deferred then
            error(start_position, once "A deferred class cannot be separate.")
         elseif mapped.is_expanded then
            error(start_position, once "An expanded class cannot be separate.")
         end

         mapped.base_class.set_maybe_separate

         if run_type = Current then
            -- Context change nothing :
            Result := Current
         elseif run_type = mapped then
            -- Mapped is already separate :
            Result := Current
         else
            m := mapped.to_runnable(rt)
            if m = Void then
               error_handler.add_position(start_position)
               fatal_error("Bad outside separate type.")
            end
            if run_type /= Void then
               Result := copy_from_other(Current,m.run_type)
            elseif m.is_separate then
               run_type := m
               run_time_mark := m.run_time_mark
               Result := Current
            elseif mapped = m.run_type then
               run_time_mark := compute_mark(m.run_time_mark)
               run_type := Current
               Result := Current
            else
               run_time_mark := compute_mark(m.run_time_mark)
               run_type := copy_from_other(Current,m.run_type)
               Result := Current
            end
            mapped.run_class.set_at_run_time
            Result.run_type.run_class.set_at_run_time
         end
      end

feature -- JVM: not implemented!

   jvm_descriptor_in(str: STRING) is
      do
         not_yet_implemented
      end

   jvm_target_descriptor_in(str: STRING) is
      do
         not_yet_implemented
      end

   jvm_return_code is
      do
         not_yet_implemented
      end

   jvm_push_local(offset: INTEGER) is
      do
         not_yet_implemented
      end

   jvm_check_class_invariant is
      do
         not_yet_implemented
      end

   jvm_push_default: INTEGER is
      do
         not_yet_implemented
      end

   jvm_write_local_creation(offset: INTEGER) is
      do
         not_yet_implemented
      end

   jvm_write_local(offset: INTEGER) is
      do
         not_yet_implemented
      end

   jvm_write_local_expanded(offset: INTEGER) is
      do
         not_yet_implemented
      end

   jvm_xnewarray is
      do
         not_yet_implemented
      end

   jvm_xastore is
      do
         not_yet_implemented
      end

   jvm_xaload is
      do
         not_yet_implemented
      end

   jvm_if_x_eq: INTEGER is
      do
         not_yet_implemented
      end

   jvm_if_x_ne: INTEGER is
      do
         not_yet_implemented
      end

   jvm_to_reference is
      do
         not_yet_implemented
      end

   jvm_expanded_from_reference(other: E_TYPE): INTEGER is
      do
         not_yet_implemented
      end

   jvm_convert_to(destination: E_TYPE): INTEGER is
      do
         not_yet_implemented
      end

   jvm_standard_is_equal is
      do
         not_yet_implemented
      end

feature

   is_boolean: BOOLEAN is
      do
         Result := mapped.is_boolean
      end

   is_character: BOOLEAN is
      do
         Result := mapped.is_character
      end

   is_integer: BOOLEAN is
      do
         Result := mapped.is_integer
      end

   is_real: BOOLEAN is
      do
         Result := mapped.is_real
      end

   is_double: BOOLEAN is
      do
         Result := mapped.is_double
      end

   is_bit: BOOLEAN is
      do
         Result := mapped.is_bit
      end

   is_pointer: BOOLEAN is
      do
         Result := mapped.is_pointer
      end

   is_string: BOOLEAN is
      do
         Result := mapped.is_string
      end

feature {TYPE_SEPARATE_VISITOR}

   accept(visitor: TYPE_SEPARATE_VISITOR) is
      deferred
      end

feature {E_TYPE}

   frozen short_hook is
      do
         short_print.hook_or(fz_separate,"separate ")
         mapped.short_hook
      end

feature {NONE}

   compute_mark(str: STRING): STRING is
      do
         tmp_string.copy(fz_separate)
         tmp_string.extend(' ')
         tmp_string.append(str)
         Result := string_aliaser.item(tmp_string)
      end

   make(sp: like start_position; m: like mapped) is
      require
         not sp.is_unknown
         m /= Void
      do
         start_position := sp
         mapped := m
         written_mark := compute_mark(mapped.written_mark)
      ensure
         start_position = sp
         mapped = m
      end

   from_other(other: like Current; m: like mapped) is
      require
         other /= Void
         m.run_type = m
      do
         start_position := other.start_position
         written_mark := other.written_mark
         mapped := m
         if mapped.is_separate then
            run_time_mark := mapped.run_time_mark
            run_type := mapped
         else
            run_time_mark := compute_mark(mapped.run_time_mark)
            run_type := Current
         end
      ensure
         run_type /= Void
      end

   copy_from_other(other: like Current; m: like mapped): like Current is
         -- Factory method, used to duplicate the current object.
      deferred
      end

end -- TYPE_SEPARATE