mirror of
https://github.com/github/codeql.git
synced 2026-04-18 21:44:02 +02:00
Swift: Add integral type classes.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
private import swift
|
||||
|
||||
/**
|
||||
* A floating-point type. This includes the `Float` type, the `Double`, and
|
||||
* builtin floating-point types.
|
||||
*/
|
||||
class FloatingPointType extends Type {
|
||||
FloatingPointType() {
|
||||
this.getName() = ["Float", "Double"] or
|
||||
this instanceof BuiltinFloatType
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
private import swift
|
||||
|
||||
/** The `Character` type. */
|
||||
class CharacterType extends StructType {
|
||||
CharacterType() { this.getName() = "Character" }
|
||||
}
|
||||
|
||||
/**
|
||||
* An integer-like type. For example, `Int`, `Int16`, `Uint16`, etc.
|
||||
*/
|
||||
class IntegerType extends Type {
|
||||
IntegerType() {
|
||||
this.getName() =
|
||||
["Int", "Int8", "Int16", "Int32", "Int64", "UInt", "UInt8", "Uint16", "Uint32", "UInt64"]
|
||||
or
|
||||
this instanceof BuiltinIntegerType
|
||||
}
|
||||
}
|
||||
|
||||
/** The `Bool` type. */
|
||||
class BooleanType extends Type {
|
||||
BooleanType() { this.getName() = "Bool" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A numeric-like type. This includes the types `Character`, `Bool`, and all
|
||||
* the integer-like types.
|
||||
*/
|
||||
class NumericOrCharType extends Type {
|
||||
NumericOrCharType() {
|
||||
this instanceof CharacterType or
|
||||
this instanceof IntegerType or
|
||||
this instanceof BooleanType
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,5 @@ import codeql.swift.elements.expr.InitializerCallExpr
|
||||
import codeql.swift.elements.expr.SelfRefExpr
|
||||
import codeql.swift.elements.decl.MethodDecl
|
||||
import codeql.swift.elements.decl.ClassOrStructDecl
|
||||
import codeql.swift.elements.type.NumericOrCharType
|
||||
import codeql.swift.Unit
|
||||
|
||||
Reference in New Issue
Block a user