Skip to content

Commit 1638183

Browse files
committed
C#: Copy dotnet.Variable implementation.
1 parent 6178acc commit 1638183

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

csharp/ql/lib/semmle/code/csharp/Variable.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ private import TypeRef
1414
/**
1515
* A variable. Either a variable with local scope (`LocalScopeVariable`) or a field (`Field`).
1616
*/
17-
class Variable extends Assignable, DotNet::Variable, @variable {
17+
class Variable extends Assignable, @variable {
1818
override Variable getUnboundDeclaration() { result = this }
1919

2020
override VariableAccess getAnAccess() { result.getTarget() = this }
2121

22+
/** Gets the type of this variable. */
2223
override Type getType() { none() }
2324

2425
/** Gets the expression used to initialise this variable, if any. */
@@ -87,9 +88,10 @@ class LocalScopeVariable extends Variable, @local_scope_variable {
8788
* }
8889
* ```
8990
*/
90-
class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, TopLevelExprParent,
91-
@parameter
92-
{
91+
class Parameter extends LocalScopeVariable, Attributable, TopLevelExprParent, @parameter {
92+
/** Gets the raw position of this parameter, including the `this` parameter at index 0. */
93+
final int getRawPosition() { this = this.getDeclaringElement().getRawParameter(result) }
94+
9395
/**
9496
* Gets the position of this parameter. For example, the position of `x` is
9597
* 0 and the position of `y` is 1 in
@@ -100,7 +102,7 @@ class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, Top
100102
* }
101103
* ```
102104
*/
103-
override int getPosition() { params(this, _, _, result, _, _, _) }
105+
int getPosition() { params(this, _, _, result, _, _, _) }
104106

105107
override int getIndex() { result = this.getPosition() }
106108

@@ -138,7 +140,7 @@ class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, Top
138140
* }
139141
* ```
140142
*/
141-
override predicate isOut() { params(this, _, _, _, 2, _, _) }
143+
predicate isOut() { params(this, _, _, _, 2, _, _) }
142144

143145
/**
144146
* Holds if this parameter is a value type that is passed in by reference.
@@ -193,7 +195,7 @@ class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, Top
193195
predicate hasExtensionMethodModifier() { params(this, _, _, _, 4, _, _) }
194196

195197
/** Gets the declaring element of this parameter. */
196-
override Parameterizable getDeclaringElement() { params(this, _, _, _, _, result, _) }
198+
Parameterizable getDeclaringElement() { params(this, _, _, _, _, result, _) }
197199

198200
override Parameter getUnboundDeclaration() { params(this, _, _, _, _, _, result) }
199201

@@ -396,9 +398,7 @@ class LocalConstant extends LocalVariable, @local_constant {
396398
* }
397399
* ```
398400
*/
399-
class Field extends Variable, AssignableMember, Attributable, TopLevelExprParent, DotNet::Field,
400-
@field
401-
{
401+
class Field extends Variable, AssignableMember, Attributable, TopLevelExprParent, @field {
402402
/**
403403
* Gets the initial value of this field, if any. For example, the initial
404404
* value of `F` on line 2 is `20` in

0 commit comments

Comments
 (0)