view truffle/com.oracle.truffle.sl.test/tests/Object.sl @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.sl.test/tests/Object.sl@997bc9764a9a
children
line wrap: on
line source

function main() {  
  obj1 = new();
  println(obj1.x);
  obj1.x = 42;
  println(obj1.x);
  
  obj2 = new();
  obj2.o = obj1;
  println(obj2.o.x);
  obj2.o.y = "why";
  println(obj1.y);
  
  println(mkobj().z);
  
  obj3 = new();
  obj3.fn = mkobj;
  println(obj3.fn().z);

  obj4 = new();
  write(obj4, 1);
  read(obj4);
  write(obj4, 2);
  read(obj4);
  write(obj4, "three");
  read(obj4);
}

function mkobj() {
  newobj = new();
  newobj.z = "zzz";
  return newobj;
}

function read(obj) {
  return obj.prop;
}

function write(obj, value) {
  return obj.prop = value;
}