annotate graal/com.oracle.truffle.sl.test/tests/Object.sl @ 19211:6081b30fe164

Make LocationMarker a LowLevelMidTierPhase.
author Josef Eisl <josef.eisl@jku.at>
date Fri, 06 Feb 2015 20:06:38 +0100
parents 997bc9764a9a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18411
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
1 function main() {
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
2 obj1 = new();
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
3 println(obj1.x);
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
4 obj1.x = 42;
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
5 println(obj1.x);
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
6
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
7 obj2 = new();
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
8 obj2.o = obj1;
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
9 println(obj2.o.x);
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
10 obj2.o.y = "why";
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
11 println(obj1.y);
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
12
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
13 println(mkobj().z);
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
14
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
15 obj3 = new();
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
16 obj3.fn = mkobj;
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
17 println(obj3.fn().z);
18412
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
18
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
19 obj4 = new();
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
20 write(obj4, 1);
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
21 read(obj4);
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
22 write(obj4, 2);
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
23 read(obj4);
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
24 write(obj4, "three");
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
25 read(obj4);
18411
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
26 }
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
27
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
28 function mkobj() {
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
29 newobj = new();
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
30 newobj.z = "zzz";
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
31 return newobj;
dc2e000bed40 SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
32 }
18412
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
33
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
34 function read(obj) {
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
35 return obj.prop;
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
36 }
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
37
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
38 function write(obj, value) {
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
39 return obj.prop = value;
997bc9764a9a SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents: 18411
diff changeset
40 }