Files
codeql/csharp/ql/lib/semmle/code/dotnet/Expr.qll
Andrew Eisenberg c9f1c98390 Packaging: C# refactoring
Split c# pack into `codeql/csharp-all` and `codeql/csharp-queries`.
2021-08-19 14:09:35 -07:00

65 lines
1.7 KiB
Plaintext

/**
* Provides .Net expression classes.
*/
import Expr
import Type
import Callable
/** An expression. */
class Expr extends Element, @dotnet_expr {
/** Gets the callable containing this expression. */
Callable getEnclosingCallable() { none() }
/** Gets the type of this expression. */
Type getType() { none() }
/** Gets the constant value of this expression, if any. */
string getValue() { none() }
/** Holds if this expression has a value. */
final predicate hasValue() { exists(this.getValue()) }
/**
* Gets the parent of this expression. This is for example the element
* that uses the result of this expression.
*/
Element getParent() { none() }
}
/** A call. */
class Call extends Expr, @dotnet_call {
/** Gets the target of this call. */
Callable getTarget() { none() }
/** Gets any potential target of this call. */
Callable getARuntimeTarget() { none() }
/**
* Gets the `i`th "raw" argument to this call, if any.
* For instance methods, argument 0 is the qualifier.
*/
Expr getRawArgument(int i) { none() }
/** Gets the `i`th argument to this call, if any. */
Expr getArgument(int i) { none() }
/** Gets an argument to this call. */
Expr getAnArgument() { result = getArgument(_) }
/** Gets the expression that is supplied for parameter `p`. */
Expr getArgumentForParameter(Parameter p) { none() }
}
/** A literal expression. */
class Literal extends Expr, @dotnet_literal { }
/** A string literal expression. */
class StringLiteral extends Literal, @dotnet_string_literal { }
/** An integer literal expression. */
class IntLiteral extends Literal, @dotnet_int_literal { }
/** A `null` literal expression. */
class NullLiteral extends Literal, @dotnet_null_literal { }