PageRenderTime 31ms CodeModel.GetById 24ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/semantics/types/delayed_resolver/liberty_delayed_agent_call.e

http://github.com/tybor/Liberty
Specman e | 100 lines | 68 code | 16 blank | 16 comment | 2 complexity | 6cb5811f2981fe63164a2d4e9500c8f3 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_DELAYED_AGENT_CALL
 16
 17inherit
 18   LIBERTY_DELAYED_RESOLVER
 19
 20creation {LIBERTY_AGENT, LIBERTY_DELAYED_AGENT_CALL}
 21   make
 22
 23feature {ANY}
 24   out_in_tagged_out_memory is
 25      do
 26         if can_resolve then
 27            resolved.out_in_tagged_out_memory
 28         else
 29            tagged_out_memory.append(once "agent like (")
 30            call.out_in_tagged_out_memory
 31            tagged_out_memory.extend(')')
 32         end
 33      end
 34
 35   hash_code: INTEGER is
 36      do
 37         Result := full_name_memory.hash_code
 38      end
 39
 40   is_equal (other: like Current): BOOLEAN is
 41      do
 42         Result := other = Current
 43      end
 44
 45feature {LIBERTY_DELAYED_TYPE}
 46   can_resolve: BOOLEAN is
 47      do
 48         Result := call.can_compute_agent_type
 49      end
 50
 51   resolved: LIBERTY_KNOWN_TYPE is
 52      do
 53         Result := call.agent_type
 54      end
 55
 56   full_name: FIXED_STRING is
 57      do
 58         Result := full_name_memory
 59      end
 60
 61   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 62      local
 63         c: like call
 64      do
 65         --|*** TODO: check coherence (shouldn't `call' handle the
 66         --|specialization instead?)
 67
 68         c := call.specialized_in(a_type)
 69         if c = call then
 70            Result := Current
 71         else
 72            create Result.make(c)
 73         end
 74      end
 75
 76feature {}
 77   make (a_call: like call) is
 78      require
 79         a_call /= Void
 80      do
 81         call := a_call
 82
 83         lock_tagged_out
 84         tagged_out_memory.copy(once "agent like (")
 85         a_call.out_in_tagged_out_memory
 86         tagged_out_memory.extend(')')
 87         unlock_tagged_out
 88
 89         full_name_memory := tagged_out_memory.intern
 90      ensure
 91         call = a_call
 92      end
 93
 94   call: LIBERTY_CALL_EXPRESSION
 95   full_name_memory: FIXED_STRING
 96
 97invariant
 98   call /= Void
 99
100end -- class LIBERTY_DELAYED_AGENT_CALL