Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl.test/tests/Object.sl @ 18411:dc2e000bed40
SL: add basic support for creating objects and accessing properties
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Nov 2014 23:02:58 +0100 |
parents | |
children | 997bc9764a9a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.sl.test/tests/Object.sl Tue Nov 18 23:02:58 2014 +0100 @@ -0,0 +1,24 @@ +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); +} + +function mkobj() { + newobj = new(); + newobj.z = "zzz"; + return newobj; +}