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

Use PEModuleBuilder.IgnoreAccessibility

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