Merge pull request #16104 from hvitved/csharp/more-compiler-generated

C#: Mark more expressions as compiler generated
This commit is contained in:
Tom Hvitved
2024-04-04 09:09:16 +02:00
committed by GitHub
48 changed files with 189 additions and 305 deletions

View File

@@ -100,8 +100,14 @@ namespace Semmle.Extraction.CSharp.Entities
/// <param name="child">The child index.</param>
/// <param name="type">A type hint.</param>
/// <returns>The new expression.</returns>
public static Expression Create(Context cx, ExpressionSyntax node, IExpressionParentEntity parent, int child) =>
CreateFromNode(new ExpressionNodeInfo(cx, node, parent, child));
public static Expression Create(Context cx, ExpressionSyntax node, IExpressionParentEntity parent, int child, Boolean isCompilerGenerated = false)
{
var info = new ExpressionNodeInfo(cx, node, parent, child)
{
IsCompilerGenerated = isCompilerGenerated
};
return CreateFromNode(info);
}
public static Expression CreateFromNode(ExpressionNodeInfo info) => Expressions.ImplicitCast.Create(info);

View File

@@ -97,7 +97,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.ARRAY_CREATION,
parent,
childIndex,
true,
isCompilerGenerated: true,
null);
var arrayCreation = new Expression(info);

View File

@@ -26,10 +26,10 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
if (operatorKind.HasValue)
{
// Convert assignment such as `a += b` into `a = a + b`.
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, Type, Location, ExprKind.SIMPLE_ASSIGN, this, 2, false, null));
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, Type, Location, ExprKind.SIMPLE_ASSIGN, this, 2, isCompilerGenerated: true, null));
Create(Context, Syntax.Left, simpleAssignExpr, 1);
var opexpr = new Expression(new ExpressionInfo(Context, Type, Location, operatorKind.Value, simpleAssignExpr, 0, false, null));
Create(Context, Syntax.Left, opexpr, 0);
var opexpr = new Expression(new ExpressionInfo(Context, Type, Location, operatorKind.Value, simpleAssignExpr, 0, isCompilerGenerated: true, null));
Create(Context, Syntax.Left, opexpr, 0, isCompilerGenerated: true);
Create(Context, Syntax.Right, opexpr, 1);
opexpr.OperatorCall(trapFile, Syntax);
}

View File

@@ -41,7 +41,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.CAST,
parent,
childIndex,
true,
isCompilerGenerated: true,
ValueAsString(value));
var ret = new Expression(info);

View File

@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class Spread : Expression
{
public Spread(Context cx, SpreadElementSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.SPREAD_ELEMENT, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.SPREAD_ELEMENT, parent, child, isCompilerGenerated: false, null))
{
Create(cx, syntax.Expression, this, 0);
}

View File

@@ -24,7 +24,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.DEFAULT,
parent,
childIndex,
true,
isCompilerGenerated: true,
value);
return new Expression(info);

View File

@@ -11,7 +11,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
}
private Discard(Context cx, CSharpSyntaxNode syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.CreateLocation(syntax.GetLocation()), ExprKind.DISCARD, parent, child, false, null))
base(new ExpressionInfo(cx, cx.GetType(syntax), cx.CreateLocation(syntax.GetLocation()), ExprKind.DISCARD, parent, child, isCompilerGenerated: false, null))
{
}

View File

@@ -22,7 +22,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
if (Kind == ExprKind.POINTER_INDIRECTION)
{
var qualifierInfo = new ExpressionNodeInfo(Context, qualifier, this, 0);
var add = new Expression(new ExpressionInfo(Context, qualifierInfo.Type, Location, ExprKind.ADD, this, 0, false, null));
var add = new Expression(new ExpressionInfo(Context, qualifierInfo.Type, Location, ExprKind.ADD, this, 0, isCompilerGenerated: false, null));
qualifierInfo.SetParent(add, 0);
CreateFromNode(qualifierInfo);
PopulateArguments(trapFile, argumentList, 1);

View File

@@ -14,13 +14,13 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
}
private ImplicitCast(ExpressionNodeInfo info)
: base(new ExpressionInfo(info.Context, info.ConvertedType, info.Location, ExprKind.CAST, info.Parent, info.Child, true, info.ExprValue))
: base(new ExpressionInfo(info.Context, info.ConvertedType, info.Location, ExprKind.CAST, info.Parent, info.Child, isCompilerGenerated: true, info.ExprValue))
{
Expr = Factory.Create(new ExpressionNodeInfo(Context, info.Node, this, 0));
}
private ImplicitCast(ExpressionNodeInfo info, IMethodSymbol method)
: base(new ExpressionInfo(info.Context, info.ConvertedType, info.Location, ExprKind.OPERATOR_INVOCATION, info.Parent, info.Child, true, info.ExprValue))
: base(new ExpressionInfo(info.Context, info.ConvertedType, info.Location, ExprKind.OPERATOR_INVOCATION, info.Parent, info.Child, isCompilerGenerated: true, info.ExprValue))
{
Expr = Factory.Create(info.SetParent(this, 0));
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
kind,
parent,
childIndex,
true,
isCompilerGenerated: true,
v);
var method = GetImplicitConversionMethod(type, value);
@@ -93,7 +93,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.CAST,
parent,
childIndex,
true,
isCompilerGenerated: true,
ValueAsString(value));
return new Expression(info);

View File

@@ -45,7 +45,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.ARRAY_INIT,
parent,
index,
true,
isCompilerGenerated: true,
null);
return new Expression(info);
@@ -132,7 +132,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
var addMethod = Method.Create(Context, collectionInfo.Symbol as IMethodSymbol);
var voidType = AnnotatedTypeSymbol.CreateNotAnnotated(Context.Compilation.GetSpecialType(SpecialType.System_Void));
var invocation = new Expression(new ExpressionInfo(Context, voidType, Context.CreateLocation(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
var invocation = new Expression(new ExpressionInfo(Context, voidType, Context.CreateLocation(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, isCompilerGenerated: true, null));
if (addMethod is not null)
trapFile.expr_call(invocation, addMethod);

View File

@@ -25,7 +25,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
case SyntaxKind.InterpolatedStringText:
// Create a string literal
var interpolatedText = (InterpolatedStringTextSyntax)c;
new Expression(new ExpressionInfo(Context, Type, Context.CreateLocation(c.GetLocation()), ExprKind.UTF16_STRING_LITERAL, this, child++, false, interpolatedText.TextToken.ValueText));
new Expression(new ExpressionInfo(Context, Type, Context.CreateLocation(c.GetLocation()), ExprKind.UTF16_STRING_LITERAL, this, child++, isCompilerGenerated: false, interpolatedText.TextToken.ValueText));
break;
default:
throw new InternalError(c, $"Unhandled interpolation kind {c.Kind()}");

View File

@@ -97,7 +97,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
kind,
parent,
childIndex,
true,
isCompilerGenerated: true,
ValueAsString(value));
return new Expression(info);
@@ -112,7 +112,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.NULL_LITERAL,
parent,
childIndex,
true,
isCompilerGenerated: true,
ValueAsString(null));
return new Expression(info);

View File

@@ -30,7 +30,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
return;
}
var objectInitializer = new Expression(new ExpressionInfo(Context, Type, Location, ExprKind.OBJECT_INIT, this, -1, false, null));
var objectInitializer = new Expression(new ExpressionInfo(Context, Type, Location, ExprKind.OBJECT_INIT, this, -1, isCompilerGenerated: false, null));
foreach (var init in Syntax.Initializers)
{
@@ -40,11 +40,11 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
var type = property.GetAnnotatedType();
var loc = Context.CreateLocation(init.GetLocation());
var assignment = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.SIMPLE_ASSIGN, objectInitializer, child++, false, null));
var assignment = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.SIMPLE_ASSIGN, objectInitializer, child++, isCompilerGenerated: false, null));
Create(Context, init.Expression, assignment, 0);
Property.Create(Context, property);
var access = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.PROPERTY_ACCESS, assignment, 1, false, null));
var access = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.PROPERTY_ACCESS, assignment, 1, isCompilerGenerated: false, null));
trapFile.expr_access(access, propEntity);
}
}

View File

@@ -59,7 +59,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.OBJECT_CREATION,
parent,
childIndex,
true,
isCompilerGenerated: true,
null));
var longTypeSymbol = constructorSymbol.Parameters[0].Type;

View File

@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class BinaryPattern : Expression
{
public BinaryPattern(Context cx, BinaryPatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken, syntax), parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken, syntax), parent, child, isCompilerGenerated: false, null))
{
Pattern.Create(cx, syntax.Left, this, 0);
Pattern.Create(cx, syntax.Right, this, 1);

View File

@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class ListPattern : Expression
{
internal ListPattern(Context cx, ListPatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.LIST_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.LIST_PATTERN, parent, child, isCompilerGenerated: false, null))
{
syntax.Patterns.ForEach((p, i) => Pattern.Create(cx, p, this, i));
}

View File

@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class PositionalPattern : Expression
{
internal PositionalPattern(Context cx, PositionalPatternClauseSyntax posPc, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, isCompilerGenerated: false, null))
{
posPc.Subpatterns.ForEach((p, i) => Pattern.Create(cx, p.Pattern, this, i));
}

View File

@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class PropertyPattern : Expression
{
internal PropertyPattern(Context cx, PropertyPatternClauseSyntax pp, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, isCompilerGenerated: false, null))
{
child = 0;
foreach (var sub in pp.Subpatterns)
@@ -56,7 +56,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
};
private static Expression CreateSyntheticExp(Context cx, Microsoft.CodeAnalysis.Location location, IExpressionParentEntity parent, int child) =>
new Expression(new ExpressionInfo(cx, null, cx.CreateLocation(location), ExprKind.PROPERTY_PATTERN, parent, child, false, null));
new Expression(new ExpressionInfo(cx, null, cx.CreateLocation(location), ExprKind.PROPERTY_PATTERN, parent, child, isCompilerGenerated: false, null));
private static void MakeExpressions(Context cx, IExpressionParentEntity parent, SubpatternSyntax syntax, int child)
{

View File

@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
/// <param name="parent">The parent pattern/expression.</param>
/// <param name="child">The child index of this pattern.</param>
public RecursivePattern(Context cx, RecursivePatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.RECURSIVE_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.RECURSIVE_PATTERN, parent, child, isCompilerGenerated: false, null))
{
// Extract the type access
if (syntax.Type is TypeSyntax t)

View File

@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class RelationalPattern : Expression
{
public RelationalPattern(Context cx, RelationalPatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken), parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), GetKind(syntax.OperatorToken), parent, child, isCompilerGenerated: false, null))
{
Expression.Create(cx, syntax.Expression, this, 0);
}

View File

@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class SlicePattern : Expression
{
public SlicePattern(Context cx, SlicePatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.SLICE_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.SLICE_PATTERN, parent, child, isCompilerGenerated: false, null))
{
if (syntax.Pattern is not null)
{

View File

@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal class UnaryPattern : Expression
{
public UnaryPattern(Context cx, UnaryPatternSyntax syntax, IExpressionParentEntity parent, int child) :
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.NOT_PATTERN, parent, child, false, null))
base(new ExpressionInfo(cx, null, cx.CreateLocation(syntax.GetLocation()), ExprKind.NOT_PATTERN, parent, child, isCompilerGenerated: false, null))
{
Pattern.Create(cx, syntax.Pattern, this, 0);
}

View File

@@ -23,7 +23,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
public QueryCall(Context cx, IMethodSymbol? method, SyntaxNode clause, IExpressionParentEntity parent, int child)
: base(new ExpressionInfo(cx, method?.GetAnnotatedReturnType(),
cx.CreateLocation(clause.GetLocation()),
ExprKind.METHOD_INVOCATION, parent, child, false, null))
ExprKind.METHOD_INVOCATION, parent, child, isCompilerGenerated: false, null))
{
if (method is not null)
cx.TrapWriter.Writer.expr_call(this, Method.Create(cx, method));
@@ -97,7 +97,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
Expression.Create(cx, Expr, decl, 0);
var nameLoc = cx.CreateLocation(name.GetLocation());
var access = new Expression(new ExpressionInfo(cx, type, nameLoc, ExprKind.LOCAL_VARIABLE_ACCESS, decl, 1, false, null));
var access = new Expression(new ExpressionInfo(cx, type, nameLoc, ExprKind.LOCAL_VARIABLE_ACCESS, decl, 1, isCompilerGenerated: false, null));
cx.TrapWriter.Writer.expr_access(access, LocalVariable.Create(cx, variableSymbol));
return decl;

View File

@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
internal SwitchCase(Context cx, SwitchExpressionArmSyntax arm, Switch parent, int child) :
base(new ExpressionInfo(
cx, cx.GetType(arm.Expression), cx.CreateLocation(arm.GetLocation()),
ExprKind.SWITCH_CASE, parent, child, false, null))
ExprKind.SWITCH_CASE, parent, child, isCompilerGenerated: false, null))
{
Expressions.Pattern.Create(cx, arm.Pattern, this, 0);
if (arm.WhenClause is WhenClauseSyntax when)

View File

@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
private This(IExpressionInfo info) : base(info) { }
public static This CreateImplicit(Context cx, ITypeSymbol @class, Extraction.Entities.Location loc, IExpressionParentEntity parent, int child) =>
new This(new ExpressionInfo(cx, AnnotatedTypeSymbol.CreateNotAnnotated(@class), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
new This(new ExpressionInfo(cx, AnnotatedTypeSymbol.CreateNotAnnotated(@class), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, isCompilerGenerated: true, null));
public static This CreateExplicit(ExpressionNodeInfo info) => new This(info.SetKind(ExprKind.THIS_ACCESS));
}

View File

@@ -44,7 +44,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.TYPE_ACCESS,
parent,
childIndex,
true,
isCompilerGenerated: true,
null);
return new Expression(typeAccessInfo);

View File

@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
ExprKind.TYPEOF,
parent,
childIndex,
true,
isCompilerGenerated: true,
null);
var ret = new Expression(info);

View File

@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
public static VariableDeclaration Create(Context cx, ISymbol symbol, AnnotatedTypeSymbol? type, TypeSyntax? optionalSyntax, Extraction.Entities.Location exprLocation, bool isVar, IExpressionParentEntity parent, int child)
{
var ret = new VariableDeclaration(new ExpressionInfo(cx, type, exprLocation, ExprKind.LOCAL_VAR_DECL, parent, child, false, null));
var ret = new VariableDeclaration(new ExpressionInfo(cx, type, exprLocation, ExprKind.LOCAL_VAR_DECL, parent, child, isCompilerGenerated: false, null));
cx.Try(null, null, () =>
{
var l = LocalVariable.Create(cx, symbol);
@@ -52,7 +52,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
public static Expression CreateParenthesized(Context cx, DeclarationExpressionSyntax node, ParenthesizedVariableDesignationSyntax designation, IExpressionParentEntity parent, int child, INamedTypeSymbol? t)
{
var type = t is null ? (AnnotatedTypeSymbol?)null : new AnnotatedTypeSymbol(t, t.NullableAnnotation);
var tuple = new Expression(new ExpressionInfo(cx, type, cx.CreateLocation(node.GetLocation()), ExprKind.TUPLE, parent, child, false, null));
var tuple = new Expression(new ExpressionInfo(cx, type, cx.CreateLocation(node.GetLocation()), ExprKind.TUPLE, parent, child, isCompilerGenerated: false, null));
cx.Try(null, null, () =>
{
@@ -68,7 +68,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
public static Expression CreateParenthesized(Context cx, VarPatternSyntax varPattern, ParenthesizedVariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
{
var tuple = new Expression(
new ExpressionInfo(cx, null, cx.CreateLocation(varPattern.GetLocation()), ExprKind.TUPLE, parent, child, false, null),
new ExpressionInfo(cx, null, cx.CreateLocation(varPattern.GetLocation()), ExprKind.TUPLE, parent, child, isCompilerGenerated: false, null),
shouldPopulate: false);
var elementTypes = new List<ITypeSymbol?>();
@@ -148,7 +148,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
Create(cx, node, node.Designation, parent, child, cx.GetTypeInfo(node).Type.DisambiguateType() as INamedTypeSymbol);
public static VariableDeclaration Create(Context cx, CSharpSyntaxNode c, AnnotatedTypeSymbol? type, IExpressionParentEntity parent, int child) =>
new VariableDeclaration(new ExpressionInfo(cx, type, cx.CreateLocation(c.FixedLocation()), ExprKind.LOCAL_VAR_DECL, parent, child, false, null));
new VariableDeclaration(new ExpressionInfo(cx, type, cx.CreateLocation(c.FixedLocation()), ExprKind.LOCAL_VAR_DECL, parent, child, isCompilerGenerated: false, null));
public static VariableDeclaration Create(Context cx, CatchDeclarationSyntax d, bool isVar, IExpressionParentEntity parent, int child)
{
@@ -179,7 +179,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
Create(cx, d.Initializer.Value, ret, 0);
// Create an access
var access = new Expression(new ExpressionInfo(cx, type, localVar.Location, ExprKind.LOCAL_VARIABLE_ACCESS, ret, 1, false, null));
var access = new Expression(new ExpressionInfo(cx, type, localVar.Location, ExprKind.LOCAL_VARIABLE_ACCESS, ret, 1, isCompilerGenerated: false, null));
cx.TrapWriter.Writer.expr_access(access, localVar);
}

View File

@@ -110,9 +110,9 @@ namespace Semmle.Extraction.CSharp.Entities
string? constValue, ref int child)
{
var type = Symbol.GetAnnotatedType();
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, constValue));
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, type, loc, ExprKind.SIMPLE_ASSIGN, this, child++, isCompilerGenerated: true, constValue));
Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer, simpleAssignExpr, 0));
var access = new Expression(new ExpressionInfo(Context, type, Location, ExprKind.FIELD_ACCESS, simpleAssignExpr, 1, false, constValue));
var access = new Expression(new ExpressionInfo(Context, type, Location, ExprKind.FIELD_ACCESS, simpleAssignExpr, 1, isCompilerGenerated: true, constValue));
trapFile.expr_access(access, this);
return access;
}

View File

@@ -86,9 +86,9 @@ namespace Semmle.Extraction.CSharp.Entities
{
var loc = Context.CreateLocation(initializer!.GetLocation());
var annotatedType = AnnotatedTypeSymbol.CreateNotAnnotated(Symbol.Type);
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, null));
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, isCompilerGenerated: true, null));
Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer.Value, simpleAssignExpr, 0));
var access = new Expression(new ExpressionInfo(Context, annotatedType, Location, ExprKind.PROPERTY_ACCESS, simpleAssignExpr, 1, false, null));
var access = new Expression(new ExpressionInfo(Context, annotatedType, Location, ExprKind.PROPERTY_ACCESS, simpleAssignExpr, 1, isCompilerGenerated: true, null));
trapFile.expr_access(access, this);
if (!Symbol.IsStatic)
{

View File

@@ -32,7 +32,10 @@ private predicate shouldPrint(Element e, Location l) {
}
private predicate isImplicitExpression(ControlFlowElement element) {
element.(Expr).isImplicit() and not exists(element.getAChild())
element.(Expr).isImplicit() and
not element instanceof CastExpr and
not element.(OperatorCall).getTarget() instanceof ImplicitConversionOperator and
not element instanceof ElementInitializer
}
private predicate isFilteredCompilerGenerated(Declaration d) {
@@ -291,18 +294,6 @@ class ControlFlowElementNode extends ElementNode {
controlFlowElement = element and
// Removing implicit expressions
not isImplicitExpression(element) and
// Removing extra nodes that are generated for an `AssignOperation`
not exists(AssignOperation ao |
ao.hasExpandedAssignment() and
(
ao.getExpandedAssignment() = controlFlowElement or
ao.getExpandedAssignment().getRValue() = controlFlowElement or
ao.getExpandedAssignment().getRValue().(BinaryOperation).getLeftOperand() =
controlFlowElement.getParent*() or
ao.getExpandedAssignment().getRValue().(OperatorCall).getChild(0) =
controlFlowElement.getParent*()
)
) and
not isNotNeeded(element.getParent+()) and
// LambdaExpr is both a Callable and a ControlFlowElement,
// print it with the more specific CallableNode
@@ -429,7 +420,7 @@ final class DeclarationWithAccessorsNode extends ElementNode {
result.(ParametersNode).getParameterizable() = declaration
or
childIndex = 2 and
result.(ElementNode).getElement() = declaration.(Property).getInitializer().getParent()
result.(ElementNode).getElement() = declaration.(Property).getInitializer()
or
result.(ElementNode).getElement() =
rank[childIndex - 2](Element a, string file, int line, int column, string name |
@@ -462,12 +453,7 @@ final class FieldNode extends ElementNode {
result.(AttributesNode).getAttributable() = field
or
childIndex = 1 and
field.hasInitializer() and
(
if field.getDeclaringType() instanceof Enum
then result.(ElementNode).getElement() = field.getInitializer()
else result.(ElementNode).getElement() = field.getInitializer().getParent()
)
result.(ElementNode).getElement() = field.getInitializer()
}
}

View File

@@ -408,7 +408,7 @@ class Field extends Variable, AssignableMember, Attributable, TopLevelExprParent
* }
* ```
*/
override Expr getInitializer() { result = this.getChildExpr(0).getChildExpr(0) }
final override Expr getInitializer() { result = this.getChildExpr(0).getChildExpr(0) }
/**
* Holds if this field has an initial value. For example, the initial
@@ -515,6 +515,4 @@ class EnumConstant extends MemberConstant {
* ```
*/
predicate hasExplicitValue() { exists(this.getInitializer()) }
override Expr getInitializer() { result = this.getChildExpr(0) }
}

View File

@@ -67,7 +67,11 @@ class Expr extends ControlFlowElement, @expr {
* Holds if this expression is generated by the compiler and does not appear
* explicitly in the source code.
*/
predicate isImplicit() { compiler_generated(this) }
final predicate isImplicit() {
compiler_generated(this) or
this =
any(AssignOperation op).getExpandedAssignment().getRValue().getChildExpr(0).getAChildExpr+()
}
/**
* Gets an expression that is the result of stripping (recursively) all

View File

@@ -163,9 +163,7 @@ attributes.cs:
# 67| 4: [BlockStmt] {...}
# 70| [Enum] E
# 70| 5: [Field] A
# 70| 1: [AssignExpr] ... = ...
# 70| 0: [MemberConstantAccess] access to constant A
# 70| 1: [IntLiteral] 42
# 70| 1: [IntLiteral] 42
# 72| [Class] ArgsAttribute
#-----| 3: (Base types)
# 72| 0: [TypeMention] Attribute

View File

@@ -186,14 +186,10 @@ trivia.cs:
# 89| 4: [BlockStmt] {...}
# 92| 7: [Field] F1
# 92| -1: [TypeMention] int
# 92| 1: [AssignExpr] ... = ...
# 92| 0: [FieldAccess] access to field F1
# 94| 1: [IntLiteral] 10
# 94| 1: [IntLiteral] 10
# 98| 8: [Field] F2
# 98| -1: [TypeMention] int
# 98| 1: [AssignExpr] ... = ...
# 98| 0: [FieldAccess] access to field F2
# 98| 1: [IntLiteral] 0
# 98| 1: [IntLiteral] 0
# 100| 9: [Property] P1
# 100| -1: [TypeMention] int
# 102| 3: [Getter] get_P1

View File

@@ -1111,18 +1111,14 @@ StaticInterfaceMembers.cs:
#-----| 3: (Base types)
# 28| 4: [Property] Real
# 28| -1: [TypeMention] double
# 28| 2: [AssignExpr] ... = ...
# 28| 0: [PropertyCall] access to property Real
# 28| 1: [DoubleLiteral] 0
# 28| 2: [DoubleLiteral] 0
# 28| 3: [Getter] get_Real
# 28| 4: [Setter] set_Real
#-----| 2: (Parameters)
# 28| 0: [Parameter] value
# 29| 5: [Property] Imaginary
# 29| -1: [TypeMention] double
# 29| 2: [AssignExpr] ... = ...
# 29| 0: [PropertyCall] access to property Imaginary
# 29| 1: [DoubleLiteral] 0
# 29| 2: [DoubleLiteral] 0
# 29| 3: [Getter] get_Imaginary
# 29| 4: [Setter] set_Imaginary
#-----| 2: (Parameters)

View File

@@ -2,9 +2,7 @@ csharp6.cs:
# 10| [Class] TestCSharp6
# 12| 6: [Property] Value
# 12| -1: [TypeMention] int
# 15| 2: [AssignExpr] ... = ...
# 12| 0: [PropertyCall] access to property Value
# 15| 1: [IntLiteral] 20
# 15| 2: [IntLiteral] 20
# 14| 3: [Getter] get_Value
# 17| 7: [Method] Fn
# 17| -1: [TypeMention] Void

View File

@@ -35,15 +35,11 @@ csharp72.cs:
# 44| [Class] NumericLiterals
# 46| 5: [Field] binaryValue
# 46| -1: [TypeMention] int
# 46| 1: [AssignExpr] ... = ...
# 46| 0: [FieldAccess] access to field binaryValue
# 46| 1: [IntLiteral] 85
# 46| 1: [IntLiteral] 85
# 49| [Class] PrivateProtected
# 51| 5: [Field] X
# 51| -1: [TypeMention] int
# 51| 1: [AssignExpr] ... = ...
# 51| 0: [FieldAccess] access to field X
# 51| 1: [IntLiteral] 1
# 51| 1: [IntLiteral] 1
# 53| 6: [Method] F
# 53| -1: [TypeMention] Void
# 53| 4: [BlockStmt] {...}

View File

@@ -2,25 +2,17 @@ CSharp7.cs:
# 5| [Class] Literals
# 7| 5: [Field] x
# 7| -1: [TypeMention] int
# 7| 1: [AssignExpr] ... = ...
# 7| 0: [FieldAccess] access to field x
# 7| 1: [IntLiteral] 11
# 7| 1: [IntLiteral] 11
# 8| 6: [Field] y
# 8| -1: [TypeMention] int
# 8| 1: [AssignExpr] ... = ...
# 8| 0: [FieldAccess] access to field y
# 8| 1: [IntLiteral] 123456
# 8| 1: [IntLiteral] 123456
# 9| 7: [Field] z
# 9| -1: [TypeMention] int
# 9| 1: [AssignExpr] ... = ...
# 9| 0: [FieldAccess] access to field z
# 9| 1: [IntLiteral] 128
# 9| 1: [IntLiteral] 128
# 12| [Class] ExpressionBodiedMembers
# 14| 4: [Field] field
# 14| -1: [TypeMention] int
# 14| 1: [AssignExpr] ... = ...
# 14| 0: [FieldAccess] access to field field
# 14| 1: [IntLiteral] 0
# 14| 1: [IntLiteral] 0
# 15| 5: [Method] Foo
# 15| -1: [TypeMention] int
# 15| 4: [FieldAccess] access to field field

View File

@@ -2,18 +2,14 @@ AlternateInterpolatedStrings.cs:
# 3| [Class] AlternateInterpolatedStrings
# 5| 5: [Field] s1
# 5| -1: [TypeMention] string
# 5| 1: [AssignExpr] ... = ...
# 5| 0: [FieldAccess] access to field s1
# 5| 1: [InterpolatedStringExpr] $"..."
# 5| 0: [StringLiteralUtf16] "C:"
# 5| 1: [IntLiteral] 12
# 5| 1: [InterpolatedStringExpr] $"..."
# 5| 0: [StringLiteralUtf16] "C:"
# 5| 1: [IntLiteral] 12
# 6| 6: [Field] s2
# 6| -1: [TypeMention] string
# 6| 1: [AssignExpr] ... = ...
# 6| 0: [FieldAccess] access to field s2
# 6| 1: [InterpolatedStringExpr] $"..."
# 6| 0: [StringLiteralUtf16] "C:"
# 6| 1: [IntLiteral] 12
# 6| 1: [InterpolatedStringExpr] $"..."
# 6| 0: [StringLiteralUtf16] "C:"
# 6| 1: [IntLiteral] 12
AsyncStreams.cs:
# 6| [Class] AsyncStreams
# 8| 5: [Method] Items

View File

@@ -3,10 +3,8 @@ AnonymousObjectCreation.cs:
# 7| 5: [Field] l
# 7| -1: [TypeMention] List<AnonObj>
# 7| 1: [TypeMention] AnonObj
# 7| 1: [AssignExpr] ... = ...
# 7| 0: [FieldAccess] access to field l
# 7| 1: [CastExpr] (...) ...
# 7| 1: [ObjectCreation] object creation of type List<AnonObj>
# 7| 1: [CastExpr] (...) ...
# 7| 1: [ObjectCreation] object creation of type List<AnonObj>
# 9| 6: [Property] Prop1
# 9| -1: [TypeMention] int
# 9| 3: [Getter] get_Prop1
@@ -294,10 +292,8 @@ FunctionPointer.cs:
# 5| 5: [Class] Program
# 7| 5: [Field] pointer
# 7| -1: [TypeMention] delegate* default<Int32>
# 7| 1: [AssignExpr] ... = ...
# 7| 0: [FieldAccess] access to field pointer
# 7| 1: [AddressOfExpr] &...
# 7| 0: [MethodAccess] access to method M0
# 7| 1: [AddressOfExpr] &...
# 7| 0: [MethodAccess] access to method M0
# 9| 6: [Method] M0
# 9| -1: [TypeMention] int
# 10| 4: [BlockStmt] {...}

View File

@@ -12,13 +12,9 @@ definitions.cs:
# 9| 4: [BlockStmt] {...}
# 13| 2: [Enum] Enumeration
# 15| 5: [Field] e1
# 15| 1: [AssignExpr] ... = ...
# 15| 0: [MemberConstantAccess] access to constant e1
# 15| 1: [IntLiteral] 1
# 15| 1: [IntLiteral] 1
# 15| 6: [Field] e2
# 15| 1: [AssignExpr] ... = ...
# 15| 0: [MemberConstantAccess] access to constant e2
# 15| 1: [IntLiteral] 2
# 15| 1: [IntLiteral] 2
# 15| 7: [Field] e3
# 18| 3: [Class] C1
# 20| 4: [InstanceConstructor] C1
@@ -405,14 +401,12 @@ definitions.cs:
# 166| -1: [TypeMention] Nested<I4>
# 166| 1: [TypeMention] C4
# 166| 2: [TypeMention] I4
# 166| 1: [AssignExpr] ... = ...
# 166| 0: [FieldAccess] access to field f
# 166| 1: [MethodCall] call to method Create
# 166| -1: [TypeAccess] access to type Nested<I4>
# 166| -2: [TypeMention] Nested<I4>
# 166| 1: [TypeMention] I4
# 166| -1: [TypeAccess] access to type C4
# 166| 0: [TypeMention] C4
# 166| 1: [MethodCall] call to method Create
# 166| -1: [TypeAccess] access to type Nested<I4>
# 166| -2: [TypeMention] Nested<I4>
# 166| 1: [TypeMention] I4
# 166| -1: [TypeAccess] access to type C4
# 166| 0: [TypeMention] C4
# 167| 6: [Field] c1
# 167| -1: [TypeMention] C1
# 169| 7: [Method] M

View File

@@ -11,35 +11,25 @@ enums.cs:
# 23| 3: [Enum] E
# 25| 4: [Enum] ValueColor
# 28| 5: [Field] OneRed
# 28| 1: [AssignExpr] ... = ...
# 28| 0: [MemberConstantAccess] access to constant OneRed
# 28| 1: [CastExpr] (...) ...
# 28| 1: [IntLiteral] 1
# 28| 1: [CastExpr] (...) ...
# 28| 1: [IntLiteral] 1
# 29| 6: [Field] TwoGreen
# 29| 1: [AssignExpr] ... = ...
# 29| 0: [MemberConstantAccess] access to constant TwoGreen
# 29| 1: [CastExpr] (...) ...
# 29| 1: [IntLiteral] 2
# 29| 1: [CastExpr] (...) ...
# 29| 1: [IntLiteral] 2
# 30| 7: [Field] FourBlue
# 30| 1: [AssignExpr] ... = ...
# 30| 0: [MemberConstantAccess] access to constant FourBlue
# 30| 1: [CastExpr] (...) ...
# 30| 1: [IntLiteral] 4
# 30| 1: [CastExpr] (...) ...
# 30| 1: [IntLiteral] 4
# 34| 5: [Enum] SparseColor
# 37| 5: [Field] Red
# 38| 6: [Field] Green
# 38| 1: [AssignExpr] ... = ...
# 38| 0: [MemberConstantAccess] access to constant Green
# 38| 1: [IntLiteral] 10
# 38| 1: [IntLiteral] 10
# 39| 7: [Field] Blue
# 40| 8: [Field] AnotherBlue
# 40| 1: [AssignExpr] ... = ...
# 40| 0: [MemberConstantAccess] access to constant AnotherBlue
# 40| 1: [AddExpr] ... + ...
# 40| 0: [CastExpr] (...) ...
# 40| 1: [MemberConstantAccess] access to constant Blue
# 40| 1: [CastExpr] (...) ...
# 40| 1: [MemberConstantAccess] access to constant Red
# 40| 1: [AddExpr] ... + ...
# 40| 0: [CastExpr] (...) ...
# 40| 1: [MemberConstantAccess] access to constant Blue
# 40| 1: [CastExpr] (...) ...
# 40| 1: [MemberConstantAccess] access to constant Red
# 44| 6: [Class] Test
# 47| 5: [Method] Main
# 47| -1: [TypeMention] Void

View File

@@ -87,16 +87,12 @@ events.cs:
# 50| 4: [Class] Control
# 53| 6: [Field] mouseDownEventKey
# 53| -1: [TypeMention] object
# 53| 1: [AssignExpr] ... = ...
# 53| 0: [FieldAccess] access to field mouseDownEventKey
# 53| 1: [ObjectCreation] object creation of type Object
# 53| 0: [TypeMention] object
# 53| 1: [ObjectCreation] object creation of type Object
# 53| 0: [TypeMention] object
# 54| 7: [Field] mouseUpEventKey
# 54| -1: [TypeMention] object
# 54| 1: [AssignExpr] ... = ...
# 54| 0: [FieldAccess] access to field mouseUpEventKey
# 54| 1: [ObjectCreation] object creation of type Object
# 54| 0: [TypeMention] object
# 54| 1: [ObjectCreation] object creation of type Object
# 54| 0: [TypeMention] object
# 57| 8: [Method] GetEventHandler
# 57| -1: [TypeMention] Delegate
#-----| 2: (Parameters)

View File

@@ -417,12 +417,10 @@ ReducedExpression.cs:
# 2| [Class] ReducedClass
# 5| 5: [Field] ReducedExpression
# 5| -1: [TypeMention] int
# 5| 1: [AssignExpr] ... = ...
# 5| 0: [MemberConstantAccess] access to constant ReducedExpression
# 5| 1: [ConditionalExpr] ... ? ... : ...
# 5| 0: [BoolLiteral] true
# 5| 1: [IntLiteral] 10
# 5| 2: [IntLiteral] 12
# 5| 1: [ConditionalExpr] ... ? ... : ...
# 5| 0: [BoolLiteral] true
# 5| 1: [IntLiteral] 10
# 5| 2: [IntLiteral] 12
expressions.cs:
# 5| [NamespaceDeclaration] namespace ... { ... }
# 7| 1: [Class] Class
@@ -550,14 +548,10 @@ expressions.cs:
# 41| 0: [LocalVariableAccess] access to local variable c
# 44| 6: [Field] constant
# 44| -1: [TypeMention] string
# 44| 1: [AssignExpr] ... = ...
# 44| 0: [MemberConstantAccess] access to constant constant
# 44| 1: [StringLiteralUtf16] "constant"
# 44| 1: [StringLiteralUtf16] "constant"
# 45| 7: [Field] f
# 45| -1: [TypeMention] int
# 45| 1: [AssignExpr] ... = ...
# 45| 0: [FieldAccess] access to field f
# 45| 1: [IntLiteral] 0
# 45| 1: [IntLiteral] 0
# 46| 8: [Field] name
# 46| -1: [TypeMention] string
# 48| 9: [StaticConstructor] Class
@@ -1492,16 +1486,12 @@ expressions.cs:
# 361| 15: [Class] Rectangle2
# 364| 5: [Field] p1
# 364| -1: [TypeMention] Point
# 364| 1: [AssignExpr] ... = ...
# 364| 0: [FieldAccess] access to field p1
# 364| 1: [ObjectCreation] object creation of type Point
# 364| 0: [TypeMention] Point
# 364| 1: [ObjectCreation] object creation of type Point
# 364| 0: [TypeMention] Point
# 365| 6: [Field] p2
# 365| -1: [TypeMention] Point
# 365| 1: [AssignExpr] ... = ...
# 365| 0: [FieldAccess] access to field p2
# 365| 1: [ObjectCreation] object creation of type Point
# 365| 0: [TypeMention] Point
# 365| 1: [ObjectCreation] object creation of type Point
# 365| 0: [TypeMention] Point
# 367| 7: [Property] P1
# 367| -1: [TypeMention] Point
# 367| 3: [Getter] get_P1
@@ -1520,11 +1510,9 @@ expressions.cs:
# 376| 6: [Field] phoneNumbers
# 376| -1: [TypeMention] List<string>
# 376| 1: [TypeMention] string
# 376| 1: [AssignExpr] ... = ...
# 376| 0: [FieldAccess] access to field phoneNumbers
# 376| 1: [ObjectCreation] object creation of type List<String>
# 376| 0: [TypeMention] List<string>
# 376| 1: [TypeMention] string
# 376| 1: [ObjectCreation] object creation of type List<String>
# 376| 0: [TypeMention] List<string>
# 376| 1: [TypeMention] string
# 378| 7: [Property] Name
# 378| -1: [TypeMention] string
# 378| 3: [Getter] get_Name
@@ -2194,9 +2182,8 @@ expressions.cs:
# 495| 19: [Class] ExpressionDepth
# 497| 5: [Field] d
# 497| -1: [TypeMention] int
# 497| 1: [AssignExpr] ... = ...
# 497| 0: [MemberConstantAccess] access to constant d
# 497| 1: [AddExpr] ... + ...
# 497| 1: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
@@ -2274,9 +2261,7 @@ expressions.cs:
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [AddExpr] ... + ...
# 497| 0: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 497| 0: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
@@ -2315,7 +2300,7 @@ expressions.cs:
# 497| 1: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 497| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
@@ -2355,6 +2340,7 @@ expressions.cs:
# 498| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 498| 1: [IntLiteral] 1
# 501| 20: [Class] TupleExprs
# 503| 5: [Method] Test
# 503| -1: [TypeMention] Void

View File

@@ -3,37 +3,27 @@ fields.cs:
# 7| 1: [Class] A
# 10| 6: [Field] X
# 10| -1: [TypeMention] int
# 10| 1: [AssignExpr] ... = ...
# 10| 0: [FieldAccess] access to field X
# 10| 1: [IntLiteral] 1
# 10| 1: [IntLiteral] 1
# 10| 7: [Field] Y
# 10| -1: [TypeMention] int
# 10| 8: [Field] Z
# 10| -1: [TypeMention] int
# 10| 1: [AssignExpr] ... = ...
# 10| 0: [FieldAccess] access to field Z
# 10| 1: [IntLiteral] 100
# 10| 1: [IntLiteral] 100
# 13| 2: [Class] B
# 15| 6: [Field] X
# 15| -1: [TypeMention] int
# 15| 1: [AssignExpr] ... = ...
# 15| 0: [FieldAccess] access to field X
# 15| 1: [IntLiteral] 1
# 15| 1: [IntLiteral] 1
# 16| 7: [Field] Y
# 16| -1: [TypeMention] int
# 17| 8: [Field] Z
# 17| -1: [TypeMention] int
# 17| 1: [AssignExpr] ... = ...
# 17| 0: [FieldAccess] access to field Z
# 17| 1: [IntLiteral] 100
# 17| 1: [IntLiteral] 100
# 20| 3: [Class] C`1
#-----| 1: (Type parameters)
# 20| 0: [TypeParameter] V
# 23| 5: [Field] count
# 23| -1: [TypeMention] int
# 23| 1: [AssignExpr] ... = ...
# 23| 0: [FieldAccess] access to field count
# 23| 1: [IntLiteral] 0
# 23| 1: [IntLiteral] 0
# 25| 6: [InstanceConstructor] C
# 25| 4: [BlockStmt] {...}
# 25| 0: [ExprStmt] ...;
@@ -50,22 +40,16 @@ fields.cs:
# 34| -1: [TypeMention] bool
# 35| 7: [Field] x
# 35| -1: [TypeMention] double
# 35| 1: [AssignExpr] ... = ...
# 35| 0: [FieldAccess] access to field x
# 35| 1: [MethodCall] call to method Sqrt
# 35| -1: [TypeAccess] access to type Math
# 35| 0: [TypeMention] Math
# 35| 0: [DoubleLiteral] 2
# 35| 1: [MethodCall] call to method Sqrt
# 35| -1: [TypeAccess] access to type Math
# 35| 0: [TypeMention] Math
# 35| 0: [DoubleLiteral] 2
# 36| 8: [Field] i
# 36| -1: [TypeMention] int
# 36| 1: [AssignExpr] ... = ...
# 36| 0: [FieldAccess] access to field i
# 36| 1: [IntLiteral] 100
# 36| 1: [IntLiteral] 100
# 37| 9: [Field] s
# 37| -1: [TypeMention] string
# 37| 1: [AssignExpr] ... = ...
# 37| 0: [FieldAccess] access to field s
# 37| 1: [StringLiteralUtf16] "Hello"
# 37| 1: [StringLiteralUtf16] "Hello"
# 39| 10: [Method] Main
# 39| -1: [TypeMention] Void
# 40| 4: [BlockStmt] {...}
@@ -111,28 +95,24 @@ fields.cs:
# 50| 5: [Class] Color
# 53| 5: [Field] Black
# 53| -1: [TypeMention] Color
# 53| 1: [AssignExpr] ... = ...
# 53| 0: [FieldAccess] access to field Black
# 53| 1: [ObjectCreation] object creation of type Color
# 53| -1: [TypeMention] Color
# 53| 0: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 53| 1: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 53| 2: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 53| 1: [ObjectCreation] object creation of type Color
# 53| -1: [TypeMention] Color
# 53| 0: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 53| 1: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 53| 2: [CastExpr] (...) ...
# 53| 1: [IntLiteral] 0
# 54| 6: [Field] White
# 54| -1: [TypeMention] Color
# 54| 1: [AssignExpr] ... = ...
# 54| 0: [FieldAccess] access to field White
# 54| 1: [ObjectCreation] object creation of type Color
# 54| -1: [TypeMention] Color
# 54| 0: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 54| 1: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 54| 2: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 54| 1: [ObjectCreation] object creation of type Color
# 54| -1: [TypeMention] Color
# 54| 0: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 54| 1: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 54| 2: [CastExpr] (...) ...
# 54| 1: [IntLiteral] 255
# 56| 7: [InstanceConstructor] Color
#-----| 2: (Parameters)
# 56| 0: [Parameter] r
@@ -145,50 +125,38 @@ fields.cs:
# 60| 6: [Class] TestBindings
# 63| 6: [Field] a
# 63| -1: [TypeMention] int
# 63| 1: [AssignExpr] ... = ...
# 63| 0: [FieldAccess] access to field a
# 63| 1: [AddExpr] ... + ...
# 63| 0: [FieldAccess] access to field b
# 63| 1: [IntLiteral] 1
# 63| 1: [AddExpr] ... + ...
# 63| 0: [FieldAccess] access to field b
# 63| 1: [IntLiteral] 1
# 64| 7: [Field] b
# 64| -1: [TypeMention] int
# 64| 1: [AssignExpr] ... = ...
# 64| 0: [FieldAccess] access to field b
# 64| 1: [AddExpr] ... + ...
# 64| 0: [FieldAccess] access to field a
# 64| 1: [IntLiteral] 1
# 64| 1: [AddExpr] ... + ...
# 64| 0: [FieldAccess] access to field a
# 64| 1: [IntLiteral] 1
# 70| [NamespaceDeclaration] namespace ... { ... }
# 72| 1: [Class] A
# 74| 5: [Field] X
# 74| -1: [TypeMention] int
# 74| 1: [AssignExpr] ... = ...
# 74| 0: [MemberConstantAccess] access to constant X
# 74| 1: [AddExpr] ... + ...
# 74| 0: [MemberConstantAccess] access to constant Z
# 74| -1: [TypeAccess] access to type B
# 74| 0: [TypeMention] B
# 74| 1: [IntLiteral] 1
# 74| 1: [AddExpr] ... + ...
# 74| 0: [MemberConstantAccess] access to constant Z
# 74| -1: [TypeAccess] access to type B
# 74| 0: [TypeMention] B
# 74| 1: [IntLiteral] 1
# 75| 6: [Field] Y
# 75| -1: [TypeMention] int
# 75| 1: [AssignExpr] ... = ...
# 75| 0: [MemberConstantAccess] access to constant Y
# 75| 1: [IntLiteral] 10
# 75| 1: [IntLiteral] 10
# 78| 2: [Class] B
# 80| 5: [Field] Z
# 80| -1: [TypeMention] int
# 80| 1: [AssignExpr] ... = ...
# 80| 0: [MemberConstantAccess] access to constant Z
# 80| 1: [AddExpr] ... + ...
# 80| 0: [MemberConstantAccess] access to constant Y
# 80| -1: [TypeAccess] access to type A
# 80| 0: [TypeMention] A
# 80| 1: [IntLiteral] 1
# 80| 1: [AddExpr] ... + ...
# 80| 0: [MemberConstantAccess] access to constant Y
# 80| -1: [TypeAccess] access to type A
# 80| 0: [TypeMention] A
# 80| 1: [IntLiteral] 1
# 83| 3: [Class] C
# 85| 4: [Field] Foo
# 85| -1: [TypeMention] int
# 85| 1: [AssignExpr] ... = ...
# 85| 0: [MemberConstantAccess] access to constant Foo
# 85| 1: [IntLiteral] 1
# 85| 1: [IntLiteral] 1
# 86| 5: [Field] x
# 86| -1: [TypeMention] long?
# 86| 1: [TypeMention] long

View File

@@ -370,24 +370,18 @@ generics.cs:
# 60| 0: [TypeParameter] T
# 63| 5: [Field] NumRows
# 63| -1: [TypeMention] int
# 63| 1: [AssignExpr] ... = ...
# 63| 0: [MemberConstantAccess] access to constant NumRows
# 63| 1: [IntLiteral] 26
# 63| 1: [IntLiteral] 26
# 64| 6: [Field] NumCols
# 64| -1: [TypeMention] int
# 64| 1: [AssignExpr] ... = ...
# 64| 0: [MemberConstantAccess] access to constant NumCols
# 64| 1: [IntLiteral] 10
# 64| 1: [IntLiteral] 10
# 66| 7: [Field] cells
# 66| -1: [TypeMention] T[,]
# 66| 1: [TypeMention] T
# 66| 1: [AssignExpr] ... = ...
# 66| 0: [FieldAccess] access to field cells
# 66| 1: [ArrayCreation] array creation of type T[,]
# 66| -1: [TypeMention] T[,]
# 66| 1: [TypeMention] T
# 66| 0: [MemberConstantAccess] access to constant NumRows
# 66| 1: [MemberConstantAccess] access to constant NumCols
# 66| 1: [ArrayCreation] array creation of type T[,]
# 66| -1: [TypeMention] T[,]
# 66| 1: [TypeMention] T
# 66| 0: [MemberConstantAccess] access to constant NumRows
# 66| 1: [MemberConstantAccess] access to constant NumCols
# 68| 8: [Indexer] Item
# 68| -1: [TypeMention] int
#-----| 1: (Parameters)

View File

@@ -214,24 +214,18 @@ indexers.cs:
# 81| 3: [Class] Grid
# 84| 5: [Field] NumRows
# 84| -1: [TypeMention] int
# 84| 1: [AssignExpr] ... = ...
# 84| 0: [MemberConstantAccess] access to constant NumRows
# 84| 1: [IntLiteral] 26
# 84| 1: [IntLiteral] 26
# 85| 6: [Field] NumCols
# 85| -1: [TypeMention] int
# 85| 1: [AssignExpr] ... = ...
# 85| 0: [MemberConstantAccess] access to constant NumCols
# 85| 1: [IntLiteral] 10
# 85| 1: [IntLiteral] 10
# 87| 7: [Field] cells
# 87| -1: [TypeMention] Int32[,]
# 87| 1: [TypeMention] int
# 87| 1: [AssignExpr] ... = ...
# 87| 0: [FieldAccess] access to field cells
# 87| 1: [ArrayCreation] array creation of type Int32[,]
# 87| -1: [TypeMention] Int32[,]
# 87| 1: [TypeMention] int
# 87| 0: [MemberConstantAccess] access to constant NumRows
# 87| 1: [MemberConstantAccess] access to constant NumCols
# 87| 1: [ArrayCreation] array creation of type Int32[,]
# 87| -1: [TypeMention] Int32[,]
# 87| 1: [TypeMention] int
# 87| 0: [MemberConstantAccess] access to constant NumRows
# 87| 1: [MemberConstantAccess] access to constant NumCols
# 89| 8: [Indexer] Item
# 89| -1: [TypeMention] int
#-----| 1: (Parameters)