[BACK]Return to kobj2.kk CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097 / debug

File: [local] / OpenXM / src / k097 / debug / kobj2.kk (download)

Revision 1.1.1.1 (vendor branch), Fri Oct 8 02:12:15 1999 UTC (24 years, 7 months ago) by maekawa
Branch: OpenXM, MAIN
CVS Tags: maekawa-ipv6, R_1_3_1-2, RELEASE_20000124, RELEASE_1_3_1_13b, RELEASE_1_2_3_12, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2, KNOPPIX_2006, HEAD, DEB_REL_1_2_3-9, ALPHA
Changes since 1.1: +0 -0 lines

o import OpenXM sources


/* kobj2.kk,  1997, 3/30 */
/* 省略記法を用いない, ソース */
/* /PrimitiveContextp StandardContextp def
   Object = [PrimitiveContextp] 
   def new() { Return(Object); }
*/

/* local int i, ans, int j;  などという形でデータ型を指定する. */

class Complex extends Object {
  /* /Complex [(Complex) Object 0 get newcontext] def
     Complex 0 get setcontext
  */
  local re,im;
  def new(a,b) {
    this = super.new();
    /* /super Object def
       super [ ] {new} sendmsg2  /this set
       Complex this {rest} primmsg {append} primmsg
       [null null] {append} primmsg  /this set
    */       
    re = a; /* this 1 a {put} primmsg  */
    im = b; 
    return(this);
  }
  def void print() {  /* sm1 の print との関係を考えよ. */
    Print("[");
    /* ["["] {Print} sendmsg */
    Print(re); Print("]+i[");
    Print(im); Print("]");
  }
  def add(b) {
    local c;
    /* arg2 /b set  arg1 /this set */
    c = Complex.new(this.re,this.im);
    /* Complex [ this 1 {get} sendmsg this 2 {get} sendmsg ] {new} sendmsg2
       /c set */
    c.re = c.re+b.re;
    /* c 1 << c 1 get >> << b 1 get >> {add} sendmsg2 {Put} sendmsg2 */
    c.im = c.im+b.im;
    return(c);
  }
};

a = Complex.new(1,2);
/* /a Complex [1 2] {new} sendmsg2 def */
a = a+b;
/* /a a b {add} sendmsg2 def */
a.print(); Println();
/* a [ ] {print} sendmsg2  [ ] {Println} sendmsg */