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

Annotation of OpenXM/src/k097/debug/kobj2.kk, Revision 1.1.1.1

1.1       maekawa     1:
                      2:
                      3: /* kobj2.kk,  1997, 3/30 */
                      4: /* 省略記法を用いない, ソース */
                      5: /* /PrimitiveContextp StandardContextp def
                      6:    Object = [PrimitiveContextp]
                      7:    def new() { Return(Object); }
                      8: */
                      9:
                     10: /* local int i, ans, int j;  などという形でデータ型を指定する. */
                     11:
                     12: class Complex extends Object {
                     13:   /* /Complex [(Complex) Object 0 get newcontext] def
                     14:      Complex 0 get setcontext
                     15:   */
                     16:   local re,im;
                     17:   def new(a,b) {
                     18:     this = super.new();
                     19:     /* /super Object def
                     20:        super [ ] {new} sendmsg2  /this set
                     21:        Complex this {rest} primmsg {append} primmsg
                     22:        [null null] {append} primmsg  /this set
                     23:     */
                     24:     re = a; /* this 1 a {put} primmsg  */
                     25:     im = b;
                     26:     return(this);
                     27:   }
                     28:   def void print() {  /* sm1 の print との関係を考えよ. */
                     29:     Print("[");
                     30:     /* ["["] {Print} sendmsg */
                     31:     Print(re); Print("]+i[");
                     32:     Print(im); Print("]");
                     33:   }
                     34:   def add(b) {
                     35:     local c;
                     36:     /* arg2 /b set  arg1 /this set */
                     37:     c = Complex.new(this.re,this.im);
                     38:     /* Complex [ this 1 {get} sendmsg this 2 {get} sendmsg ] {new} sendmsg2
                     39:        /c set */
                     40:     c.re = c.re+b.re;
                     41:     /* c 1 << c 1 get >> << b 1 get >> {add} sendmsg2 {Put} sendmsg2 */
                     42:     c.im = c.im+b.im;
                     43:     return(c);
                     44:   }
                     45: };
                     46:
                     47: a = Complex.new(1,2);
                     48: /* /a Complex [1 2] {new} sendmsg2 def */
                     49: a = a+b;
                     50: /* /a a b {add} sendmsg2 def */
                     51: a.print(); Println();
                     52: /* a [ ] {print} sendmsg2  [ ] {Println} sendmsg */
                     53:
                     54:
                     55:
                     56:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>