|
| 1 | +/** |
| 2 | + * Provides classes for builtins. |
| 3 | + */ |
| 4 | + |
| 5 | +private import rust |
| 6 | + |
| 7 | +/** The folder containing builtins. */ |
| 8 | +class BuiltinsFolder extends Folder { |
| 9 | + BuiltinsFolder() { |
| 10 | + this.getBaseName() = "builtins" and |
| 11 | + this.getParentContainer().getBaseName() = "tools" |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +private class BuiltinsTypesFile extends File { |
| 16 | + BuiltinsTypesFile() { |
| 17 | + this.getBaseName() = "types.rs" and |
| 18 | + this.getParentContainer() instanceof BuiltinsFolder |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * A builtin type, such as `bool` and `i32`. |
| 24 | + * |
| 25 | + * Builtin types are represented as structs. |
| 26 | + */ |
| 27 | +class BuiltinType extends Struct { |
| 28 | + BuiltinType() { this.getFile() instanceof BuiltinsTypesFile } |
| 29 | + |
| 30 | + /** Gets the name of this type. */ |
| 31 | + string getName() { result = super.getName().getText() } |
| 32 | +} |
| 33 | + |
| 34 | +/** The builtin `bool` type. */ |
| 35 | +class Bool extends BuiltinType { |
| 36 | + Bool() { this.getName() = "bool" } |
| 37 | +} |
| 38 | + |
| 39 | +/** The builtin `char` type. */ |
| 40 | +class Char extends BuiltinType { |
| 41 | + Char() { this.getName() = "char" } |
| 42 | +} |
| 43 | + |
| 44 | +/** The builtin `str` type. */ |
| 45 | +class Str extends BuiltinType { |
| 46 | + Str() { this.getName() = "str" } |
| 47 | +} |
| 48 | + |
| 49 | +/** The builtin `i8` type. */ |
| 50 | +class I8 extends BuiltinType { |
| 51 | + I8() { this.getName() = "i8" } |
| 52 | +} |
| 53 | + |
| 54 | +/** The builtin `i16` type. */ |
| 55 | +class I16 extends BuiltinType { |
| 56 | + I16() { this.getName() = "i16" } |
| 57 | +} |
| 58 | + |
| 59 | +/** The builtin `i32` type. */ |
| 60 | +class I32 extends BuiltinType { |
| 61 | + I32() { this.getName() = "i32" } |
| 62 | +} |
| 63 | + |
| 64 | +/** The builtin `i64` type. */ |
| 65 | +class I64 extends BuiltinType { |
| 66 | + I64() { this.getName() = "i64" } |
| 67 | +} |
| 68 | + |
| 69 | +/** The builtin `i128` type. */ |
| 70 | +class I128 extends BuiltinType { |
| 71 | + I128() { this.getName() = "i128" } |
| 72 | +} |
| 73 | + |
| 74 | +/** The builtin `u8` type. */ |
| 75 | +class U8 extends BuiltinType { |
| 76 | + U8() { this.getName() = "u8" } |
| 77 | +} |
| 78 | + |
| 79 | +/** The builtin `u16` type. */ |
| 80 | +class U16 extends BuiltinType { |
| 81 | + U16() { this.getName() = "u16" } |
| 82 | +} |
| 83 | + |
| 84 | +/** The builtin `u32` type. */ |
| 85 | +class U32 extends BuiltinType { |
| 86 | + U32() { this.getName() = "u32" } |
| 87 | +} |
| 88 | + |
| 89 | +/** The builtin `u64` type. */ |
| 90 | +class U64 extends BuiltinType { |
| 91 | + U64() { this.getName() = "u64" } |
| 92 | +} |
| 93 | + |
| 94 | +/** The builtin `u128` type. */ |
| 95 | +class U128 extends BuiltinType { |
| 96 | + U128() { this.getName() = "u128" } |
| 97 | +} |
| 98 | + |
| 99 | +/** The builtin `usize` type. */ |
| 100 | +class USize extends BuiltinType { |
| 101 | + USize() { this.getName() = "usize" } |
| 102 | +} |
| 103 | + |
| 104 | +/** The builtin `isize` type. */ |
| 105 | +class ISize extends BuiltinType { |
| 106 | + ISize() { this.getName() = "isize" } |
| 107 | +} |
| 108 | + |
| 109 | +/** The builtin `f32` type. */ |
| 110 | +class F32 extends BuiltinType { |
| 111 | + F32() { this.getName() = "f32" } |
| 112 | +} |
| 113 | + |
| 114 | +/** The builtin `f64` type. */ |
| 115 | +class F64 extends BuiltinType { |
| 116 | + F64() { this.getName() = "f64" } |
| 117 | +} |
0 commit comments