MCPcopy Create free account
hub / github.com/LFYSec/MScan / PrimitiveType

Enum PrimitiveType

src/main/java/pascal/taie/language/type/PrimitiveType.java:25–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23package pascal.taie.language.type;
24
25public enum PrimitiveType implements Type {
26
27 INT("int"),
28 CHAR("char"),
29 BOOLEAN("boolean"),
30 BYTE("byte"),
31 LONG("long"),
32 FLOAT("float"),
33 DOUBLE("double"),
34 SHORT("short");
35
36 /**
37 * Name of this type.
38 */
39 private final String name;
40
41 PrimitiveType(String name) {
42 this.name = name;
43 }
44
45 /**
46 * @return true if given name represents a primitive type, otherwise false.
47 */
48 public static boolean isPrimitiveType(String name) {
49 for (PrimitiveType t : values()) {
50 if (t.name.equals(name)) {
51 return true;
52 }
53 }
54 return false;
55 }
56
57 /**
58 * @return the primitive type specified by specific name.
59 * @throws IllegalArgumentException if given name is irrelevant to any primitive type.
60 */
61 public static PrimitiveType get(String name) {
62 for (PrimitiveType t : values()) {
63 if (t.name.equals(name)) {
64 return t;
65 }
66 }
67 throw new IllegalArgumentException(name + " is not primitive type");
68 }
69
70 @Override
71 public String getName() {
72 return name;
73 }
74
75 @Override
76 public String toString() {
77 return getName();
78 }
79
80 /**
81 * JVM Spec. (2.11.1): most operations on values of actual types
82 * boolean, byte, char, and short are correctly performed by instructions

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected