Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java @ 22548:6b76a24fffbd default tip
Use all variables: a, b, u,v and x, y
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 14 Jan 2016 14:20:57 +0100 |
parents | dc83cc1f94f2 |
children |
rev | line source |
---|---|
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.dsl.processor.model; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
25 import com.oracle.truffle.dsl.processor.expression.DSLExpression; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
26 import com.oracle.truffle.dsl.processor.java.ElementUtils; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
27 import javax.lang.model.element.AnnotationMirror; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
28 import javax.lang.model.element.AnnotationValue; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
29 import javax.lang.model.element.Element; |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 public final class CacheExpression extends MessageContainer { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 private final DSLExpression expression; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 private final Parameter sourceParameter; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 private final AnnotationMirror sourceAnnotationMirror; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 public CacheExpression(Parameter sourceParameter, AnnotationMirror sourceAnnotationMirror, DSLExpression expression) { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 this.sourceParameter = sourceParameter; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 this.expression = expression; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 this.sourceAnnotationMirror = sourceAnnotationMirror; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
43 public Parameter getParameter() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
44 return sourceParameter; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
45 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
46 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 @Override |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 public Element getMessageElement() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 return sourceParameter.getVariableElement(); |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 @Override |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 public AnnotationMirror getMessageAnnotation() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 return sourceAnnotationMirror; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 @Override |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 public AnnotationValue getMessageAnnotationValue() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 return ElementUtils.getAnnotationValue(getMessageAnnotation(), "value"); |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 public DSLExpression getExpression() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 return expression; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 } |