Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ImplicitCastData.java @ 18726:8153d8cf264c
Added unit test for StampFactoryTest.createParameterStamps.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 19 Dec 2014 14:58:50 +0100 |
parents | e6d15134ca86 |
children | 18c0f02fa4d2 |
rev | line source |
---|---|
11468
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
12452
diff
changeset
|
23 package com.oracle.truffle.dsl.processor.model; |
11468
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 public class ImplicitCastData extends TemplateMethod { |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
11545
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
27 private final TypeData sourceType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
28 private final TypeData targetType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
29 |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
30 public ImplicitCastData(TemplateMethod method, TypeData sourceType, TypeData targetType) { |
11468
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 super(method); |
11545
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
32 this.sourceType = sourceType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
33 this.targetType = targetType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
34 } |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
35 |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
36 public TypeData getSourceType() { |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
37 return sourceType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
38 } |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
39 |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
40 public TypeData getTargetType() { |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
41 return targetType; |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
42 } |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
43 |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
44 @Override |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
45 public int compareTo(TemplateMethod o) { |
12452
5f022aa41631
Truffle-DSL: fixed an NPE if invalid TypeData are compared.
Christian Humer <christian.humer@gmail.com>
parents:
11545
diff
changeset
|
46 if (o instanceof ImplicitCastData && sourceType != null) { |
11545
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
47 // implicit casts are ordered by source type since |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
48 // its also the order in which they are checked. |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
49 TypeData otherSourceType = ((ImplicitCastData) o).getSourceType(); |
12452
5f022aa41631
Truffle-DSL: fixed an NPE if invalid TypeData are compared.
Christian Humer <christian.humer@gmail.com>
parents:
11545
diff
changeset
|
50 if (otherSourceType != null) { |
5f022aa41631
Truffle-DSL: fixed an NPE if invalid TypeData are compared.
Christian Humer <christian.humer@gmail.com>
parents:
11545
diff
changeset
|
51 return this.sourceType.compareTo(otherSourceType); |
5f022aa41631
Truffle-DSL: fixed an NPE if invalid TypeData are compared.
Christian Humer <christian.humer@gmail.com>
parents:
11545
diff
changeset
|
52 } |
11545
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
53 } |
2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
Christian Humer <christian.humer@gmail.com>
parents:
11468
diff
changeset
|
54 return super.compareTo(o); |
11468
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 } |
79d4c4b2d6db
Truffle-DSL: added ImplicitCast api classes. (non functional yet)
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 } |