提交 a827fee8 编写于 作者: C Charles Stoner

Use PEModuleBuilder.IgnoreAccessibility

上级 fbad195c
......@@ -1201,8 +1201,7 @@ private BoundStatement ChainImplicitStructConstructor(MethodSymbol methodSymbol,
lazyVariableSlotAllocator,
compilationState,
diagnostics,
assignLocals: false,
allowNonPublicTypeArguments: false);
assignLocals: false);
}
if (bodyWithoutLambdas.HasErrors)
......
......@@ -14,7 +14,7 @@ internal class ExpressionLambdaRewriter // this is like a bound tree rewriter, b
private readonly SyntheticBoundNodeFactory _bound;
private readonly TypeMap _typeMap;
private readonly Dictionary<ParameterSymbol, BoundExpression> _parameterMap = new Dictionary<ParameterSymbol, BoundExpression>();
private readonly bool _allowNonPublicTypeArguments;
private readonly bool _ignoreAccessibility;
private NamedTypeSymbol _ExpressionType;
private NamedTypeSymbol ExpressionType
......@@ -92,10 +92,10 @@ private NamedTypeSymbol MemberInfoType
private DiagnosticBag Diagnostics { get { return _bound.Diagnostics; } }
private ExpressionLambdaRewriter(TypeCompilationState compilationState, TypeMap typeMap, bool allowNonPublicTypeArguments, CSharpSyntaxNode node, DiagnosticBag diagnostics)
private ExpressionLambdaRewriter(TypeCompilationState compilationState, TypeMap typeMap, CSharpSyntaxNode node, DiagnosticBag diagnostics)
{
_bound = new SyntheticBoundNodeFactory(null, compilationState.Type, node, compilationState, diagnostics);
_allowNonPublicTypeArguments = allowNonPublicTypeArguments;
_ignoreAccessibility = compilationState.ModuleBuilderOpt.IgnoreAccessibility;
_int32Type = _bound.SpecialType(SpecialType.System_Int32);
_objectType = _bound.SpecialType(SpecialType.System_Object);
_nullableType = _bound.SpecialType(SpecialType.System_Nullable_T);
......@@ -104,11 +104,11 @@ private ExpressionLambdaRewriter(TypeCompilationState compilationState, TypeMap
_typeMap = typeMap;
}
internal static BoundNode RewriteLambda(BoundLambda node, TypeCompilationState compilationState, TypeMap typeMap, bool allowNonPublicTypeArguments, DiagnosticBag diagnostics)
internal static BoundNode RewriteLambda(BoundLambda node, TypeCompilationState compilationState, TypeMap typeMap, DiagnosticBag diagnostics)
{
try
{
var r = new ExpressionLambdaRewriter(compilationState, typeMap, allowNonPublicTypeArguments, node.Syntax, diagnostics);
var r = new ExpressionLambdaRewriter(compilationState, typeMap, node.Syntax, diagnostics);
var result = r.VisitLambdaInternal(node);
if (node.Type != result.Type)
{
......@@ -972,7 +972,7 @@ private BoundExpression ExprFactory(string name, params BoundExpression[] argume
private BoundExpression ExprFactory(string name, ImmutableArray<TypeSymbol> typeArgs, params BoundExpression[] arguments)
{
return _bound.StaticCall(_allowNonPublicTypeArguments ? BinderFlags.IgnoreAccessibility : BinderFlags.None, ExpressionType, name, typeArgs, arguments);
return _bound.StaticCall(_ignoreAccessibility ? BinderFlags.IgnoreAccessibility : BinderFlags.None, ExpressionType, name, typeArgs, arguments);
}
private BoundExpression ExprFactory(WellKnownMember method, ImmutableArray<TypeSymbol> typeArgs, params BoundExpression[] arguments)
......
......@@ -79,9 +79,6 @@ internal sealed partial class LambdaRewriter : MethodToClassRewriter
// expression evaluator where the original locals are left as is.
private readonly bool _assignLocals;
// Allow type arguments of constructed methods to be non-public.
private readonly bool _allowNonPublicTypeArguments;
// The current method or lambda being processed.
private MethodSymbol _currentMethod;
......@@ -131,8 +128,7 @@ internal sealed partial class LambdaRewriter : MethodToClassRewriter
VariableSlotAllocator slotAllocatorOpt,
TypeCompilationState compilationState,
DiagnosticBag diagnostics,
bool assignLocals,
bool allowNonPublicTypeArguments)
bool assignLocals)
: base(slotAllocatorOpt, compilationState, diagnostics)
{
Debug.Assert(analysis != null);
......@@ -147,7 +143,6 @@ internal sealed partial class LambdaRewriter : MethodToClassRewriter
_currentMethod = method;
_analysis = analysis;
_assignLocals = assignLocals;
_allowNonPublicTypeArguments = allowNonPublicTypeArguments;
_currentTypeParameters = method.TypeParameters;
_currentLambdaBodyTypeMap = TypeMap.Empty;
_innermostFramePointer = _currentFrameThis = thisParameterOpt;
......@@ -179,7 +174,6 @@ protected override bool NeedsProxy(Symbol localOrParameter)
/// <param name="compilationState">The caller's buffer into which we produce additional methods to be emitted by the caller</param>
/// <param name="diagnostics">Diagnostic bag for diagnostics</param>
/// <param name="assignLocals">The rewritten tree should include assignments of the original locals to the lifted proxies</param>
/// <param name="allowNonPublicTypeArguments">Allow type arguments of constructed methods to be non-public</param>
public static BoundStatement Rewrite(
BoundStatement loweredBody,
NamedTypeSymbol thisType,
......@@ -191,8 +185,7 @@ protected override bool NeedsProxy(Symbol localOrParameter)
VariableSlotAllocator slotAllocatorOpt,
TypeCompilationState compilationState,
DiagnosticBag diagnostics,
bool assignLocals,
bool allowNonPublicTypeArguments)
bool assignLocals)
{
Debug.Assert((object)thisType != null);
Debug.Assert(((object)thisParameter == null) || (thisParameter.Type == thisType));
......@@ -220,8 +213,7 @@ protected override bool NeedsProxy(Symbol localOrParameter)
slotAllocatorOpt,
compilationState,
diagnostics,
assignLocals,
allowNonPublicTypeArguments);
assignLocals);
analysis.ComputeLambdaScopesAndFrameCaptures();
rewriter.MakeFrames(closureDebugInfoBuilder);
......@@ -999,7 +991,7 @@ private BoundNode RewriteLambdaConversion(BoundLambda node)
var newType = VisitType(node.Type);
var newBody = (BoundBlock)Visit(node.Body);
node = node.Update(node.Symbol, newBody, node.Diagnostics, node.Binder, newType);
var result0 = wasInExpressionLambda ? node : ExpressionLambdaRewriter.RewriteLambda(node, CompilationState, TypeMap, _allowNonPublicTypeArguments, Diagnostics);
var result0 = wasInExpressionLambda ? node : ExpressionLambdaRewriter.RewriteLambda(node, CompilationState, TypeMap, Diagnostics);
_inExpressionLambda = wasInExpressionLambda;
return result0;
}
......
......@@ -565,8 +565,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState,
slotAllocatorOpt: null,
compilationState: compilationState,
diagnostics: diagnostics,
assignLocals: true,
allowNonPublicTypeArguments: true);
assignLocals: true);
// we don't need this information:
closureDebugInfoBuilder.Free();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册