mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Remove the tuples from the C# extractor.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
@@ -30,10 +31,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public new Accessor OriginalDefinition => Create(Context, symbol.OriginalDefinition);
|
||||
|
||||
public override void Populate(System.IO.TextWriter trapFile)
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
ContainingType.ExtractGenerics();
|
||||
|
||||
var prop = PropertySymbol;
|
||||
@@ -62,16 +63,16 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.accessors(this, kind, symbol.Name, parent, unboundAccessor));
|
||||
trapFile.accessors(this, kind, symbol.Name, parent, unboundAccessor);
|
||||
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.accessor_location(this, l));
|
||||
trapFile.accessor_location(this, l);
|
||||
|
||||
Overrides(trapFile);
|
||||
|
||||
if (symbol.FromSource() && Block == null)
|
||||
{
|
||||
trapFile.Emit(Tuples.compiler_generated(this));
|
||||
trapFile.compiler_generated(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
void ExtractAttribute(System.IO.TextWriter trapFile, AttributeSyntax syntax, ITypeSymbol attributeClass, IEntity entity)
|
||||
{
|
||||
var type = Type.Create(cx, attributeClass);
|
||||
trapFile.Emit(Tuples.attributes(this, type.TypeRef, entity));
|
||||
trapFile.attributes(this, type.TypeRef, entity);
|
||||
|
||||
trapFile.Emit(Tuples.attribute_location(this, cx.Create(syntax.Name.GetLocation())));
|
||||
trapFile.attribute_location(this, cx.Create(syntax.Name.GetLocation()));
|
||||
|
||||
if (cx.Extractor.OutputPath != null)
|
||||
trapFile.Emit(Tuples.attribute_location(this, Assembly.CreateOutputAssembly(cx)));
|
||||
trapFile.attribute_location(this, Assembly.CreateOutputAssembly(cx));
|
||||
|
||||
TypeMention.Create(cx, syntax.Name, this, type);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
var expr = Expression.Create(cx, arg.Expression, this, child++);
|
||||
if (!(arg.NameEquals is null))
|
||||
{
|
||||
trapFile.Emit(Tuples.expr_argument_name(expr, arg.NameEquals.Name.Identifier.Text));
|
||||
trapFile.expr_argument_name(expr, arg.NameEquals.Name.Identifier.Text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.commentblock(this));
|
||||
trapFile.commentblock(this);
|
||||
int child = 0;
|
||||
trapFile.Emit(Tuples.commentblock_location(this, Context.Create(symbol.Location)));
|
||||
trapFile.commentblock_location(this, Context.Create(symbol.Location));
|
||||
foreach (var l in symbol.CommentLines)
|
||||
{
|
||||
trapFile.Emit(Tuples.commentblock_child(this, (CommentLine)l, child++));
|
||||
trapFile.commentblock_child(this, (CommentLine)l, child++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public void BindTo(Label entity, CommentBinding binding)
|
||||
{
|
||||
Context.TrapWriter.Writer.Emit(Tuples.commentblock_binding(this, entity, binding));
|
||||
Context.TrapWriter.Writer.commentblock_binding(this, entity, binding);
|
||||
}
|
||||
|
||||
public static CommentBlock Create(Context cx, ICommentBlock block) => CommentBlockFactory.Instance.CreateEntity(cx, block);
|
||||
|
||||
@@ -115,8 +115,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
location = Context.Create(Location);
|
||||
trapFile.Emit(Tuples.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText));
|
||||
trapFile.Emit(Tuples.commentline_location(this, location));
|
||||
trapFile.commentline(this, Type == CommentLineType.MultilineContinuation ? CommentLineType.Multiline : Type, Text, RawText);
|
||||
trapFile.commentline_location(this, location);
|
||||
}
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location ReportingLocation => location.symbol;
|
||||
|
||||
@@ -22,34 +22,34 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
Extraction.Entities.Assembly.CreateOutputAssembly(cx);
|
||||
|
||||
trapFile.Emit(Tuples.compilations(this, Extraction.Entities.File.PathAsDatabaseString(cwd)));
|
||||
trapFile.compilations(this, Extraction.Entities.File.PathAsDatabaseString(cwd));
|
||||
|
||||
// Arguments
|
||||
int index = 0;
|
||||
foreach(var arg in args)
|
||||
{
|
||||
trapFile.Emit(Tuples.compilation_args(this, index++, arg));
|
||||
trapFile.compilation_args(this, index++, arg);
|
||||
}
|
||||
|
||||
// Files
|
||||
index = 0;
|
||||
foreach(var file in cx.Compilation.SyntaxTrees.Select(tree => Extraction.Entities.File.Create(cx, tree.FilePath)))
|
||||
{
|
||||
trapFile.Emit(Tuples.compilation_compiling_files(this, index++, file));
|
||||
trapFile.compilation_compiling_files(this, index++, file);
|
||||
}
|
||||
|
||||
// References
|
||||
index = 0;
|
||||
foreach(var file in cx.Compilation.References.OfType<PortableExecutableReference>().Select(r => Extraction.Entities.File.Create(cx, r.FilePath)))
|
||||
{
|
||||
trapFile.Emit(Tuples.compilation_referencing_files(this, index++, file));
|
||||
trapFile.compilation_referencing_files(this, index++, file);
|
||||
}
|
||||
|
||||
// Diagnostics
|
||||
index = 0;
|
||||
foreach(var diag in cx.Compilation.GetDiagnostics().Select(d => new Diagnostic(cx, d)))
|
||||
{
|
||||
trapFile.Emit(Tuples.diagnostic_for(diag, this, 0, index++));
|
||||
trapFile.diagnostic_for(diag, this, 0, index++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
int index = 0;
|
||||
foreach(float metric in p.Metrics)
|
||||
{
|
||||
trapFile.Emit(Tuples.compilation_time(this, -1, index++, metric));
|
||||
trapFile.compilation_time(this, -1, index++, metric);
|
||||
}
|
||||
trapFile.Emit(Tuples.compilation_finished(this, (float)p.Total.Cpu.TotalSeconds, (float)p.Total.Elapsed.TotalSeconds));
|
||||
trapFile.compilation_finished(this, (float)p.Total.Cpu.TotalSeconds, (float)p.Total.Elapsed.TotalSeconds);
|
||||
}
|
||||
|
||||
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
|
||||
@@ -81,8 +81,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.diagnostics(this, (int)diagnostic.Severity, diagnostic.Id, diagnostic.Descriptor.Title.ToString(),
|
||||
diagnostic.GetMessage(), Extraction.Entities.Location.Create(cx, diagnostic.Location)));
|
||||
trapFile.diagnostics(this, (int)diagnostic.Severity, diagnostic.Id, diagnostic.Descriptor.Title.ToString(),
|
||||
diagnostic.GetMessage(), Extraction.Entities.Location.Create(cx, diagnostic.Location));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,16 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
ContainingType.ExtractGenerics();
|
||||
|
||||
trapFile.Emit(Tuples.constructors(this, symbol.ContainingType.Name, ContainingType, (Constructor)OriginalDefinition));
|
||||
trapFile.Emit(Tuples.constructor_location(this, Location));
|
||||
trapFile.constructors(this, symbol.ContainingType.Name, ContainingType, (Constructor)OriginalDefinition);
|
||||
trapFile.constructor_location(this, Location);
|
||||
|
||||
if (symbol.IsImplicitlyDeclared)
|
||||
{
|
||||
var lineCounts = new LineCounts() { Total = 2, Code = 1, Comment = 0 };
|
||||
trapFile.Emit(Tuples.numlines(this, lineCounts));
|
||||
trapFile.numlines(this, lineCounts);
|
||||
}
|
||||
ExtractCompilerGenerated(trapFile);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.expr_call(init, target));
|
||||
trapFile.expr_call(init, target);
|
||||
|
||||
int child = 0;
|
||||
foreach (var arg in initializer.ArgumentList.Arguments)
|
||||
|
||||
@@ -11,11 +11,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
ContainingType.ExtractGenerics();
|
||||
|
||||
trapFile.Emit(Tuples.destructors(this, string.Format("~{0}", symbol.ContainingType.Name), ContainingType, OriginalDefinition(Context, this, symbol)));
|
||||
trapFile.Emit(Tuples.destructor_location(this, Location));
|
||||
trapFile.destructors(this, string.Format("~{0}", symbol.ContainingType.Name), ContainingType, OriginalDefinition(Context, this, symbol));
|
||||
trapFile.destructor_location(this, Location);
|
||||
}
|
||||
|
||||
static new Destructor OriginalDefinition(Context cx, Destructor original, IMethodSymbol symbol)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExtractNullability(trapFile, symbol.NullableAnnotation);
|
||||
|
||||
var type = Type.Create(Context, symbol.Type);
|
||||
Context.Emit(Tuples.events(this, symbol.GetName(), ContainingType, type.TypeRef, Create(Context, symbol.OriginalDefinition)));
|
||||
trapFile.events(this, symbol.GetName(), ContainingType, type.TypeRef, Create(Context, symbol.OriginalDefinition));
|
||||
|
||||
var adder = symbol.AddMethod;
|
||||
var remover = symbol.RemoveMethod;
|
||||
@@ -35,7 +35,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (!(remover is null))
|
||||
Method.Create(Context, remover);
|
||||
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
BindComments();
|
||||
|
||||
var declSyntaxReferences = IsSourceDeclaration
|
||||
@@ -44,14 +44,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations.Select(impl => Type.Create(Context, impl.ContainingType)))
|
||||
{
|
||||
trapFile.Emit(Tuples.explicitly_implements(this, explicitInterface.TypeRef));
|
||||
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
|
||||
|
||||
foreach (var syntax in declSyntaxReferences.OfType<EventDeclarationSyntax>())
|
||||
TypeMention.Create(Context, syntax.ExplicitInterfaceSpecifier.Name, this, explicitInterface);
|
||||
}
|
||||
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.event_location(this, l));
|
||||
trapFile.event_location(this, l);
|
||||
|
||||
foreach (var syntaxType in declSyntaxReferences.OfType<VariableDeclaratorSyntax>().
|
||||
Select(d => d.Parent).
|
||||
|
||||
@@ -44,10 +44,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.event_accessors(this, kind, symbol.Name, parent, unboundAccessor));
|
||||
trapFile.event_accessors(this, kind, symbol.Name, parent, unboundAccessor);
|
||||
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.event_accessor_location(this, l));
|
||||
trapFile.event_accessor_location(this, l);
|
||||
|
||||
Overrides(trapFile);
|
||||
}
|
||||
|
||||
@@ -39,18 +39,18 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected sealed override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.expressions(this, Kind, Type.Type.TypeRef));
|
||||
trapFile.expressions(this, Kind, Type.Type.TypeRef);
|
||||
if (Info.Parent.IsTopLevelParent)
|
||||
trapFile.Emit(Tuples.expr_parent_top_level(this, Info.Child, Info.Parent));
|
||||
trapFile.expr_parent_top_level(this, Info.Child, Info.Parent);
|
||||
else
|
||||
trapFile.Emit(Tuples.expr_parent(this, Info.Child, Info.Parent));
|
||||
trapFile.Emit(Tuples.expr_location(this, Location));
|
||||
trapFile.expr_parent(this, Info.Child, Info.Parent);
|
||||
trapFile.expr_location(this, Location);
|
||||
|
||||
if (Info.IsCompilerGenerated)
|
||||
trapFile.Emit(Tuples.expr_compiler_generated(this));
|
||||
trapFile.expr_compiler_generated(this);
|
||||
|
||||
if (Info.ExprValue is string value)
|
||||
cx.Emit(Tuples.expr_value(this, value));
|
||||
trapFile.expr_value(this, value);
|
||||
|
||||
Type.Type.ExtractGenerics();
|
||||
}
|
||||
@@ -133,11 +133,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (callType == CallType.Dynamic)
|
||||
{
|
||||
UserOperator.OperatorSymbol(method.Name, out string operatorName);
|
||||
trapFile.Emit(Tuples.dynamic_member_name(this, operatorName));
|
||||
trapFile.dynamic_member_name(this, operatorName);
|
||||
return;
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.expr_call(this, Method.Create(cx, method)));
|
||||
trapFile.expr_call(this, Method.Create(cx, method));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public void MakeConditional(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.conditional_access(this));
|
||||
trapFile.conditional_access(this);
|
||||
}
|
||||
|
||||
public void PopulateArguments(TextWriter trapFile, BaseArgumentListSyntax args, int child)
|
||||
@@ -241,11 +241,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
default:
|
||||
throw new InternalError(arg, "Unknown argument type");
|
||||
}
|
||||
trapFile.Emit(Tuples.expr_argument(expr, mode));
|
||||
trapFile.expr_argument(expr, mode);
|
||||
|
||||
if (arg.NameColon != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.expr_argument_name(expr, arg.NameColon.Name.Identifier.Text));
|
||||
trapFile.expr_argument_name(expr, arg.NameColon.Name.Identifier.Text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
Access(ExpressionNodeInfo info, ISymbol symbol, bool implicitThis, IEntity target)
|
||||
: base(info.SetKind(AccessKind(info.Context, symbol)))
|
||||
{
|
||||
cx.Emit(Tuples.expr_access(this, target));
|
||||
cx.TrapWriter.Writer.expr_access(this, target);
|
||||
|
||||
if (implicitThis && !symbol.IsStatic)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
|
||||
if (explicitlySized)
|
||||
cx.Emit(Tuples.explicitly_sized_array_creation(this));
|
||||
trapFile.explicitly_sized_array_creation(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
ArrayInitializer.Create(new ExpressionNodeInfo(cx, Syntax.Initializer, this, -1));
|
||||
}
|
||||
|
||||
cx.Emit(Tuples.implicitly_typed_array_creation(this));
|
||||
trapFile.implicitly_typed_array_creation(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
var indexer = symbolInfo.Symbol as IPropertySymbol;
|
||||
if (indexer != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.expr_access(this, Indexer.Create(cx, indexer)));
|
||||
trapFile.expr_access(this, Indexer.Create(cx, indexer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.CSharp.Populators;
|
||||
using Semmle.Extraction.Kinds;
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
var target = Method.Create(cx, method);
|
||||
if (target != null)
|
||||
cx.Emit(Tuples.expr_call(this, target));
|
||||
cx.TrapWriter.Writer.expr_call(this, target);
|
||||
else
|
||||
cx.ModelError(info.Node, "Failed to resolve target for operator invocation");
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
protected override void PopulateExpression(TextWriter trapFile)
|
||||
{
|
||||
ArrayInitializer.Create(new ExpressionNodeInfo(cx, Syntax, this, -1));
|
||||
trapFile.Emit(Tuples.implicitly_typed_array_creation(this));
|
||||
trapFile.implicitly_typed_array_creation(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.Create(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
|
||||
|
||||
if (addMethod != null)
|
||||
trapFile.Emit(Tuples.expr_call(invocation, addMethod));
|
||||
trapFile.expr_call(invocation, addMethod);
|
||||
else
|
||||
cx.ModelError(Syntax, "Unable to find an Add() method for collection initializer");
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if (isDynamicCall)
|
||||
{
|
||||
if (memberName != null)
|
||||
trapFile.Emit(Tuples.dynamic_member_name(this, memberName));
|
||||
trapFile.dynamic_member_name(this, memberName);
|
||||
else
|
||||
cx.ModelError(Syntax, "Unable to get name for dynamic call.");
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
|
||||
var targetKey = Method.Create(cx, target);
|
||||
cx.Emit(Tuples.expr_call(this, targetKey));
|
||||
trapFile.expr_call(this, targetKey);
|
||||
}
|
||||
|
||||
static bool IsDynamicCall(ExpressionNodeInfo info)
|
||||
|
||||
@@ -73,10 +73,11 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
base(new ExpressionInfo(cx, Entities.NullType.Create(cx), cx.Create(pp.GetLocation()), ExprKind.PROPERTY_PATTERN, parent, child, false, null))
|
||||
{
|
||||
child = 0;
|
||||
var trapFile = cx.TrapWriter.Writer;
|
||||
foreach (var sub in pp.Subpatterns)
|
||||
{
|
||||
var p = cx.CreatePattern(sub.Pattern, this, child++);
|
||||
cx.Emit(Tuples.exprorstmt_name(p, sub.NameColon.Name.ToString()));
|
||||
trapFile.exprorstmt_name(p, sub.NameColon.Name.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,11 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
class MemberAccess : Expression
|
||||
{
|
||||
readonly IEntity Target;
|
||||
|
||||
private MemberAccess(ExpressionNodeInfo info, ExpressionSyntax qualifier, ISymbol target) : base(info)
|
||||
{
|
||||
var trapFile = info.Context.TrapWriter.Writer;
|
||||
Qualifier = Create(cx, qualifier, this, -1);
|
||||
|
||||
if (target == null)
|
||||
@@ -19,7 +22,8 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
}
|
||||
else
|
||||
{
|
||||
cx.Emit(Tuples.expr_access(this, cx.CreateEntity(target)));
|
||||
Target = cx.CreateEntity(target);
|
||||
trapFile.expr_access(this, Target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +47,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if (IsDynamic(info.Context, expression))
|
||||
{
|
||||
var expr = new MemberAccess(info.SetKind(ExprKind.DYNAMIC_MEMBER_ACCESS), expression, null);
|
||||
info.Context.Emit(Tuples.dynamic_member_name(expr, name.Identifier.Text));
|
||||
info.Context.TrapWriter.Writer.dynamic_member_name(expr, name.Identifier.Text);
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,14 +46,14 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.expr_call(this, Method.Create(cx, method)));
|
||||
trapFile.expr_call(this, Method.Create(cx, method));
|
||||
}
|
||||
|
||||
if (IsDynamicObjectCreation(cx, Syntax))
|
||||
{
|
||||
var name = GetDynamicName(Syntax.Type);
|
||||
if (name.HasValue)
|
||||
trapFile.Emit(Tuples.dynamic_member_name(this, name.Value.Text));
|
||||
trapFile.dynamic_member_name(this, name.Value.Text);
|
||||
else
|
||||
cx.ModelError(Syntax, "Unable to get name for dynamic object creation.");
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.expr_call(this, Method.Create(cx, method)));
|
||||
trapFile.expr_call(this, Method.Create(cx, method));
|
||||
}
|
||||
var child = 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
Property.Create(cx, property);
|
||||
|
||||
var access = new Expression(new ExpressionInfo(cx, type, loc, ExprKind.PROPERTY_ACCESS, assignment, 1, false, null));
|
||||
trapFile.Emit(Tuples.expr_access(access, propEntity));
|
||||
trapFile.expr_access(access, propEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if ((OperatorKind == ExprKind.POST_INCR || OperatorKind == ExprKind.POST_DECR) &&
|
||||
Kind == ExprKind.OPERATOR_INVOCATION)
|
||||
{
|
||||
trapFile.Emit(Tuples.mutator_invocation_mode(this, 2));
|
||||
trapFile.mutator_invocation_mode(this, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
ExprKind.METHOD_INVOCATION, parent, child, false, null))
|
||||
{
|
||||
if (method != null)
|
||||
cx.Emit(Tuples.expr_call(this, Method.Create(cx, method)));
|
||||
cx.TrapWriter.Writer.expr_call(this, Method.Create(cx, method));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
Expression.Create(cx, Expr, decl, 0);
|
||||
|
||||
var access = new Expression(new ExpressionInfo(cx, type, nameLoc, ExprKind.LOCAL_VARIABLE_ACCESS, decl, 1, false, null));
|
||||
cx.Emit(Tuples.expr_access(access, LocalVariable.GetAlreadyCreated(cx, variableSymbol)));
|
||||
cx.TrapWriter.Writer.expr_access(access, LocalVariable.GetAlreadyCreated(cx, variableSymbol));
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if ((OperatorKind == ExprKind.PRE_INCR || OperatorKind == ExprKind.PRE_DECR) &&
|
||||
Kind == ExprKind.OPERATOR_INVOCATION)
|
||||
{
|
||||
trapFile.Emit(Tuples.mutator_invocation_mode(this, 1));
|
||||
trapFile.mutator_invocation_mode(this, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
// Create an access
|
||||
var access = new Expression(new ExpressionInfo(cx, type, location, ExprKind.LOCAL_VARIABLE_ACCESS, ret, 1, false, null));
|
||||
cx.Emit(Tuples.expr_access(access, localVar));
|
||||
cx.TrapWriter.Writer.expr_access(access, localVar);
|
||||
}
|
||||
|
||||
var decl = d.Parent as VariableDeclarationSyntax;
|
||||
|
||||
@@ -33,25 +33,25 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExtractNullability(trapFile, symbol.NullableAnnotation);
|
||||
|
||||
Field unboundFieldKey = Field.Create(Context, symbol.OriginalDefinition);
|
||||
trapFile.Emit(Tuples.fields(this, (symbol.IsConst ? 2 : 1), symbol.Name, ContainingType, Type.Type.TypeRef, unboundFieldKey));
|
||||
trapFile.fields(this, (symbol.IsConst ? 2 : 1), symbol.Name, ContainingType, Type.Type.TypeRef, unboundFieldKey);
|
||||
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
|
||||
if (symbol.IsVolatile)
|
||||
Modifier.HasModifier(Context, this, "volatile");
|
||||
Modifier.HasModifier(Context, trapFile, this, "volatile");
|
||||
|
||||
if (symbol.IsConst)
|
||||
{
|
||||
Modifier.HasModifier(Context, this, "const");
|
||||
Modifier.HasModifier(Context, trapFile, this, "const");
|
||||
|
||||
if (symbol.HasConstantValue)
|
||||
{
|
||||
trapFile.Emit(Tuples.constant_value(this, Expression.ValueAsString(symbol.ConstantValue)));
|
||||
trapFile.constant_value(this, Expression.ValueAsString(symbol.ConstantValue));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.field_location(this, l));
|
||||
trapFile.field_location(this, l);
|
||||
|
||||
if (!IsSourceDeclaration || !symbol.FromSource())
|
||||
return;
|
||||
@@ -86,7 +86,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
// Mark fields that have explicit initializers.
|
||||
var expr = new Expression(new ExpressionInfo(Context, Type, Context.Create(initializer.EqualsValue.Value.FixedLocation()), Kinds.ExprKind.FIELD_ACCESS, this, child++, false, null));
|
||||
trapFile.Emit(Tuples.expr_access(expr, this));
|
||||
trapFile.expr_access(expr, this);
|
||||
}
|
||||
|
||||
if (IsSourceDeclaration)
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExtractNullability(trapFile, symbol.NullableAnnotation);
|
||||
|
||||
var type = Type.Create(Context, symbol.Type);
|
||||
trapFile.Emit(Tuples.indexers(this, symbol.GetName(useMetadataName: true), ContainingType, type.TypeRef, OriginalDefinition));
|
||||
trapFile.indexers(this, symbol.GetName(useMetadataName: true), ContainingType, type.TypeRef, OriginalDefinition);
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.indexer_location(this, l));
|
||||
trapFile.indexer_location(this, l);
|
||||
|
||||
var getter = symbol.GetMethod;
|
||||
var setter = symbol.SetMethod;
|
||||
@@ -50,7 +50,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
BindComments();
|
||||
|
||||
var declSyntaxReferences = IsSourceDeclaration
|
||||
@@ -60,7 +60,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations.Select(impl => Type.Create(Context, impl.ContainingType)))
|
||||
{
|
||||
trapFile.Emit(Tuples.explicitly_implements(this, explicitInterface.TypeRef));
|
||||
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
|
||||
|
||||
foreach (var syntax in declSyntaxReferences)
|
||||
TypeMention.Create(Context, syntax.ExplicitInterfaceSpecifier.Name, this, explicitInterface);
|
||||
|
||||
@@ -43,13 +43,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
foreach(var modifier in fn.Modifiers)
|
||||
{
|
||||
Modifier.HasModifier(Context, this, modifier.Text);
|
||||
Modifier.HasModifier(Context, trapFile, this, modifier.Text);
|
||||
}
|
||||
}
|
||||
|
||||
var originalDefinition = IsSourceDeclaration ? this : Create(Context, symbol.OriginalDefinition);
|
||||
var returnType = Type.Create(Context, symbol.ReturnType);
|
||||
trapFile.Emit(Tuples.local_functions(this, symbol.Name, returnType, originalDefinition));
|
||||
trapFile.local_functions(this, symbol.Name, returnType, originalDefinition);
|
||||
ExtractRefReturn(trapFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +33,20 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
ExtractNullability(trapFile, local.NullableAnnotation);
|
||||
if (local.IsRef)
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.Ref));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.Ref);
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.localvars(
|
||||
trapFile.localvars(
|
||||
this,
|
||||
IsRef ? 3 : IsConst ? 2 : 1,
|
||||
symbol.Name,
|
||||
IsVar ? 1 : 0,
|
||||
Type.Type.TypeRef,
|
||||
Parent));
|
||||
Parent);
|
||||
|
||||
trapFile.Emit(Tuples.localvar_location(this, DeclLocation));
|
||||
trapFile.localvar_location(this, DeclLocation);
|
||||
|
||||
DefineConstantValue();
|
||||
DefineConstantValue(trapFile);
|
||||
}
|
||||
|
||||
public static LocalVariable Create(Context cx, ISymbol local, Expression parent, bool isVar, Extraction.Entities.Location declLocation)
|
||||
@@ -87,12 +87,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
void DefineConstantValue()
|
||||
void DefineConstantValue(TextWriter trapFile)
|
||||
{
|
||||
var local = symbol as ILocalSymbol;
|
||||
if (local != null && local.HasConstantValue)
|
||||
{
|
||||
Context.Emit(Tuples.constant_value(this, Expression.ValueAsString(local.ConstantValue)));
|
||||
trapFile.constant_value(this, Expression.ValueAsString(local.ConstantValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
Where(sym => sym.MethodKind == MethodKind.Ordinary).
|
||||
Select(impl => Type.Create(Context, impl.ContainingType)))
|
||||
{
|
||||
Context.Emit(Tuples.explicitly_implements(this, explicitInterface.TypeRef));
|
||||
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
|
||||
|
||||
if (IsSourceDeclaration)
|
||||
foreach (var syntax in symbol.DeclaringSyntaxReferences.Select(d => d.GetSyntax()).OfType<MethodDeclarationSyntax>())
|
||||
@@ -99,7 +99,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
if (symbol.OverriddenMethod != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.overrides(this, Method.Create(Context, symbol.OverriddenMethod)));
|
||||
trapFile.overrides(this, Method.Create(Context, symbol.OverriddenMethod));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,23 +340,23 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
if (isFullyConstructed)
|
||||
{
|
||||
trapFile.Emit(Tuples.is_constructed(this));
|
||||
trapFile.Emit(Tuples.constructed_generic(this, Method.Create(Context, ConstructedFromSymbol)));
|
||||
trapFile.is_constructed(this);
|
||||
trapFile.constructed_generic(this, Method.Create(Context, ConstructedFromSymbol));
|
||||
foreach (var tp in symbol.GetAnnotatedTypeArguments())
|
||||
{
|
||||
trapFile.Emit(Tuples.type_arguments(Type.Create(Context, tp.Symbol), child, this));
|
||||
trapFile.type_arguments(Type.Create(Context, tp.Symbol), child, this);
|
||||
var ta = tp.Nullability.GetTypeAnnotation();
|
||||
if (ta != Kinds.TypeAnnotation.None)
|
||||
trapFile.Emit(Tuples.type_argument_annotation(this, child, ta));
|
||||
trapFile.type_argument_annotation(this, child, ta);
|
||||
child++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trapFile.Emit(Tuples.is_generic(this));
|
||||
trapFile.is_generic(this);
|
||||
foreach (var typeParam in symbol.TypeParameters.Select(tp => TypeParameter.Create(Context, tp)))
|
||||
{
|
||||
trapFile.Emit(Tuples.type_parameters(typeParam, child, this));
|
||||
trapFile.type_parameters(typeParam, child, this);
|
||||
child++;
|
||||
}
|
||||
}
|
||||
@@ -366,9 +366,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected void ExtractRefReturn(TextWriter trapFile)
|
||||
{
|
||||
if (symbol.ReturnsByRef)
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.Ref));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.Ref);
|
||||
if (symbol.ReturnsByRefReadonly)
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef);
|
||||
}
|
||||
|
||||
protected void PopulateMethod(TextWriter trapFile)
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public static void HasAccessibility(Context cx, IEntity type, Accessibility access)
|
||||
public static void HasAccessibility(Context cx, TextWriter trapFile, IEntity type, Accessibility access)
|
||||
{
|
||||
switch (access)
|
||||
{
|
||||
@@ -71,70 +71,70 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
case Accessibility.Public:
|
||||
case Accessibility.Protected:
|
||||
case Accessibility.Internal:
|
||||
HasModifier(cx, type, Modifier.AccessbilityModifier(access));
|
||||
HasModifier(cx, trapFile, type, Modifier.AccessbilityModifier(access));
|
||||
break;
|
||||
case Accessibility.NotApplicable:
|
||||
break;
|
||||
case Accessibility.ProtectedOrInternal:
|
||||
HasModifier(cx, type, "protected");
|
||||
HasModifier(cx, type, "internal");
|
||||
HasModifier(cx, trapFile, type, "protected");
|
||||
HasModifier(cx, trapFile, type, "internal");
|
||||
break;
|
||||
case Accessibility.ProtectedAndInternal:
|
||||
HasModifier(cx, type, "protected");
|
||||
HasModifier(cx, type, "private");
|
||||
HasModifier(cx, trapFile, type, "protected");
|
||||
HasModifier(cx, trapFile, type, "private");
|
||||
break;
|
||||
default:
|
||||
throw new InternalError($"Unhandled Microsoft.CodeAnalysis.Accessibility value: {access}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void HasModifier(Context cx, IEntity target, string modifier)
|
||||
public static void HasModifier(Context cx, TextWriter trapFile, IEntity target, string modifier)
|
||||
{
|
||||
cx.Emit(Tuples.has_modifiers(target, Modifier.Create(cx, modifier)));
|
||||
trapFile.has_modifiers(target, Modifier.Create(cx, modifier));
|
||||
}
|
||||
|
||||
public static void ExtractModifiers(Context cx, IEntity key, ISymbol symbol)
|
||||
public static void ExtractModifiers(Context cx, TextWriter trapFile, IEntity key, ISymbol symbol)
|
||||
{
|
||||
bool interfaceDefinition = symbol.ContainingType != null
|
||||
&& symbol.ContainingType.Kind == SymbolKind.NamedType
|
||||
&& symbol.ContainingType.TypeKind == TypeKind.Interface;
|
||||
|
||||
Modifier.HasAccessibility(cx, key, symbol.DeclaredAccessibility);
|
||||
HasAccessibility(cx, trapFile, key, symbol.DeclaredAccessibility);
|
||||
if (symbol.Kind == SymbolKind.ErrorType)
|
||||
cx.Emit(Tuples.has_modifiers(key, Modifier.Create(cx, Accessibility.Public)));
|
||||
trapFile.has_modifiers(key, Modifier.Create(cx, Accessibility.Public));
|
||||
|
||||
if (symbol.IsAbstract && (symbol.Kind != SymbolKind.NamedType || ((INamedTypeSymbol)symbol).TypeKind != TypeKind.Interface) && !interfaceDefinition)
|
||||
Modifier.HasModifier(cx, key, "abstract");
|
||||
HasModifier(cx, trapFile, key, "abstract");
|
||||
|
||||
if (symbol.IsSealed)
|
||||
HasModifier(cx, key, "sealed");
|
||||
HasModifier(cx, trapFile, key, "sealed");
|
||||
|
||||
bool fromSource = symbol.DeclaringSyntaxReferences.Length > 0;
|
||||
|
||||
if (symbol.IsStatic && !(symbol.Kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsConst && !fromSource))
|
||||
HasModifier(cx, key, "static");
|
||||
HasModifier(cx, trapFile, key, "static");
|
||||
|
||||
if (symbol.IsVirtual)
|
||||
HasModifier(cx, key, "virtual");
|
||||
HasModifier(cx, trapFile, key, "virtual");
|
||||
|
||||
// For some reason, method in interfaces are "virtual", not "abstract"
|
||||
if (symbol.IsAbstract && interfaceDefinition)
|
||||
HasModifier(cx, key, "virtual");
|
||||
HasModifier(cx, trapFile, key, "virtual");
|
||||
|
||||
if (symbol.Kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsReadOnly)
|
||||
HasModifier(cx, key, "readonly");
|
||||
HasModifier(cx, trapFile, key, "readonly");
|
||||
|
||||
if (symbol.IsOverride)
|
||||
HasModifier(cx, key, "override");
|
||||
HasModifier(cx, trapFile, key, "override");
|
||||
|
||||
if (symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).IsAsync)
|
||||
HasModifier(cx, key, "async");
|
||||
HasModifier(cx, trapFile, key, "async");
|
||||
|
||||
if (symbol.IsExtern)
|
||||
HasModifier(cx, key, "extern");
|
||||
HasModifier(cx, trapFile, key, "extern");
|
||||
|
||||
foreach (var modifier in symbol.GetSourceLevelModifiers())
|
||||
HasModifier(cx, key, modifier);
|
||||
HasModifier(cx, trapFile, key, modifier);
|
||||
|
||||
if (symbol.Kind == SymbolKind.NamedType)
|
||||
{
|
||||
@@ -145,9 +145,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (nt.TypeKind == TypeKind.Struct)
|
||||
{
|
||||
if (nt.IsReadOnly)
|
||||
HasModifier(cx, key, "readonly");
|
||||
HasModifier(cx, trapFile, key, "readonly");
|
||||
if (nt.IsRefLikeType)
|
||||
HasModifier(cx, key, "ref");
|
||||
HasModifier(cx, trapFile, key, "ref");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.namespaces(this, symbol.Name));
|
||||
trapFile.namespaces(this, symbol.Name);
|
||||
|
||||
if (symbol.ContainingNamespace != null)
|
||||
{
|
||||
Namespace parent = Create(Context, symbol.ContainingNamespace);
|
||||
trapFile.Emit(Tuples.parent_namespace(this, parent));
|
||||
trapFile.parent_namespace(this, parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var ns = Namespace.Create(cx, (INamespaceSymbol)cx.GetModel(Node).GetSymbolInfo(Node.Name).Symbol);
|
||||
trapFile.Emit(Tuples.namespace_declarations(this, ns));
|
||||
trapFile.Emit(Tuples.namespace_declaration_location(this, cx.Create(Node.Name.GetLocation())));
|
||||
trapFile.namespace_declarations(this, ns);
|
||||
trapFile.namespace_declaration_location(this, cx.Create(Node.Name.GetLocation()));
|
||||
|
||||
var visitor = new Populators.TypeOrNamespaceVisitor(cx, trapFile, this);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.parent_namespace_declaration(this, Parent));
|
||||
trapFile.parent_namespace_declaration(this, Parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
ContainingType.ExtractGenerics();
|
||||
|
||||
var returnType = Type.Create(Context, symbol.ReturnType);
|
||||
trapFile.Emit(Tuples.methods(this, Name, ContainingType, returnType.TypeRef, OriginalDefinition));
|
||||
trapFile.methods(this, Name, ContainingType, returnType.TypeRef, OriginalDefinition);
|
||||
|
||||
if (IsSourceDeclaration)
|
||||
foreach (var declaration in symbol.DeclaringSyntaxReferences.Select(s => s.GetSyntax()).OfType<MethodDeclarationSyntax>())
|
||||
@@ -41,7 +41,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
|
||||
foreach (var l in Locations)
|
||||
Context.Emit(Tuples.method_location(this, l));
|
||||
trapFile.method_location(this, l);
|
||||
|
||||
ExtractGenerics(trapFile);
|
||||
Overrides(trapFile);
|
||||
|
||||
@@ -110,10 +110,10 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
Context.ModelError(symbol, "Inconsistent parameter declaration");
|
||||
|
||||
var type = Type.Create(Context, symbol.Type);
|
||||
trapFile.Emit(Tuples.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent, Original));
|
||||
trapFile.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent, Original);
|
||||
|
||||
foreach (var l in symbol.Locations)
|
||||
Context.Emit(Tuples.param_location(this, Context.Create(l)));
|
||||
trapFile.param_location(this, Context.Create(l));
|
||||
|
||||
if (!IsSourceDeclaration || !symbol.FromSource())
|
||||
return;
|
||||
@@ -185,9 +185,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.types(this, Kinds.TypeKind.ARGLIST, "__arglist"));
|
||||
trapFile.Emit(Tuples.parent_namespace(this, Namespace.Create(Context, Context.Compilation.GlobalNamespace)));
|
||||
Modifier.HasModifier(Context, this, "public");
|
||||
trapFile.types(this, Kinds.TypeKind.ARGLIST, "__arglist");
|
||||
trapFile.parent_namespace(this, Namespace.Create(Context, Context.Compilation.GlobalNamespace));
|
||||
Modifier.HasModifier(Context, trapFile, this, "public");
|
||||
}
|
||||
|
||||
public override bool NeedsPopulation => true;
|
||||
@@ -226,8 +226,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
var typeKey = VarargsType.Create(Context);
|
||||
// !! Maybe originaldefinition is wrong
|
||||
trapFile.Emit(Tuples.@params(this, "", typeKey, Ordinal, Kind.None, Parent, this));
|
||||
trapFile.Emit(Tuples.param_location(this, GeneratedLocation.Create(Context)));
|
||||
trapFile.@params(this, "", typeKey, Ordinal, Kind.None, Parent, this);
|
||||
trapFile.param_location(this, GeneratedLocation.Create(Context));
|
||||
}
|
||||
|
||||
protected override int Ordinal => ((Method)Parent).OriginalDefinition.symbol.Parameters.Length;
|
||||
@@ -265,8 +265,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var typeKey = Type.Create(Context, ConstructedType);
|
||||
trapFile.Emit(Tuples.@params(this, Original.symbol.Name, typeKey.TypeRef, 0, Kind.This, Parent, Original));
|
||||
trapFile.Emit(Tuples.param_location(this, Original.Location));
|
||||
trapFile.@params(this, Original.symbol.Name, typeKey.TypeRef, 0, Kind.This, Parent, Original);
|
||||
trapFile.param_location(this, Original.Location);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => symbol.GetHashCode() + 31 * ConstructedType.GetHashCode();
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
ExtractMetadataHandle(trapFile);
|
||||
ExtractAttributes();
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
BindComments();
|
||||
ExtractNullability(trapFile, symbol.NullableAnnotation);
|
||||
ExtractRefKind(trapFile, symbol.RefKind);
|
||||
|
||||
var type = Type.Create(Context, symbol.Type);
|
||||
trapFile.Emit(Tuples.properties(this, symbol.GetName(), ContainingType, type.TypeRef, Create(Context, symbol.OriginalDefinition)));
|
||||
trapFile.properties(this, symbol.GetName(), ContainingType, type.TypeRef, Create(Context, symbol.OriginalDefinition));
|
||||
|
||||
var getter = symbol.GetMethod;
|
||||
var setter = symbol.SetMethod;
|
||||
@@ -50,14 +50,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations.Select(impl => Type.Create(Context, impl.ContainingType)))
|
||||
{
|
||||
trapFile.Emit(Tuples.explicitly_implements(this, explicitInterface.TypeRef));
|
||||
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
|
||||
|
||||
foreach (var syntax in declSyntaxReferences)
|
||||
TypeMention.Create(Context, syntax.ExplicitInterfaceSpecifier.Name, this, explicitInterface);
|
||||
}
|
||||
|
||||
foreach (var l in Locations)
|
||||
Context.Emit(Tuples.property_location(this, l));
|
||||
trapFile.property_location(this, l);
|
||||
|
||||
if (IsSourceDeclaration && symbol.FromSource())
|
||||
{
|
||||
|
||||
@@ -61,12 +61,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.statements(this, Kind));
|
||||
trapFile.statements(this, Kind);
|
||||
if (Parent.IsTopLevelParent)
|
||||
trapFile.Emit(Tuples.stmt_parent_top_level(this, Child, Parent));
|
||||
trapFile.stmt_parent_top_level(this, Child, Parent);
|
||||
else
|
||||
trapFile.Emit(Tuples.stmt_parent(this, Child, Parent));
|
||||
cx.Emit(Tuples.stmt_location(this, Location));
|
||||
trapFile.stmt_parent(this, Child, Parent);
|
||||
trapFile.stmt_location(this, Location);
|
||||
PopulateStatement(trapFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
if (hasVariableDeclaration) // A catch clause of the form 'catch(Ex ex) { ... }'
|
||||
{
|
||||
var decl = Expressions.VariableDeclaration.Create(cx, Stmt.Declaration, false, this, 0);
|
||||
trapFile.Emit(Tuples.catch_type(this, decl.Type.Type.TypeRef, true));
|
||||
trapFile.catch_type(this, decl.Type.Type.TypeRef, true);
|
||||
}
|
||||
else if (isSpecificCatchClause) // A catch clause of the form 'catch(Ex) { ... }'
|
||||
{
|
||||
trapFile.Emit(Tuples.catch_type(this, Type.Create(cx, cx.GetType(Stmt.Declaration.Type)).Type.TypeRef, true));
|
||||
trapFile.catch_type(this, Type.Create(cx, cx.GetType(Stmt.Declaration.Type)).Type.TypeRef, true);
|
||||
}
|
||||
else // A catch clause of the form 'catch { ... }'
|
||||
{
|
||||
var exception = Type.Create(cx, cx.Compilation.GetTypeByMetadataName(SystemExceptionName));
|
||||
trapFile.Emit(Tuples.catch_type(this, exception, false));
|
||||
trapFile.catch_type(this, exception, false);
|
||||
}
|
||||
|
||||
if (Stmt.Filter != null)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
{
|
||||
case StmtKind.GOTO:
|
||||
var target = ((IdentifierNameSyntax)Stmt.Expression).Identifier.Text;
|
||||
cx.Emit(Tuples.exprorstmt_name(this, target));
|
||||
trapFile.exprorstmt_name(this, target);
|
||||
break;
|
||||
case StmtKind.GOTO_CASE:
|
||||
Expr = Expression.Create(cx, Stmt.Expression, this, 0);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
|
||||
protected override void PopulateStatement(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.exprorstmt_name(this, Stmt.Identifier.ToString()));
|
||||
trapFile.exprorstmt_name(this, Stmt.Identifier.ToString());
|
||||
|
||||
// For compatilibty with the Mono extractor, make insert the labelled statement into the same block
|
||||
// as this one. The parent MUST be a block statement.
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
|
||||
protected override void PopulateStatement(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.local_function_stmts(this, Function));
|
||||
trapFile.local_function_stmts(this, Function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public virtual Type ContainingType => symbol.ContainingType != null ? Type.Create(Context, symbol.ContainingType) : null;
|
||||
|
||||
public void ExtractModifiers()
|
||||
public void ExtractModifiers(TextWriter trapFile)
|
||||
{
|
||||
Modifier.ExtractModifiers(Context, this, symbol);
|
||||
Modifier.ExtractModifiers(Context, trapFile, this, symbol);
|
||||
}
|
||||
|
||||
protected void ExtractAttributes()
|
||||
@@ -32,7 +32,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
var ta = annotation.GetTypeAnnotation();
|
||||
if (ta != Kinds.TypeAnnotation.None)
|
||||
trapFile.Emit(Tuples.type_annotation(this, ta));
|
||||
trapFile.type_annotation(this, ta);
|
||||
}
|
||||
|
||||
protected void ExtractRefKind(TextWriter trapFile, RefKind kind)
|
||||
@@ -40,13 +40,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
switch (kind)
|
||||
{
|
||||
case RefKind.Out:
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.Out));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.Out);
|
||||
break;
|
||||
case RefKind.Ref:
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.Ref));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.Ref);
|
||||
break;
|
||||
case RefKind.RefReadOnly:
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected void ExtractCompilerGenerated(TextWriter trapFile)
|
||||
{
|
||||
if (symbol.IsImplicitlyDeclared)
|
||||
trapFile.Emit(Tuples.compiler_generated(this));
|
||||
trapFile.compiler_generated(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -130,7 +130,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
var handle = MetadataHandle;
|
||||
|
||||
if (handle.HasValue)
|
||||
trapFile.Emit(Tuples.metadata_handle(this, Location, MetadataTokens.GetToken(handle.Value)));
|
||||
trapFile.metadata_handle(this, Location, MetadataTokens.GetToken(handle.Value));
|
||||
}
|
||||
|
||||
public Handle? MetadataHandle
|
||||
|
||||
@@ -108,8 +108,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
void Emit(TextWriter trapFile, Microsoft.CodeAnalysis.Location loc, IEntity parent, Type type)
|
||||
{
|
||||
trapFile.Emit(Tuples.type_mention(this, type.TypeRef, parent));
|
||||
trapFile.Emit(Tuples.type_mention_location(this, cx.Create(loc)));
|
||||
trapFile.type_mention(this, type.TypeRef, parent);
|
||||
trapFile.type_mention_location(this, cx.Create(loc));
|
||||
}
|
||||
|
||||
public static TypeMention Create(Context cx, TypeSyntax syntax, IEntity parent, Type type, Microsoft.CodeAnalysis.Location loc = null)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.array_element_type(this, Dimension, Rank, element.Type.TypeRef));
|
||||
trapFile.array_element_type(this, Dimension, Rank, element.Type.TypeRef);
|
||||
ExtractType(trapFile);
|
||||
ExtractNullability(trapFile, symbol.ElementNullableAnnotation);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.types(this, Kinds.TypeKind.DYNAMIC, "dynamic"));
|
||||
trapFile.Emit(Tuples.type_location(this, Location));
|
||||
trapFile.types(this, Kinds.TypeKind.DYNAMIC, "dynamic");
|
||||
trapFile.type_location(this, Location);
|
||||
|
||||
trapFile.Emit(Tuples.has_modifiers(this, Modifier.Create(Context, "public")));
|
||||
trapFile.Emit(Tuples.parent_namespace(this, Namespace.Create(Context, Context.Compilation.GlobalNamespace)));
|
||||
trapFile.has_modifiers(this, Modifier.Create(Context, "public"));
|
||||
trapFile.parent_namespace(this, Namespace.Create(Context, Context.Compilation.GlobalNamespace));
|
||||
}
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
|
||||
@@ -29,38 +29,38 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.typeref_type((NamedTypeRef)TypeRef, this));
|
||||
trapFile.typeref_type((NamedTypeRef)TypeRef, this);
|
||||
|
||||
if (symbol.IsGenericType)
|
||||
{
|
||||
if (symbol.IsBoundNullable())
|
||||
{
|
||||
// An instance of Nullable<T>
|
||||
trapFile.Emit(Tuples.nullable_underlying_type(this, Create(Context, symbol.TypeArguments[0]).TypeRef));
|
||||
trapFile.nullable_underlying_type(this, Create(Context, symbol.TypeArguments[0]).TypeRef);
|
||||
}
|
||||
else if (symbol.IsReallyUnbound())
|
||||
{
|
||||
trapFile.Emit(Tuples.is_generic(this));
|
||||
trapFile.is_generic(this);
|
||||
|
||||
for (int i = 0; i < symbol.TypeParameters.Length; ++i)
|
||||
{
|
||||
TypeParameter.Create(Context, symbol.TypeParameters[i]);
|
||||
var param = symbol.TypeParameters[i];
|
||||
var typeParameter = TypeParameter.Create(Context, param);
|
||||
trapFile.Emit(Tuples.type_parameters(typeParameter, i, this));
|
||||
trapFile.type_parameters(typeParameter, i, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trapFile.Emit(Tuples.is_constructed(this));
|
||||
trapFile.Emit(Tuples.constructed_generic(this, Type.Create(Context, symbol.ConstructedFrom).TypeRef));
|
||||
trapFile.is_constructed(this);
|
||||
trapFile.constructed_generic(this, Type.Create(Context, symbol.ConstructedFrom).TypeRef);
|
||||
|
||||
for (int i = 0; i < symbol.TypeArguments.Length; ++i)
|
||||
{
|
||||
var ta = symbol.TypeArgumentsNullableAnnotations[i].GetTypeAnnotation();
|
||||
if (ta != Kinds.TypeAnnotation.None)
|
||||
trapFile.Emit(Tuples.type_argument_annotation(this, i, ta));
|
||||
trapFile.Emit(Tuples.type_arguments(TypeArguments[i].TypeRef, i, this));
|
||||
trapFile.type_argument_annotation(this, i, ta);
|
||||
trapFile.type_arguments(TypeArguments[i].TypeRef, i, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,14 +69,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
if (symbol.EnumUnderlyingType != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.enum_underlying_type(this, Type.Create(Context, symbol.EnumUnderlyingType).TypeRef));
|
||||
trapFile.enum_underlying_type(this, Type.Create(Context, symbol.EnumUnderlyingType).TypeRef);
|
||||
}
|
||||
|
||||
// Class location
|
||||
if (!symbol.IsGenericType || symbol.IsReallyUnbound())
|
||||
{
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.type_location(this, l));
|
||||
trapFile.type_location(this, l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.typerefs(this, symbol.Name));
|
||||
trapFile.typerefs(this, symbol.Name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.types(this, Kinds.TypeKind.NULL, "null"));
|
||||
trapFile.types(this, Kinds.TypeKind.NULL, "null");
|
||||
}
|
||||
|
||||
public override void WriteId(TextWriter trapFile)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
trapFile.Emit(Tuples.pointer_referent_type(this, PointedAtType.TypeRef));
|
||||
trapFile.pointer_referent_type(this, PointedAtType.TypeRef);
|
||||
ExtractType(trapFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,17 +42,17 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExtractGenerics();
|
||||
|
||||
var underlyingType = NamedType.Create(Context, symbol.TupleUnderlyingType);
|
||||
trapFile.Emit(Tuples.tuple_underlying_type(this, underlyingType));
|
||||
trapFile.tuple_underlying_type(this, underlyingType);
|
||||
|
||||
int index = 0;
|
||||
foreach (var element in TupleElements)
|
||||
trapFile.Emit(Tuples.tuple_element(this, index++, element));
|
||||
trapFile.tuple_element(this, index++, element);
|
||||
|
||||
// Note: symbol.Locations seems to be very inconsistent
|
||||
// about what locations are available for a tuple type.
|
||||
// Sometimes it's the source code, and sometimes it's empty.
|
||||
foreach (var l in symbol.Locations)
|
||||
trapFile.Emit(Tuples.type_location(this, Context.Create(l)));
|
||||
trapFile.type_location(this, Context.Create(l));
|
||||
}
|
||||
|
||||
readonly Lazy<Field[]> tupleElementsLazy;
|
||||
|
||||
@@ -85,28 +85,28 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
var tb = new StringWriter();
|
||||
symbol.BuildDisplayName(Context, tb);
|
||||
trapFile.Emit(Tuples.types(this, GetClassType(Context, symbol), tb.ToString()));
|
||||
trapFile.types(this, GetClassType(Context, symbol), tb.ToString());
|
||||
|
||||
// Visit base types
|
||||
var baseTypes = new List<Type>();
|
||||
if (symbol.BaseType != null)
|
||||
{
|
||||
Type baseKey = Create(Context, symbol.BaseType);
|
||||
trapFile.Emit(Tuples.extend(this, baseKey.TypeRef));
|
||||
trapFile.extend(this, baseKey.TypeRef);
|
||||
if (symbol.TypeKind != TypeKind.Struct)
|
||||
baseTypes.Add(baseKey);
|
||||
}
|
||||
|
||||
if (symbol.TypeKind == TypeKind.Interface)
|
||||
{
|
||||
trapFile.Emit(Tuples.extend(this, Create(Context, Context.Compilation.ObjectType)));
|
||||
trapFile.extend(this, Create(Context, Context.Compilation.ObjectType));
|
||||
}
|
||||
|
||||
if (!(base.symbol is IArrayTypeSymbol))
|
||||
{
|
||||
foreach (var t in base.symbol.Interfaces.Select(i=>Create(Context, i)))
|
||||
{
|
||||
trapFile.Emit(Tuples.implement(this, t.TypeRef));
|
||||
trapFile.implement(this, t.TypeRef);
|
||||
baseTypes.Add(t);
|
||||
}
|
||||
}
|
||||
@@ -115,11 +115,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (containingType != null && symbol.Kind != SymbolKind.TypeParameter)
|
||||
{
|
||||
Type originalDefinition = symbol.TypeKind == TypeKind.Error ? this : Create(Context, symbol.OriginalDefinition);
|
||||
trapFile.Emit(Tuples.nested_types(this, containingType, originalDefinition));
|
||||
trapFile.nested_types(this, containingType, originalDefinition);
|
||||
}
|
||||
else if (symbol.ContainingNamespace != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.parent_namespace(this, Namespace.Create(Context, symbol.ContainingNamespace)));
|
||||
trapFile.parent_namespace(this, Namespace.Create(Context, symbol.ContainingNamespace));
|
||||
}
|
||||
|
||||
if (symbol is IArrayTypeSymbol)
|
||||
@@ -128,7 +128,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ITypeSymbol elementType = ((IArrayTypeSymbol)symbol).ElementType;
|
||||
INamespaceSymbol ns = elementType.TypeKind == TypeKind.TypeParameter ? Context.Compilation.GlobalNamespace : elementType.ContainingNamespace;
|
||||
if (ns != null)
|
||||
trapFile.Emit(Tuples.parent_namespace(this, Namespace.Create(Context, ns)));
|
||||
trapFile.parent_namespace(this, Namespace.Create(Context, ns));
|
||||
}
|
||||
|
||||
if (symbol is IPointerTypeSymbol)
|
||||
@@ -137,7 +137,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
INamespaceSymbol ns = elementType.TypeKind == TypeKind.TypeParameter ? Context.Compilation.GlobalNamespace : elementType.ContainingNamespace;
|
||||
|
||||
if (ns != null)
|
||||
trapFile.Emit(Tuples.parent_namespace(this, Namespace.Create(Context, ns)));
|
||||
trapFile.parent_namespace(this, Namespace.Create(Context, ns));
|
||||
}
|
||||
|
||||
if (symbol.BaseType != null && symbol.BaseType.SpecialType == SpecialType.System_MulticastDelegate)
|
||||
@@ -157,14 +157,14 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
|
||||
var returnKey = Create(Context, invokeMethod.ReturnType);
|
||||
trapFile.Emit(Tuples.delegate_return_type(this, returnKey.TypeRef));
|
||||
trapFile.delegate_return_type(this, returnKey.TypeRef);
|
||||
if (invokeMethod.ReturnsByRef)
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.Ref));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.Ref);
|
||||
if (invokeMethod.ReturnsByRefReadonly)
|
||||
trapFile.Emit(Tuples.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef));
|
||||
trapFile.type_annotation(this, Kinds.TypeAnnotation.ReadonlyRef);
|
||||
}
|
||||
|
||||
Modifier.ExtractModifiers(Context, this, symbol);
|
||||
Modifier.ExtractModifiers(Context, trapFile, this, symbol);
|
||||
|
||||
if (IsSourceDeclaration && symbol.FromSource())
|
||||
{
|
||||
@@ -255,7 +255,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
if (symbol.ContainingSymbol.Kind == SymbolKind.Namespace && !symbol.ContainingNamespace.IsGlobalNamespace)
|
||||
{
|
||||
trapFile.Emit(Tuples.parent_namespace_declaration(this, (NamespaceDeclaration)parent));
|
||||
trapFile.parent_namespace_declaration(this, (NamespaceDeclaration)parent);
|
||||
}
|
||||
|
||||
ExtractRecursive();
|
||||
|
||||
@@ -24,46 +24,46 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
var constraints = new TypeParameterConstraints(Context);
|
||||
trapFile.Emit(Tuples.type_parameter_constraints(constraints, this));
|
||||
trapFile.type_parameter_constraints(constraints, this);
|
||||
|
||||
if (symbol.HasReferenceTypeConstraint)
|
||||
trapFile.Emit(Tuples.general_type_parameter_constraints(constraints, 1));
|
||||
trapFile.general_type_parameter_constraints(constraints, 1);
|
||||
|
||||
if (symbol.HasValueTypeConstraint)
|
||||
trapFile.Emit(Tuples.general_type_parameter_constraints(constraints, 2));
|
||||
trapFile.general_type_parameter_constraints(constraints, 2);
|
||||
|
||||
if (symbol.HasConstructorConstraint)
|
||||
trapFile.Emit(Tuples.general_type_parameter_constraints(constraints, 3));
|
||||
trapFile.general_type_parameter_constraints(constraints, 3);
|
||||
|
||||
if(symbol.HasUnmanagedTypeConstraint)
|
||||
trapFile.Emit(Tuples.general_type_parameter_constraints(constraints, 4));
|
||||
trapFile.general_type_parameter_constraints(constraints, 4);
|
||||
|
||||
ITypeSymbol baseType = symbol.HasValueTypeConstraint ?
|
||||
Context.Compilation.GetTypeByMetadataName(valueTypeName) :
|
||||
Context.Compilation.ObjectType;
|
||||
|
||||
if(symbol.ReferenceTypeConstraintNullableAnnotation == NullableAnnotation.Annotated)
|
||||
trapFile.Emit(Tuples.general_type_parameter_constraints(constraints, 5));
|
||||
trapFile.general_type_parameter_constraints(constraints, 5);
|
||||
|
||||
foreach (var abase in symbol.GetAnnotatedTypeConstraints())
|
||||
{
|
||||
if (abase.Symbol.TypeKind != TypeKind.Interface)
|
||||
baseType = abase.Symbol;
|
||||
var t = Create(Context, abase.Symbol);
|
||||
trapFile.Emit(Tuples.specific_type_parameter_constraints(constraints, t.TypeRef));
|
||||
trapFile.specific_type_parameter_constraints(constraints, t.TypeRef);
|
||||
if (abase.Nullability.GetTypeAnnotation() != Kinds.TypeAnnotation.None)
|
||||
trapFile.Emit(Tuples.specific_type_parameter_annotation(constraints, t.TypeRef, abase.Nullability.GetTypeAnnotation()));
|
||||
trapFile.specific_type_parameter_annotation(constraints, t.TypeRef, abase.Nullability.GetTypeAnnotation());
|
||||
}
|
||||
|
||||
trapFile.Emit(Tuples.types(this, Semmle.Extraction.Kinds.TypeKind.TYPE_PARAMETER, symbol.Name));
|
||||
trapFile.Emit(Tuples.extend(this, Create(Context, baseType).TypeRef));
|
||||
trapFile.types(this, Semmle.Extraction.Kinds.TypeKind.TYPE_PARAMETER, symbol.Name);
|
||||
trapFile.extend(this, Create(Context, baseType).TypeRef);
|
||||
|
||||
Namespace parentNs = Namespace.Create(Context, symbol.TypeParameterKind == TypeParameterKind.Method ? Context.Compilation.GlobalNamespace : symbol.ContainingNamespace);
|
||||
trapFile.Emit(Tuples.parent_namespace(this, parentNs));
|
||||
trapFile.parent_namespace(this, parentNs);
|
||||
|
||||
foreach (var l in symbol.Locations)
|
||||
{
|
||||
trapFile.Emit(Tuples.type_location(this, Context.Create(l)));
|
||||
trapFile.type_location(this, Context.Create(l));
|
||||
}
|
||||
|
||||
if (this.IsSourceDeclaration)
|
||||
|
||||
@@ -13,18 +13,18 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
ExtractModifiers();
|
||||
ExtractModifiers(trapFile);
|
||||
|
||||
var returnType = Type.Create(Context, symbol.ReturnType);
|
||||
trapFile.Emit(Tuples.operators(this,
|
||||
trapFile.operators(this,
|
||||
symbol.Name,
|
||||
OperatorSymbol(Context, symbol.Name),
|
||||
ContainingType,
|
||||
returnType.TypeRef,
|
||||
(UserOperator)OriginalDefinition));
|
||||
(UserOperator)OriginalDefinition);
|
||||
|
||||
foreach (var l in Locations)
|
||||
trapFile.Emit(Tuples.operator_location(this, l));
|
||||
trapFile.operator_location(this, l);
|
||||
|
||||
if (IsSourceDeclaration)
|
||||
{
|
||||
|
||||
@@ -40,21 +40,21 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
else
|
||||
{
|
||||
var ns = Namespace.Create(cx, namespaceSymbol);
|
||||
trapFile.Emit(Tuples.using_namespace_directives(this, ns));
|
||||
trapFile.Emit(Tuples.using_directive_location(this, cx.Create(ReportingLocation)));
|
||||
trapFile.using_namespace_directives(this, ns);
|
||||
trapFile.using_directive_location(this, cx.Create(ReportingLocation));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// A "using static"
|
||||
Type m = Type.Create(cx, (ITypeSymbol)info.Symbol);
|
||||
trapFile.Emit(Tuples.using_static_directives(this, m.TypeRef));
|
||||
trapFile.Emit(Tuples.using_directive_location(this, cx.Create(ReportingLocation)));
|
||||
trapFile.using_static_directives(this, m.TypeRef);
|
||||
trapFile.using_directive_location(this, cx.Create(ReportingLocation));
|
||||
}
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
trapFile.Emit(Tuples.parent_namespace_declaration(this, Parent));
|
||||
trapFile.parent_namespace_declaration(this, Parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
public static void NumberOfLines(this Context cx, TextWriter trapFile, CSharpSyntaxNode node, IEntity callable)
|
||||
{
|
||||
var lineCounts = node.Accept(new AstLineCounter());
|
||||
trapFile.Emit(Tuples.numlines(callable, lineCounts));
|
||||
trapFile.numlines(callable, lineCounts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,235 +3,471 @@ using Semmle.Extraction.CSharp.Entities;
|
||||
using Semmle.Extraction.Entities;
|
||||
using Semmle.Extraction.Kinds;
|
||||
using Semmle.Util;
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Methods for creating DB tuples.
|
||||
/// Methods for writing DB tuples.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Notice how the parameters to the tuples are well typed.
|
||||
/// In an idea world, each tuple would be its own type, as a typed entity. However
|
||||
/// that seems to be overkill.
|
||||
/// The parameters to the tuples are well-typed.
|
||||
/// </remarks>
|
||||
internal static class Tuples
|
||||
{
|
||||
internal static Tuple accessor_location(Accessor accessorKey, Location location) => new Tuple("accessor_location", accessorKey, location);
|
||||
|
||||
internal static Tuple accessors(Accessor accessorKey, int kind, string name, Property propKey, Accessor unboundAccessor) => new Tuple("accessors", accessorKey, kind, name, propKey, unboundAccessor);
|
||||
|
||||
internal static Tuple array_element_type(ArrayType array, int dimension, int rank, Type elementType) => new Tuple("array_element_type", array, dimension, rank, elementType);
|
||||
|
||||
internal static Tuple attributes(Attribute attribute, Type attributeType, IEntity entity) => new Tuple("attributes", attribute, attributeType, entity);
|
||||
|
||||
internal static Tuple attribute_location(Attribute attribute, Location location) => new Tuple("attribute_location", attribute, location);
|
||||
|
||||
internal static Tuple catch_type(Entities.Statements.Catch @catch, Type type, bool explicityCaught) => new Tuple("catch_type", @catch, type, explicityCaught ? 1 : 2);
|
||||
|
||||
internal static Tuple commentblock(CommentBlock k) => new Tuple("commentblock", k);
|
||||
|
||||
internal static Tuple commentblock_binding(CommentBlock commentBlock, Label entity, CommentBinding binding) => new Tuple("commentblock_binding", commentBlock, entity, binding);
|
||||
|
||||
internal static Tuple commentblock_child(CommentBlock commentBlock, CommentLine commentLine, int child) => new Tuple("commentblock_child", commentBlock, commentLine, child);
|
||||
|
||||
internal static Tuple commentblock_location(CommentBlock k, Location l) => new Tuple("commentblock_location", k, l);
|
||||
|
||||
internal static Tuple commentline(CommentLine commentLine, CommentLineType type, string text, string rawtext) => new Tuple("commentline", commentLine, type, text, rawtext);
|
||||
|
||||
internal static Tuple commentline_location(CommentLine commentLine, Location location) => new Tuple("commentline_location", commentLine, location);
|
||||
|
||||
internal static Tuple compilation_args(Compilation compilation, int index, string arg) => new Tuple("compilation_args", compilation, index, arg);
|
||||
|
||||
internal static Tuple compilation_compiling_files(Compilation compilation, int index, File file) => new Tuple("compilation_compiling_files", compilation, index, file);
|
||||
|
||||
internal static Tuple compilation_referencing_files(Compilation compilation, int index, File file) => new Tuple("compilation_referencing_files", compilation, index, file);
|
||||
|
||||
internal static Tuple compilation_finished(Compilation compilation, float cpuSeconds, float elapsedSeconds) => new Tuple("compilation_finished", compilation, cpuSeconds, elapsedSeconds);
|
||||
|
||||
internal static Tuple compilation_time(Compilation compilation, int num, int index, float metric) => new Tuple("compilation_time", compilation, num, index, metric);
|
||||
|
||||
internal static Tuple compilations(Compilation compilation, string cwd) => new Tuple("compilations", compilation, cwd);
|
||||
|
||||
internal static Tuple compiler_generated(IEntity entity) => new Tuple("compiler_generated", entity);
|
||||
|
||||
internal static Tuple conditional_access(Expression access) => new Tuple("conditional_access", access);
|
||||
|
||||
internal static Tuple constant_value(IEntity field, string value) => new Tuple("constant_value", field, value);
|
||||
|
||||
internal static Tuple constructed_generic(IEntity constructedTypeOrMethod, IEntity unboundTypeOrMethod) => new Tuple("constructed_generic", constructedTypeOrMethod, unboundTypeOrMethod);
|
||||
|
||||
internal static Tuple constructor_location(Constructor constructor, Location location) => new Tuple("constructor_location", constructor, location);
|
||||
|
||||
internal static Tuple constructors(Constructor key, string name, Type definingType, Constructor originalDefinition) => new Tuple("constructors", key, name, definingType, originalDefinition);
|
||||
|
||||
internal static Tuple delegate_return_type(Type delegateKey, Type returnType) => new Tuple("delegate_return_type", delegateKey, returnType);
|
||||
|
||||
internal static Tuple destructor_location(Destructor destructor, Location location) => new Tuple("destructor_location", destructor, location);
|
||||
|
||||
internal static Tuple destructors(Destructor destructor, string name, Type containingType, Destructor original) => new Tuple("destructors", destructor, name, containingType, original);
|
||||
|
||||
internal static Tuple diagnostic_for(Diagnostic diag, Compilation comp, int fileNo, int index) => new Tuple("diagnostic_for", diag, comp, fileNo, index);
|
||||
|
||||
internal static Tuple diagnostics(Diagnostic diag, int severity, string errorTag, string errorMessage, string fullErrorMessage, Location location) =>
|
||||
new Tuple("diagnostics", diag, severity, errorTag, errorMessage, fullErrorMessage, location);
|
||||
|
||||
internal static Tuple dynamic_member_name(Expression e, string name) => new Tuple("dynamic_member_name", e, name);
|
||||
|
||||
internal static Tuple enum_underlying_type(Type @enum, Type type) => new Tuple("enum_underlying_type", @enum, type);
|
||||
|
||||
internal static Tuple event_accessor_location(EventAccessor accessor, Location location) => new Tuple("event_accessor_location", accessor, location);
|
||||
|
||||
internal static Tuple event_accessors(EventAccessor accessorKey, int type, string name, Event eventKey, EventAccessor unboundAccessor) => new Tuple("event_accessors", accessorKey, type, name, eventKey, unboundAccessor);
|
||||
|
||||
internal static Tuple event_location(Event eventKey, Location locationKey) => new Tuple("event_location", eventKey, locationKey);
|
||||
|
||||
internal static Tuple events(Event eventKey, string name, Type declaringType, Type memberType, Event originalDefinition) => new Tuple("events", eventKey, name, declaringType, memberType, originalDefinition);
|
||||
|
||||
internal static Tuple explicitly_implements(IEntity member, Type @interface) => new Tuple("explicitly_implements", member, @interface);
|
||||
|
||||
internal static Tuple explicitly_sized_array_creation(Expression array) => new Tuple("explicitly_sized_array_creation", array);
|
||||
|
||||
internal static Tuple expr_compiler_generated(Expression expr) => new Tuple("expr_compiler_generated", expr);
|
||||
|
||||
internal static Tuple expr_location(Expression exprKey, Location location) => new Tuple("expr_location", exprKey, location);
|
||||
|
||||
internal static Tuple expr_access(Expression expr, IEntity access) => new Tuple("expr_access", expr, access);
|
||||
|
||||
internal static Tuple expr_argument(Expression expr, int mode) => new Tuple("expr_argument", expr, mode);
|
||||
|
||||
internal static Tuple expr_argument_name(Expression expr, string name) => new Tuple("expr_argument_name", expr, name);
|
||||
|
||||
internal static Tuple expr_call(Expression expr, Method target) => new Tuple("expr_call", expr, target);
|
||||
|
||||
internal static Tuple expr_parent(Expression exprKey, int child, IExpressionParentEntity parent) => new Tuple("expr_parent", exprKey, child, parent);
|
||||
|
||||
internal static Tuple expr_parent_top_level(Expression exprKey, int child, IExpressionParentEntity parent) => new Tuple("expr_parent_top_level", exprKey, child, parent);
|
||||
|
||||
internal static Tuple expr_value(Expression exprKey, string value) => new Tuple("expr_value", exprKey, value);
|
||||
|
||||
internal static Tuple expressions(Expression expr, ExprKind kind, Type exprType) => new Tuple("expressions", expr, kind, exprType);
|
||||
|
||||
internal static Tuple exprorstmt_name(IEntity expr, string name) => new Tuple("exprorstmt_name", expr, name);
|
||||
|
||||
internal static Tuple extend(Type type, Type super) => new Tuple("extend", type, super);
|
||||
|
||||
internal static Tuple field_location(Field field, Location location) => new Tuple("field_location", field, location);
|
||||
|
||||
internal static Tuple fields(Field field, int @const, string name, Type declaringType, Type fieldType, Field unboundKey) => new Tuple("fields", field, @const, name, declaringType, fieldType, unboundKey);
|
||||
|
||||
|
||||
internal static Tuple general_type_parameter_constraints(TypeParameterConstraints constraints, int hasKind) => new Tuple("general_type_parameter_constraints", constraints, hasKind);
|
||||
|
||||
internal static Tuple has_modifiers(IEntity entity, Modifier modifier) => new Tuple("has_modifiers", entity, modifier);
|
||||
|
||||
internal static Tuple implement(Type type, Type @interface) => new Tuple("implement", type, @interface);
|
||||
|
||||
internal static Tuple implicitly_typed_array_creation(Expression array) => new Tuple("implicitly_typed_array_creation", array);
|
||||
|
||||
internal static Tuple indexer_location(Indexer indexer, Location location) => new Tuple("indexer_location", indexer, location);
|
||||
|
||||
internal static Tuple indexers(Indexer propKey, string name, Type declaringType, Type memberType, Indexer unboundProperty) => new Tuple("indexers", propKey, name, declaringType, memberType, unboundProperty);
|
||||
|
||||
internal static Tuple is_constructed(IEntity typeOrMethod) => new Tuple("is_constructed", typeOrMethod);
|
||||
|
||||
internal static Tuple is_generic(IEntity typeOrMethod) => new Tuple("is_generic", typeOrMethod);
|
||||
|
||||
internal static Tuple jump_step(IEntity origin, IEntity src, Statement dest) => new Tuple("jump_step", origin, src, dest);
|
||||
|
||||
internal static Tuple local_function_stmts(Entities.Statements.LocalFunction fnStmt, LocalFunction fn) => new Tuple("local_function_stmts", fnStmt, fn);
|
||||
|
||||
internal static Tuple local_functions(LocalFunction fn, string name, Type returnType, LocalFunction unboundFn) => new Tuple("local_functions", fn, name, returnType, unboundFn);
|
||||
|
||||
internal static Tuple localvar_location(LocalVariable var, Location location) => new Tuple("localvar_location", var, location);
|
||||
|
||||
internal static Tuple localvars(LocalVariable key, int @const, string name, int @var, Type type, Expression expr) => new Tuple("localvars", key, @const, name, @var, type, expr);
|
||||
|
||||
public static Tuple metadata_handle(IEntity entity, Location assembly, int handleValue) =>
|
||||
new Tuple("metadata_handle", entity, assembly, handleValue);
|
||||
|
||||
internal static Tuple method_location(Method method, Location location) => new Tuple("method_location", method, location);
|
||||
|
||||
internal static Tuple methods(Method method, string name, Type declType, Type retType, Method originalDefinition) => new Tuple("methods", method, name, declType, retType, originalDefinition);
|
||||
|
||||
internal static Tuple mutator_invocation_mode(Expression expr, int mode) => new Tuple("mutator_invocation_mode", expr, mode);
|
||||
|
||||
internal static Tuple namespace_declaration_location(NamespaceDeclaration decl, Location location) => new Tuple("namespace_declaration_location", decl, location);
|
||||
|
||||
internal static Tuple namespace_declarations(NamespaceDeclaration decl, Namespace ns) => new Tuple("namespace_declarations", decl, ns);
|
||||
|
||||
internal static Tuple namespaces(Namespace ns, string name) => new Tuple("namespaces", ns, name);
|
||||
|
||||
internal static Tuple nested_types(Type typeKey, Type declaringTypeKey, Type unboundTypeKey) => new Tuple("nested_types", typeKey, declaringTypeKey, unboundTypeKey);
|
||||
|
||||
internal static Tuple nullable_underlying_type(Type nullableType, Type underlyingType) => new Tuple("nullable_underlying_type", nullableType, underlyingType);
|
||||
|
||||
internal static Tuple numlines(IEntity label, LineCounts lineCounts) => new Tuple("numlines", label, lineCounts.Total, lineCounts.Code, lineCounts.Comment);
|
||||
|
||||
internal static Tuple operator_location(UserOperator @operator, Location location) => new Tuple("operator_location", @operator, location);
|
||||
|
||||
internal static Tuple operators(UserOperator method, string methodName, string symbol, Type classKey, Type returnType, UserOperator originalDefinition) => new Tuple("operators", method, methodName, symbol, classKey, returnType, originalDefinition);
|
||||
|
||||
internal static Tuple overrides(Method overriding, Method overridden) => new Tuple("overrides", overriding, overridden);
|
||||
|
||||
internal static Tuple param_location(Parameter param, Location location) => new Tuple("param_location", param, location);
|
||||
|
||||
internal static Tuple @params(Parameter param, string name, Type type, int child, Parameter.Kind mode, IEntity method, Parameter originalDefinition) => new Tuple("params", param, name, type, child, mode, method, originalDefinition);
|
||||
|
||||
internal static Tuple parent_namespace(IEntity type, Namespace parent) => new Tuple("parent_namespace", type, parent);
|
||||
|
||||
internal static Tuple parent_namespace_declaration(IEntity item, NamespaceDeclaration parent) => new Tuple("parent_namespace_declaration", item, parent);
|
||||
|
||||
internal static Tuple pointer_referent_type(PointerType pointerType, Type referentType) => new Tuple("pointer_referent_type", pointerType, referentType);
|
||||
|
||||
internal static Tuple property_location(Property property, Location location) => new Tuple("property_location", property, location);
|
||||
|
||||
internal static Tuple properties(Property propKey, string name, Type declaringType, Type memberType, Property unboundProperty) => new Tuple("properties", propKey, name, declaringType, memberType, unboundProperty);
|
||||
|
||||
internal static Tuple statements(Statement stmt, StmtKind kind) => new Tuple("statements", stmt, kind);
|
||||
|
||||
internal static Tuple specific_type_parameter_constraints(TypeParameterConstraints constraints, Type baseType) => new Tuple("specific_type_parameter_constraints", constraints, baseType);
|
||||
|
||||
internal static Tuple specific_type_parameter_annotation(TypeParameterConstraints constraints, Type baseType, TypeAnnotation annotation) => new Tuple("specific_type_parameter_annotation", constraints, baseType, (int)annotation);
|
||||
|
||||
internal static Tuple successors(IEntity from, IEntity to) => new Tuple("successors", from, to);
|
||||
|
||||
internal static Tuple stmt_location(Statement stmt, Location location) => new Tuple("stmt_location", stmt, location);
|
||||
|
||||
internal static Tuple stmt_parent(Statement stmt, int child, IStatementParentEntity parent) => new Tuple("stmt_parent", stmt, child, parent);
|
||||
|
||||
internal static Tuple stmt_parent_top_level(Statement stmt, int child, IStatementParentEntity parent) => new Tuple("stmt_parent_top_level", stmt, child, parent);
|
||||
|
||||
internal static Tuple tuple_element(TupleType type, int index, Field field) => new Tuple("tuple_element", type, index, field);
|
||||
|
||||
internal static Tuple tuple_underlying_type(TupleType type, NamedType underlying) => new Tuple("tuple_underlying_type", type, underlying);
|
||||
|
||||
internal static Tuple type_annotation(IEntity element, Kinds.TypeAnnotation annotation) => new Tuple("type_annotation", element, (int)annotation);
|
||||
|
||||
internal static Tuple type_argument_annotation(IEntity element, int index, Kinds.TypeAnnotation annotation) => new Tuple("type_argument_annotation", element, index, (int)annotation);
|
||||
|
||||
internal static Tuple type_mention(TypeMention ta, Type type, IEntity parent) => new Tuple("type_mention", ta, type, parent);
|
||||
|
||||
internal static Tuple type_mention_location(TypeMention ta, Location loc) => new Tuple("type_mention_location", ta, loc);
|
||||
|
||||
internal static Tuple type_arguments(Type arg, int n, IEntity typeOrMethod) => new Tuple("type_arguments", arg, n, typeOrMethod);
|
||||
|
||||
internal static Tuple type_location(Type type, Location location) => new Tuple("type_location", type, location);
|
||||
|
||||
internal static Tuple type_parameter_constraints(TypeParameterConstraints constraints, TypeParameter typeParam) => new Tuple("type_parameter_constraints", constraints, typeParam);
|
||||
|
||||
internal static Tuple type_parameters(TypeParameter param, int child, IEntity typeOrMethod) => new Tuple("type_parameters", param, child, typeOrMethod, param.Variance);
|
||||
|
||||
internal static Tuple typeref_type(NamedTypeRef typeref, Type type) => new Tuple("typeref_type", typeref, type);
|
||||
|
||||
internal static Tuple typerefs(NamedTypeRef type, string name) => new Tuple("typerefs", type, name);
|
||||
|
||||
internal static Tuple types(Type type, TypeKind kind, params string[] name) => new Tuple("types", type, kind, name);
|
||||
|
||||
internal static Tuple using_namespace_directives(UsingDirective @using, Namespace ns) => new Tuple("using_namespace_directives", @using, ns);
|
||||
|
||||
internal static Tuple using_directive_location(UsingDirective @using, Location location) => new Tuple("using_directive_location", @using, location);
|
||||
|
||||
internal static Tuple using_static_directives(UsingDirective @using, Type type) => new Tuple("using_static_directives", @using, type);
|
||||
internal static void accessor_location(this TextWriter trapFile, Accessor accessorKey, Location location)
|
||||
{
|
||||
trapFile.BeginTuple("accessor_location").Param(accessorKey).Param(location).EndTuple();
|
||||
}
|
||||
|
||||
internal static void accessors(this TextWriter trapFile, Accessor accessorKey, int kind, string name, Property propKey, Accessor unboundAccessor)
|
||||
{
|
||||
trapFile.BeginTuple("accessors").Param(accessorKey).Param(kind).Param(name).Param(propKey).Param(unboundAccessor).EndTuple();
|
||||
}
|
||||
|
||||
internal static void array_element_type(this TextWriter trapFile, ArrayType array, int dimension, int rank, Type elementType)
|
||||
{
|
||||
trapFile.BeginTuple("array_element_type").Param(array).Param(dimension).Param(rank).Param(elementType).EndTuple();
|
||||
}
|
||||
|
||||
internal static void attributes(this TextWriter trapFile, Attribute attribute, Type attributeType, IEntity entity)
|
||||
{
|
||||
trapFile.BeginTuple("attributes").Param(attribute).Param(attributeType).Param(entity).EndTuple();
|
||||
}
|
||||
|
||||
internal static void attribute_location(this TextWriter trapFile, Attribute attribute, Location location)
|
||||
{
|
||||
trapFile.BeginTuple("attribute_location").Param(attribute).Param(location).EndTuple();
|
||||
}
|
||||
|
||||
internal static void catch_type(this TextWriter trapFile, Entities.Statements.Catch @catch, Type type, bool explicityCaught)
|
||||
{
|
||||
trapFile.BeginTuple("catch_type").Param(@catch).Param(type).Param(explicityCaught ? 1 : 2).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentblock(this TextWriter trapFile, CommentBlock k)
|
||||
{
|
||||
trapFile.BeginTuple("commentblock").Param(k).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentblock_binding(this TextWriter trapFile, CommentBlock commentBlock, Label entity, CommentBinding binding)
|
||||
{
|
||||
trapFile.BeginTuple("commentblock_binding").Param(commentBlock).Param(entity).Param((int)binding).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentblock_child(this TextWriter trapFile, CommentBlock commentBlock, CommentLine commentLine, int child)
|
||||
{
|
||||
trapFile.BeginTuple("commentblock_child").Param(commentBlock).Param(commentLine).Param(child).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentblock_location(this TextWriter trapFile, CommentBlock k, Location l)
|
||||
{
|
||||
trapFile.BeginTuple("commentblock_location").Param(k).Param(l).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentline(this TextWriter trapFile, CommentLine commentLine, CommentLineType type, string text, string rawtext)
|
||||
{
|
||||
trapFile.BeginTuple("commentline").Param(commentLine).Param((int)type).Param(text).Param(rawtext).EndTuple();
|
||||
}
|
||||
|
||||
internal static void commentline_location(this TextWriter trapFile, CommentLine commentLine, Location location)
|
||||
{
|
||||
trapFile.BeginTuple("commentline_location").Param(commentLine).Param(location).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilation_args(this TextWriter trapFile, Compilation compilation, int index, string arg)
|
||||
{
|
||||
trapFile.BeginTuple("compilation_args").Param(compilation).Param(index).Param(arg).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilation_compiling_files(this TextWriter trapFile, Compilation compilation, int index, Extraction.Entities.File file)
|
||||
{
|
||||
trapFile.BeginTuple("compilation_compiling_files").Param(compilation).Param(index).Param(file).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilation_referencing_files(this TextWriter trapFile, Compilation compilation, int index, Extraction.Entities.File file)
|
||||
{
|
||||
trapFile.BeginTuple("compilation_referencing_files").Param(compilation).Param(index).Param(file).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilation_finished(this TextWriter trapFile, Compilation compilation, float cpuSeconds, float elapsedSeconds)
|
||||
{
|
||||
trapFile.BeginTuple("compilation_finished").Param(compilation).Param(cpuSeconds).Param(elapsedSeconds).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilation_time(this TextWriter trapFile, Compilation compilation, int num, int index, float metric)
|
||||
{
|
||||
trapFile.BeginTuple("compilation_time").Param(compilation).Param(num).Param(index).Param(metric).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compilations(this TextWriter trapFile, Compilation compilation, string cwd)
|
||||
{
|
||||
trapFile.BeginTuple("compilations").Param(compilation).Param(cwd).EndTuple();
|
||||
}
|
||||
|
||||
internal static void compiler_generated(this TextWriter trapFile, IEntity entity)
|
||||
{
|
||||
trapFile.BeginTuple("compiler_generated").Param(entity).EndTuple();
|
||||
}
|
||||
|
||||
internal static void conditional_access(this TextWriter trapFile, Expression access)
|
||||
{
|
||||
trapFile.BeginTuple("conditional_access").Param(access).EndTuple();
|
||||
}
|
||||
|
||||
internal static void constant_value(this TextWriter trapFile, IEntity field, string value)
|
||||
{
|
||||
trapFile.BeginTuple("constant_value").Param(field).Param(value).EndTuple();
|
||||
}
|
||||
|
||||
internal static void constructed_generic(this TextWriter trapFile, IEntity constructedTypeOrMethod, IEntity unboundTypeOrMethod)
|
||||
{
|
||||
trapFile.WriteTuple("constructed_generic", constructedTypeOrMethod, unboundTypeOrMethod);
|
||||
}
|
||||
|
||||
internal static void constructor_location(this TextWriter trapFile, Constructor constructor, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("constructor_location", constructor, location);
|
||||
}
|
||||
|
||||
internal static void constructors(this TextWriter trapFile, Constructor key, string name, Type definingType, Constructor originalDefinition)
|
||||
{
|
||||
trapFile.WriteTuple("constructors", key, name, definingType, originalDefinition);
|
||||
}
|
||||
|
||||
internal static void delegate_return_type(this TextWriter trapFile, Type delegateKey, Type returnType)
|
||||
{
|
||||
trapFile.WriteTuple("delegate_return_type", delegateKey, returnType);
|
||||
}
|
||||
|
||||
internal static void destructor_location(this TextWriter trapFile, Destructor destructor, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("destructor_location", destructor, location);
|
||||
}
|
||||
|
||||
|
||||
internal static void destructors(this TextWriter trapFile, Destructor destructor, string name, Type containingType, Destructor original)
|
||||
{
|
||||
trapFile.WriteTuple("destructors", destructor, name, containingType, original);
|
||||
}
|
||||
|
||||
internal static void diagnostic_for(this TextWriter trapFile, Diagnostic diag, Compilation comp, int fileNo, int index)
|
||||
{
|
||||
trapFile.BeginTuple("diagnostic_for").Param(diag).Param(comp).Param(fileNo).Param(index).EndTuple();
|
||||
}
|
||||
|
||||
internal static void diagnostics(this TextWriter trapFile, Diagnostic diag, int severity, string errorTag, string errorMessage, string fullErrorMessage, Location location)
|
||||
{
|
||||
trapFile.BeginTuple("diagnostics").Param(diag).Param(severity).Param(errorTag).Param(errorMessage).Param(fullErrorMessage).Param(location).EndTuple();
|
||||
}
|
||||
|
||||
internal static void dynamic_member_name(this TextWriter trapFile, Expression e, string name) { trapFile.BeginTuple("dynamic_member_name").Param(e).Param(name).EndTuple(); }
|
||||
|
||||
internal static void enum_underlying_type(this TextWriter trapFile, Type @enum, Type type) { trapFile.WriteTuple("enum_underlying_type", @enum, type); }
|
||||
|
||||
internal static void event_accessor_location(this TextWriter trapFile, EventAccessor accessor, Location location) { trapFile.WriteTuple("event_accessor_location", accessor, location); }
|
||||
|
||||
internal static void event_accessors(this TextWriter trapFile, EventAccessor accessorKey, int type, string name, Event eventKey, EventAccessor unboundAccessor)
|
||||
{
|
||||
trapFile.BeginTuple("event_accessors").Param(accessorKey).Param(type).Param(name).Param(eventKey).Param(unboundAccessor).EndTuple();
|
||||
}
|
||||
internal static void event_location(this TextWriter trapFile, Event eventKey, Location locationKey)
|
||||
{
|
||||
trapFile.WriteTuple("event_location", eventKey, locationKey);
|
||||
}
|
||||
internal static void events(this TextWriter trapFile, Event eventKey, string name, Type declaringType, Type memberType, Event originalDefinition)
|
||||
{
|
||||
trapFile.WriteTuple("events", eventKey, name, declaringType, memberType, originalDefinition);
|
||||
}
|
||||
internal static void explicitly_implements(this TextWriter trapFile, IEntity member, Type @interface)
|
||||
{
|
||||
trapFile.WriteTuple("explicitly_implements", member, @interface);
|
||||
}
|
||||
internal static void explicitly_sized_array_creation(this TextWriter trapFile, Expression array)
|
||||
{
|
||||
trapFile.WriteTuple("explicitly_sized_array_creation", array);
|
||||
}
|
||||
internal static void expr_compiler_generated(this TextWriter trapFile, Expression expr)
|
||||
{
|
||||
trapFile.WriteTuple("expr_compiler_generated", expr);
|
||||
}
|
||||
internal static void expr_location(this TextWriter trapFile, Expression exprKey, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("expr_location", exprKey, location);
|
||||
}
|
||||
internal static void expr_access(this TextWriter trapFile, Expression expr, IEntity access)
|
||||
{
|
||||
trapFile.WriteTuple("expr_access", expr, access);
|
||||
}
|
||||
internal static void expr_argument(this TextWriter trapFile, Expression expr, int mode)
|
||||
{
|
||||
trapFile.WriteTuple("expr_argument", expr, mode);
|
||||
}
|
||||
internal static void expr_argument_name(this TextWriter trapFile, Expression expr, string name)
|
||||
{
|
||||
trapFile.WriteTuple("expr_argument_name", expr, name);
|
||||
}
|
||||
internal static void expr_call(this TextWriter trapFile, Expression expr, Method target)
|
||||
{
|
||||
trapFile.WriteTuple("expr_call", expr, target);
|
||||
}
|
||||
internal static void expr_parent(this TextWriter trapFile, Expression exprKey, int child, IExpressionParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent", exprKey, child, parent);
|
||||
}
|
||||
internal static void expr_parent_top_level(this TextWriter trapFile, Expression exprKey, int child, IExpressionParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent_top_level", exprKey, child, parent);
|
||||
}
|
||||
internal static void expr_value(this TextWriter trapFile, Expression exprKey, string value)
|
||||
{
|
||||
trapFile.WriteTuple("expr_value", exprKey, value);
|
||||
}
|
||||
internal static void expressions(this TextWriter trapFile, Expression expr, ExprKind kind, Type exprType)
|
||||
{
|
||||
trapFile.WriteTuple("expressions", expr, (int)kind, exprType);
|
||||
}
|
||||
internal static void exprorstmt_name(this TextWriter trapFile, IEntity expr, string name)
|
||||
{
|
||||
trapFile.WriteTuple("exprorstmt_name", expr, name);
|
||||
}
|
||||
internal static void extend(this TextWriter trapFile, Type type, Type super)
|
||||
{
|
||||
trapFile.WriteTuple("extend", type, super);
|
||||
}
|
||||
internal static void field_location(this TextWriter trapFile, Field field, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("field_location", field, location);
|
||||
}
|
||||
internal static void fields(this TextWriter trapFile, Field field, int @const, string name, Type declaringType, Type fieldType, Field unboundKey)
|
||||
{
|
||||
trapFile.BeginTuple("fields").Param(field).Param(@const).Param(name).Param(declaringType).Param(fieldType).Param(unboundKey).EndTuple();
|
||||
}
|
||||
internal static void general_type_parameter_constraints(this TextWriter trapFile, TypeParameterConstraints constraints, int hasKind)
|
||||
{
|
||||
trapFile.WriteTuple("general_type_parameter_constraints", constraints, hasKind);
|
||||
}
|
||||
internal static void has_modifiers(this TextWriter trapFile, IEntity entity, Modifier modifier)
|
||||
{
|
||||
trapFile.WriteTuple("has_modifiers", entity, modifier);
|
||||
}
|
||||
internal static void implement(this TextWriter trapFile, Type type, Type @interface)
|
||||
{
|
||||
trapFile.WriteTuple("implement", type, @interface);
|
||||
}
|
||||
internal static void implicitly_typed_array_creation(this TextWriter trapFile, Expression array)
|
||||
{
|
||||
trapFile.WriteTuple("implicitly_typed_array_creation", array);
|
||||
}
|
||||
internal static void indexer_location(this TextWriter trapFile, Indexer indexer, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("indexer_location", indexer, location);
|
||||
}
|
||||
internal static void indexers(this TextWriter trapFile, Indexer propKey, string name, Type declaringType, Type memberType, Indexer unboundProperty)
|
||||
{
|
||||
trapFile.WriteTuple("indexers", propKey, name, declaringType, memberType, unboundProperty);
|
||||
}
|
||||
internal static void is_constructed(this TextWriter trapFile, IEntity typeOrMethod)
|
||||
{
|
||||
trapFile.WriteTuple("is_constructed", typeOrMethod);
|
||||
}
|
||||
internal static void is_generic(this TextWriter trapFile, IEntity typeOrMethod)
|
||||
{
|
||||
trapFile.WriteTuple("is_generic", typeOrMethod);
|
||||
}
|
||||
internal static void jump_step(this TextWriter trapFile, IEntity origin, IEntity src, Statement dest)
|
||||
{
|
||||
trapFile.WriteTuple("jump_step", origin, src, dest);
|
||||
}
|
||||
internal static void local_function_stmts(this TextWriter trapFile, Entities.Statements.LocalFunction fnStmt, LocalFunction fn)
|
||||
{
|
||||
trapFile.WriteTuple("local_function_stmts", fnStmt, fn);
|
||||
}
|
||||
internal static void local_functions(this TextWriter trapFile, LocalFunction fn, string name, Type returnType, LocalFunction unboundFn)
|
||||
{
|
||||
trapFile.WriteTuple("local_functions", fn, name, returnType, unboundFn);
|
||||
}
|
||||
internal static void localvar_location(this TextWriter trapFile, LocalVariable var, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("localvar_location", var, location);
|
||||
}
|
||||
internal static void localvars(this TextWriter trapFile, LocalVariable key, int @const, string name, int @var, Type type, Expression expr)
|
||||
{
|
||||
trapFile.BeginTuple("localvars").Param(key).Param(@const).Param(name).Param(@var).Param(type).Param(expr).EndTuple();
|
||||
}
|
||||
public static void metadata_handle(this TextWriter trapFile, IEntity entity, Location assembly, int handleValue)
|
||||
{
|
||||
trapFile.WriteTuple("metadata_handle", entity, assembly, handleValue);
|
||||
}
|
||||
internal static void method_location(this TextWriter trapFile, Method method, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("method_location", method, location);
|
||||
}
|
||||
internal static void methods(this TextWriter trapFile, Method method, string name, Type declType, Type retType, Method originalDefinition)
|
||||
{
|
||||
trapFile.WriteTuple("methods", method, name, declType, retType, originalDefinition);
|
||||
}
|
||||
internal static void mutator_invocation_mode(this TextWriter trapFile, Expression expr, int mode)
|
||||
{
|
||||
trapFile.WriteTuple("mutator_invocation_mode", expr, mode);
|
||||
}
|
||||
internal static void namespace_declaration_location(this TextWriter trapFile, NamespaceDeclaration decl, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("namespace_declaration_location", decl, location);
|
||||
}
|
||||
internal static void namespace_declarations(this TextWriter trapFile, NamespaceDeclaration decl, Namespace ns)
|
||||
{
|
||||
trapFile.WriteTuple("namespace_declarations", decl, ns);
|
||||
}
|
||||
internal static void namespaces(this TextWriter trapFile, Namespace ns, string name)
|
||||
{
|
||||
trapFile.WriteTuple("namespaces", ns, name);
|
||||
}
|
||||
internal static void nested_types(this TextWriter trapFile, Type typeKey, Type declaringTypeKey, Type unboundTypeKey)
|
||||
{
|
||||
trapFile.WriteTuple("nested_types", typeKey, declaringTypeKey, unboundTypeKey);
|
||||
}
|
||||
internal static void nullable_underlying_type(this TextWriter trapFile, Type nullableType, Type underlyingType)
|
||||
{
|
||||
trapFile.WriteTuple("nullable_underlying_type", nullableType, underlyingType);
|
||||
}
|
||||
internal static void numlines(this TextWriter trapFile, IEntity label, LineCounts lineCounts)
|
||||
{
|
||||
trapFile.BeginTuple("numlines").Param(label).Param(lineCounts.Total).Param(lineCounts.Code).Param(lineCounts.Comment).EndTuple();
|
||||
}
|
||||
internal static void operator_location(this TextWriter trapFile, UserOperator @operator, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("operator_location", @operator, location);
|
||||
}
|
||||
internal static void operators(this TextWriter trapFile, UserOperator method, string methodName, string symbol, Type classKey, Type returnType, UserOperator originalDefinition)
|
||||
{
|
||||
trapFile.BeginTuple("operators").Param(method).Param(methodName).Param(symbol).Param(classKey).Param(returnType).Param(originalDefinition).EndTuple();
|
||||
}
|
||||
internal static void overrides(this TextWriter trapFile, Method overriding, Method overridden)
|
||||
{
|
||||
trapFile.WriteTuple("overrides", overriding, overridden);
|
||||
}
|
||||
internal static void param_location(this TextWriter trapFile, Parameter param, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("param_location", param, location);
|
||||
}
|
||||
internal static void @params(this TextWriter trapFile, Parameter param, string name, Type type, int child, Parameter.Kind mode, IEntity method, Parameter originalDefinition)
|
||||
{
|
||||
trapFile.BeginTuple("params").Param(param).Param(name).Param(type).Param(child).Param((int)mode).Param(method).Param(originalDefinition).EndTuple();
|
||||
}
|
||||
internal static void parent_namespace(this TextWriter trapFile, IEntity type, Namespace parent)
|
||||
{
|
||||
trapFile.WriteTuple("parent_namespace", type, parent);
|
||||
}
|
||||
internal static void parent_namespace_declaration(this TextWriter trapFile, IEntity item, NamespaceDeclaration parent)
|
||||
{
|
||||
trapFile.WriteTuple("parent_namespace_declaration", item, parent);
|
||||
}
|
||||
internal static void pointer_referent_type(this TextWriter trapFile, PointerType pointerType, Type referentType)
|
||||
{
|
||||
trapFile.WriteTuple("pointer_referent_type", pointerType, referentType);
|
||||
}
|
||||
internal static void property_location(this TextWriter trapFile, Property property, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("property_location", property, location);
|
||||
}
|
||||
internal static void properties(this TextWriter trapFile, Property propKey, string name, Type declaringType, Type memberType, Property unboundProperty)
|
||||
{
|
||||
trapFile.WriteTuple("properties", propKey, name, declaringType, memberType, unboundProperty);
|
||||
}
|
||||
internal static void statements(this TextWriter trapFile, Statement stmt, StmtKind kind)
|
||||
{
|
||||
trapFile.WriteTuple("statements", stmt, (int)kind);
|
||||
}
|
||||
internal static void specific_type_parameter_constraints(this TextWriter trapFile, TypeParameterConstraints constraints, Type baseType)
|
||||
{
|
||||
trapFile.WriteTuple("specific_type_parameter_constraints", constraints, baseType);
|
||||
}
|
||||
internal static void specific_type_parameter_annotation(this TextWriter trapFile, TypeParameterConstraints constraints, Type baseType, TypeAnnotation annotation)
|
||||
{
|
||||
trapFile.WriteTuple("specific_type_parameter_annotation", constraints, baseType, (int)annotation);
|
||||
}
|
||||
internal static void successors(this TextWriter trapFile, IEntity from, IEntity to)
|
||||
{
|
||||
trapFile.WriteTuple("successors", from, to);
|
||||
}
|
||||
internal static void stmt_location(this TextWriter trapFile, Statement stmt, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("stmt_location", stmt, location);
|
||||
}
|
||||
internal static void stmt_parent(this TextWriter trapFile, Statement stmt, int child, IStatementParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("stmt_parent", stmt, child, parent);
|
||||
}
|
||||
internal static void stmt_parent_top_level(this TextWriter trapFile, Statement stmt, int child, IStatementParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("stmt_parent_top_level", stmt, child, parent);
|
||||
}
|
||||
internal static void tuple_element(this TextWriter trapFile, TupleType type, int index, Field field)
|
||||
{
|
||||
trapFile.WriteTuple("tuple_element", type, index, field);
|
||||
}
|
||||
internal static void tuple_underlying_type(this TextWriter trapFile, TupleType type, NamedType underlying)
|
||||
{
|
||||
trapFile.WriteTuple("tuple_underlying_type", type, underlying);
|
||||
}
|
||||
|
||||
internal static void type_annotation(this TextWriter trapFile, IEntity element, Kinds.TypeAnnotation annotation)
|
||||
{
|
||||
trapFile.WriteTuple("type_annotation", element, (int)annotation);
|
||||
}
|
||||
internal static void type_argument_annotation(this TextWriter trapFile, IEntity element, int index, Kinds.TypeAnnotation annotation)
|
||||
{
|
||||
trapFile.WriteTuple("type_argument_annotation", element, index, (int)annotation);
|
||||
}
|
||||
internal static void type_mention(this TextWriter trapFile, TypeMention ta, Type type, IEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("type_mention", ta, type, parent);
|
||||
}
|
||||
internal static void type_mention_location(this TextWriter trapFile, TypeMention ta, Location loc)
|
||||
{
|
||||
trapFile.WriteTuple("type_mention_location", ta, loc);
|
||||
}
|
||||
internal static void type_arguments(this TextWriter trapFile, Type arg, int n, IEntity typeOrMethod)
|
||||
{
|
||||
trapFile.WriteTuple("type_arguments", arg, n, typeOrMethod);
|
||||
}
|
||||
internal static void type_location(this TextWriter trapFile, Type type, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("type_location", type, location);
|
||||
}
|
||||
internal static void type_parameter_constraints(this TextWriter trapFile, TypeParameterConstraints constraints, TypeParameter typeParam)
|
||||
{
|
||||
trapFile.WriteTuple("type_parameter_constraints", constraints, typeParam);
|
||||
}
|
||||
internal static void type_parameters(this TextWriter trapFile, TypeParameter param, int child, IEntity typeOrMethod)
|
||||
{
|
||||
trapFile.BeginTuple("type_parameters").Param(param).Param(child).Param(typeOrMethod).Param((int)param.Variance).EndTuple();
|
||||
}
|
||||
internal static void typeref_type(this TextWriter trapFile, NamedTypeRef typeref, Type type)
|
||||
{
|
||||
trapFile.WriteTuple("typeref_type", typeref, type);
|
||||
}
|
||||
internal static void typerefs(this TextWriter trapFile, NamedTypeRef type, string name)
|
||||
{
|
||||
trapFile.WriteTuple("typerefs", type, name);
|
||||
}
|
||||
internal static void types(this TextWriter trapFile, Type type, TypeKind kind, string name)
|
||||
{
|
||||
trapFile.BeginTuple("types").Param(type).Param((int)kind).Param(name).EndTuple();
|
||||
}
|
||||
internal static void using_namespace_directives(this TextWriter trapFile, UsingDirective @using, Namespace ns)
|
||||
{
|
||||
trapFile.WriteTuple("using_namespace_directives", @using, ns);
|
||||
}
|
||||
internal static void using_directive_location(this TextWriter trapFile, UsingDirective @using, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("using_directive_location", @using, location);
|
||||
}
|
||||
internal static void using_static_directives(this TextWriter trapFile, UsingDirective @using, Type type)
|
||||
{
|
||||
trapFile.WriteTuple("using_static_directives", @using, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Semmle.Extraction
|
||||
while (File.Exists(tmpFile));
|
||||
|
||||
var fileStream = new FileStream(tmpFile, FileMode.CreateNew, FileAccess.Write);
|
||||
var compressionStream = new GZipStream(fileStream, CompressionMode.Compress);
|
||||
var compressionStream = new BrotliStream(fileStream, CompressionLevel.Fastest);
|
||||
return new StreamWriter(compressionStream, UTF8, 2000000);
|
||||
});
|
||||
this.archive = archive;
|
||||
@@ -158,7 +158,7 @@ namespace Semmle.Extraction
|
||||
if (existingHash != hash)
|
||||
{
|
||||
var root = TrapFile.Substring(0, TrapFile.Length - 8); // Remove trailing ".trap.gz"
|
||||
if (TryMove(tmpFile, $"{root}-{hash}.trap.gz"))
|
||||
if (TryMove(tmpFile, $"{root}-{hash}.trap.br"))
|
||||
return;
|
||||
}
|
||||
Logger.Log(Severity.Info, "Identical trap file for {0} already exists", TrapFile);
|
||||
@@ -255,7 +255,7 @@ namespace Semmle.Extraction
|
||||
|
||||
public static string TrapPath(ILogger logger, string folder, string filename)
|
||||
{
|
||||
filename = Path.GetFullPath(filename) + ".trap.gz";
|
||||
filename = Path.GetFullPath(filename) + ".trap.br";
|
||||
if (string.IsNullOrEmpty(folder))
|
||||
folder = Directory.GetCurrentDirectory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user