Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/access/SLReadPropertyCacheNode.java @ 18764:ccb97347d874
SL: adapt SL to type system singleton removal.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:39:07 +0100 |
parents | 997bc9764a9a |
children | 73211b2c7c7a |
rev | line source |
---|---|
18412
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
1 /* |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
4 * |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
8 * |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
14 * |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
18 * |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
21 * questions. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
22 */ |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.nodes.access; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
24 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
25 import com.oracle.truffle.api.*; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
26 import com.oracle.truffle.api.nodes.*; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.object.*; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
28 import com.oracle.truffle.sl.nodes.*; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
29 import com.oracle.truffle.sl.runtime.*; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
30 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
31 /** |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
32 * The node for accessing a property of an object. When executed, this node first evaluates the |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
33 * object expression on the left side of the dot operator and then reads the named property. |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
34 */ |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
35 public abstract class SLReadPropertyCacheNode extends Node { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
36 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
37 public static SLReadPropertyCacheNode create(String propertyName) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
38 return new SLUninitializedReadObjectPropertyNode(propertyName); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
39 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
40 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
41 public abstract Object executeObject(DynamicObject receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
42 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
43 public abstract long executeLong(DynamicObject receiver) throws UnexpectedResultException; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
44 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
45 protected abstract static class SLReadPropertyCacheChainNode extends SLReadPropertyCacheNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
46 protected final Shape shape; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
47 @Child protected SLReadPropertyCacheNode next; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
48 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
49 public SLReadPropertyCacheChainNode(Shape shape, SLReadPropertyCacheNode next) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
50 this.shape = shape; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
51 this.next = next; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
52 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
53 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
54 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
55 public final Object executeObject(DynamicObject receiver) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
56 try { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
57 // if this assumption fails, the object needs to be updated to a valid shape |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
58 shape.getValidAssumption().check(); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
59 } catch (InvalidAssumptionException e) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
60 return this.replace(next).executeObject(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
61 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
62 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
63 boolean condition = shape.check(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
64 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
65 if (condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
66 return executeObjectUnchecked(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
67 } else { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
68 return next.executeObject(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
69 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
70 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
71 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
72 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
73 public final long executeLong(DynamicObject receiver) throws UnexpectedResultException { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
74 try { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
75 // if this assumption fails, the object needs to be updated to a valid shape |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
76 shape.getValidAssumption().check(); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
77 } catch (InvalidAssumptionException e) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
78 return this.replace(next).executeLong(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
79 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
80 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
81 boolean condition = shape.check(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
82 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
83 if (condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
84 return executeLongUnchecked(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
85 } else { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
86 return next.executeLong(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
87 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
88 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
89 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
90 protected abstract Object executeObjectUnchecked(DynamicObject receiver, boolean condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
91 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
92 protected long executeLongUnchecked(DynamicObject receiver, boolean condition) throws UnexpectedResultException { |
18764
ccb97347d874
SL: adapt SL to type system singleton removal.
Christian Humer <christian.humer@gmail.com>
parents:
18412
diff
changeset
|
93 return SLTypesGen.expectLong(executeObjectUnchecked(receiver, condition)); |
18412
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
94 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
95 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
96 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
97 protected static class SLReadObjectPropertyNode extends SLReadPropertyCacheChainNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
98 private final Location location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
99 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
100 protected SLReadObjectPropertyNode(Shape shape, Location location, SLReadPropertyCacheNode next) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
101 super(shape, next); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
102 this.location = location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
103 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
104 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
105 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
106 protected Object executeObjectUnchecked(DynamicObject receiver, boolean condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
107 return location.get(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
108 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
109 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
110 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
111 protected static class SLReadBooleanPropertyNode extends SLReadPropertyCacheChainNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
112 private final BooleanLocation location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
113 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
114 protected SLReadBooleanPropertyNode(Shape shape, BooleanLocation location, SLReadPropertyCacheNode next) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
115 super(shape, next); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
116 this.location = location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
117 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
118 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
119 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
120 protected Object executeObjectUnchecked(DynamicObject receiver, boolean condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
121 return location.getBoolean(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
122 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
123 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
124 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
125 protected static class SLReadLongPropertyNode extends SLReadPropertyCacheChainNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
126 private final LongLocation location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
127 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
128 protected SLReadLongPropertyNode(Shape shape, LongLocation location, SLReadPropertyCacheNode next) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
129 super(shape, next); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
130 this.location = location; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
131 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
132 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
133 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
134 protected Object executeObjectUnchecked(DynamicObject receiver, boolean condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
135 return location.getLong(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
136 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
137 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
138 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
139 protected long executeLongUnchecked(DynamicObject receiver, boolean condition) throws UnexpectedResultException { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
140 return location.getLong(receiver, condition); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
141 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
142 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
143 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
144 protected static class SLReadMissingPropertyNode extends SLReadPropertyCacheChainNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
145 protected SLReadMissingPropertyNode(Shape shape, SLReadPropertyCacheNode next) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
146 super(shape, next); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
147 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
148 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
149 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
150 protected Object executeObjectUnchecked(DynamicObject receiver, boolean condition) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
151 // The property was not found in the object, return null |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
152 return SLNull.SINGLETON; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
153 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
154 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
155 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
156 protected static class SLUninitializedReadObjectPropertyNode extends SLReadPropertyCacheNode { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
157 protected final String propertyName; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
158 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
159 protected SLUninitializedReadObjectPropertyNode(String propertyName) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
160 this.propertyName = propertyName; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
161 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
162 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
163 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
164 public Object executeObject(DynamicObject receiver) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
165 CompilerDirectives.transferToInterpreterAndInvalidate(); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
166 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
167 receiver.updateShape(); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
168 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
169 Shape shape = receiver.getShape(); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
170 Property property = shape.getProperty(propertyName); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
171 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
172 final SLReadPropertyCacheNode resolvedNode; |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
173 if (property == null) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
174 resolvedNode = new SLReadMissingPropertyNode(shape, this); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
175 } else if (property.getLocation() instanceof LongLocation) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
176 resolvedNode = new SLReadLongPropertyNode(shape, (LongLocation) property.getLocation(), this); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
177 } else if (property.getLocation() instanceof BooleanLocation) { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
178 resolvedNode = new SLReadBooleanPropertyNode(shape, (BooleanLocation) property.getLocation(), this); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
179 } else { |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
180 resolvedNode = new SLReadObjectPropertyNode(shape, property.getLocation(), this); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
181 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
182 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
183 return this.replace(resolvedNode, "resolved '" + propertyName + "'").executeObject(receiver); |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
184 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
185 |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
186 @Override |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
187 public long executeLong(DynamicObject receiver) throws UnexpectedResultException { |
18764
ccb97347d874
SL: adapt SL to type system singleton removal.
Christian Humer <christian.humer@gmail.com>
parents:
18412
diff
changeset
|
188 return SLTypesGen.expectLong(executeObject(receiver)); |
18412
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
189 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
190 } |
997bc9764a9a
SL: use the truffle object storage model to represent SL objects
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
191 } |