home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / creation_call_3.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  112 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class CREATION_CALL_3
  17.    --
  18.    -- For creation call like :
  19.    --                           !!foo.bar(...)
  20.    --
  21.  
  22. inherit CREATION_CALL_3_4;
  23.  
  24. creation make
  25.  
  26. feature
  27.  
  28.    type: TYPE is do end;
  29.  
  30.    make(sp: like start_position; w: like writable; c: like call) is
  31.       require
  32.          sp /= Void;
  33.          w /= Void;
  34.          c /= Void;
  35.       do
  36.          start_position := sp;
  37.          writable := w;
  38.          call := c;
  39.       ensure
  40.          writable = w;
  41.          call = c;
  42.       end;
  43.  
  44.    to_runnable(ct: TYPE): like Current is
  45.       local
  46.          t: TYPE;
  47.       do
  48.          if current_type = Void then
  49.             check_writable(ct);
  50.             t := writable.result_type;
  51.             check_created_type(t);
  52.             check_creation_clause(t);
  53.             Result := Current;
  54.          else
  55.             !!Result.make(start_position,writable,call);
  56.             Result := Result.to_runnable(ct);
  57.          end;
  58.       end;
  59.  
  60.    compile_to_c is
  61.       local
  62.          t: TYPE;
  63.       do
  64.          t := writable.result_type.run_type;
  65.          if t.is_reference then
  66.             c2c_opening(t);
  67.             cpp.push_new(run_feature,run_args);
  68.             run_feature.mapping_c;
  69.             cpp.pop;
  70.             c2c_closing(t);
  71.          else
  72.             c2c_clear_expanded(t.id);
  73.             c2c_expanded_initializer(t);
  74.          end;
  75.       end;
  76.  
  77.    compile_to_jvm is
  78.       local
  79.          w: EXPRESSION;
  80.          t: TYPE;
  81.       do
  82.          w := writable;
  83.          t := w.result_type.run_type;
  84.          compile_to_jvm0(t);
  85.          jvm.inside_new(run_feature,call);
  86.          t.jvm_check_class_invariant;
  87.          w.jvm_assign;
  88.       end;
  89.  
  90.    use_current: BOOLEAN is
  91.       do
  92.          if run_args /= Void then
  93.             Result := run_args.use_current;
  94.          end;
  95.          Result := Result or else writable.use_current;
  96.       end;
  97.  
  98.    pretty_print is
  99.       do
  100.          fmt.put_string("!!");
  101.          call.pretty_print;
  102.       end;
  103.  
  104. invariant
  105.  
  106.    type = Void;
  107.  
  108.    call /= Void;
  109.  
  110. end -- CREATION_CALL_3
  111.  
  112.