Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TypeSystemData.java @ 16816:b8470fcec3a3
Truffle-DSL: refined type system type caching
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 13 Aug 2014 18:06:18 +0200 |
parents | e8d9b3827d4b |
children | 8169deda04bb |
comparison
equal
deleted
inserted
replaced
16815:c22fc3f48c60 | 16816:b8470fcec3a3 |
---|---|
33 public class TypeSystemData extends Template { | 33 public class TypeSystemData extends Template { |
34 | 34 |
35 private List<TypeData> types; | 35 private List<TypeData> types; |
36 private List<TypeMirror> primitiveTypeMirrors = new ArrayList<>(); | 36 private List<TypeMirror> primitiveTypeMirrors = new ArrayList<>(); |
37 private List<TypeMirror> boxedTypeMirrors = new ArrayList<>(); | 37 private List<TypeMirror> boxedTypeMirrors = new ArrayList<>(); |
38 private Map<TypeMirror, TypeData> cachedTypes = new HashMap<>(); | 38 private Map<String, TypeData> cachedTypes = new HashMap<>(); |
39 | 39 |
40 private List<ImplicitCastData> implicitCasts; | 40 private List<ImplicitCastData> implicitCasts; |
41 private List<TypeCastData> casts; | 41 private List<TypeCastData> casts; |
42 private List<TypeCheckData> checks; | 42 private List<TypeCheckData> checks; |
43 | 43 |
57 this.types = types; | 57 this.types = types; |
58 if (types != null) { | 58 if (types != null) { |
59 for (TypeData typeData : types) { | 59 for (TypeData typeData : types) { |
60 primitiveTypeMirrors.add(typeData.getPrimitiveType()); | 60 primitiveTypeMirrors.add(typeData.getPrimitiveType()); |
61 boxedTypeMirrors.add(typeData.getBoxedType()); | 61 boxedTypeMirrors.add(typeData.getBoxedType()); |
62 cachedTypes.put(typeData.getPrimitiveType(), typeData); | 62 cachedTypes.put(typeData.getPrimitiveType().toString(), typeData); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 public void setImplicitCasts(List<ImplicitCastData> implicitCasts) { | 67 public void setImplicitCasts(List<ImplicitCastData> implicitCasts) { |
152 } | 152 } |
153 return types.get(index); | 153 return types.get(index); |
154 } | 154 } |
155 | 155 |
156 public int findType(TypeMirror type) { | 156 public int findType(TypeMirror type) { |
157 TypeData data = cachedTypes.get(type); | 157 TypeData data = cachedTypes.get(type.toString()); |
158 if (data != null) { | 158 if (data != null) { |
159 return data.getIndex(); | 159 return data.getIndex(); |
160 } | 160 } |
161 return -1; | 161 return -1; |
162 } | 162 } |