Java Code Examples for com.strobel.assembler.metadata.TypeReference#makeArrayType()
The following examples show how to use
com.strobel.assembler.metadata.TypeReference#makeArrayType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleType.java From huntbugs with Apache License 2.0 | 6 votes |
static EType of(TypeReference tr, What what) { if (tr == null || tr.isPrimitive() || (what == What.SUBTYPE && Types.isObject(tr))) return UNKNOWN; TypeDefinition td = tr.resolve(); if (td == null) return UNKNOWN; if (td.isFinal() || td.isPrimitive()) { if (what == What.SUBTYPE) what = What.EXACT; if (what == What.NOT) what = What.NOT_SUBTYPE; } TypeReference newTr = td; while (tr.isArray()) { tr = tr.getElementType(); newTr = newTr.makeArrayType(); } boolean complete = Types.hasCompleteHierarchy(td); return new SingleType(newTr, what, complete); }
Example 2
Source File: Types.java From huntbugs with Apache License 2.0 | 6 votes |
public static TypeReference mergeTypes(TypeReference t1, TypeReference t2) { if (t1 == null || t2 == null) return null; if (t1 == BuiltinTypes.Null) return t2; if (t2 == BuiltinTypes.Null) return t1; if (t1.isEquivalentTo(t2)) return t1; if(t1.isArray() ^ t2.isArray()) return null; if(t1.isArray()) { TypeReference merged = mergeTypes(t1.getElementType(), t2.getElementType()); return merged == null ? null : merged.makeArrayType(); } List<TypeReference> chain1 = getBaseTypes(t1); List<TypeReference> chain2 = getBaseTypes(t2); for (int i = Math.min(chain1.size(), chain2.size()) - 1; i >= 0; i--) { if (chain1.get(i).equals(chain2.get(i))) return chain1.get(i); } return null; }