Mercurial > hg > graal-compiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
18410:f444ef4684ec | 18411:dc2e000bed40 |
---|---|
1 function main() { | |
2 obj1 = new(); | |
3 println(obj1.x); | |
4 obj1.x = 42; | |
5 println(obj1.x); | |
6 | |
7 obj2 = new(); | |
8 obj2.o = obj1; | |
9 println(obj2.o.x); | |
10 obj2.o.y = "why"; | |
11 println(obj1.y); | |
12 | |
13 println(mkobj().z); | |
14 | |
15 obj3 = new(); | |
16 obj3.fn = mkobj; | |
17 println(obj3.fn().z); | |
18 } | |
19 | |
20 function mkobj() { | |
21 newobj = new(); | |
22 newobj.z = "zzz"; | |
23 return newobj; | |
24 } |