/src/tools/semantics/types/utils/liberty_class_descriptor.e
Specman e | 110 lines | 84 code | 12 blank | 14 comment | 3 complexity | a70b7b1fcb2cd9b26246978ba45c022b MD5 | raw file
1-- This file is part of Liberty Eiffel. 2-- 3-- Liberty Eiffel is free software: you can redistribute it and/or modify 4-- it under the terms of the GNU General Public License as published by 5-- the Free Software Foundation, version 3 of the License. 6-- 7-- Liberty Eiffel is distributed in the hope that it will be useful, 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10-- GNU General Public License for more details. 11-- 12-- You should have received a copy of the GNU General Public License 13-- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>. 14-- 15class LIBERTY_CLASS_DESCRIPTOR 16 17insert 18 HASHABLE 19 20create {LIBERTY_UNIVERSE, LIBERTY_TYPE_RESOLVER_IN_TYPE} 21 make 22 23create {LIBERTY_VOID_TYPE} 24 make_void 25 26feature {ANY} 27 cluster: LIBERTY_CLUSTER 28 name: FIXED_STRING 29 position: LIBERTY_POSITION 30 file: FIXED_STRING 31 hash_code: INTEGER 32 33 is_equal (other: like Current): BOOLEAN is 34 do 35 Result := name.is_equal(other.name) and then cluster.is_equal(other.cluster) 36 end 37 38 make (a_cluster: like cluster; a_name: like name; a_position: like position) is 39 require 40 a_cluster /= Void 41 a_name /= Void 42 do 43 cluster := a_cluster 44 name := a_name 45 position := a_position 46 compute_hash_code 47 compute_file 48 ensure 49 cluster = a_cluster 50 name = a_name 51 position = a_position 52 end 53 54 make_void (a_position: like position) is 55 do 56 create cluster.make_void 57 name := "<Void>".intern 58 position := a_position 59 file := name 60 ensure 61 position = a_position 62 end 63 64 compute_file is 65 local 66 n, f: STRING 67 do 68 n := once "" 69 n.clear_count 70 n.append(name) 71 n.to_lower 72 n.append(once ".e") 73 f := once "" 74 f.make_from_string(cluster.location_of(name)) 75 dir.compute_file_path_with(f, n) 76 f.copy(dir.last_entry) 77 if f.is_empty or else not file_tools.is_file(f) then 78 std_error.put_string(" *** Unknown class: ") 79 std_error.put_string(name) 80 std_error.put_string(" in cluster ") 81 std_error.put_line(cluster.name) 82 breakpoint 83 die_with_code(1) 84 end 85 file := f.intern 86 ensure 87 file /= Void 88 end 89 90feature {} 91 compute_hash_code is 92 local 93 h: like hash_code 94 do 95 h := name.hash_code #*31 #+ cluster.hash_code 96 if h < 0 then 97 h := ~h 98 end 99 hash_code := h 100 end 101 102 file_tools: FILE_TOOLS 103 dir: BASIC_DIRECTORY 104 105invariant 106 cluster /= Void 107 name /= Void 108 file /= Void 109 110end