本文整理汇总了C#中SpecialMember类的典型用法代码示例。如果您正苦于以下问题:C# SpecialMember类的具体用法?C# SpecialMember怎么用?C# SpecialMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpecialMember类属于命名空间,在下文中一共展示了SpecialMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RewriteDelegateOperation
private BoundNode RewriteDelegateOperation(BoundBinaryOperator node, SpecialMember member)
{
Debug.Assert(node != null);
var method = (MethodSymbol)this.compilation.Assembly.GetSpecialTypeMember(member);
// UNDONE: Handle the bizarre error case where we don't have the expected methods.
Debug.Assert(method != null);
BoundExpression call = BoundCall.SynthesizedCall(null, method, node.Left, node.Right);
BoundExpression result = method.ReturnType.SpecialType == SpecialType.System_Delegate ?
BoundConversion.SynthesizedConversion(call, ConversionKind.ExplicitReference, node.Type) :
call;
return Visit(result);
}
示例2: ReportErrorOnSpecialMember
private static void ReportErrorOnSpecialMember(Symbol symbol, SpecialMember member, DiagnosticBag diagnostics, ref bool hasError)
{
if ((object)symbol == null)
{
MemberDescriptor memberDescriptor = SpecialMembers.GetDescriptor(member);
diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, NoLocation.Singleton,
((SpecialType)memberDescriptor.DeclaringTypeId).GetMetadataName(), memberDescriptor.Name);
hasError = true;
}
else
{
ReportErrorOnSymbol(symbol, diagnostics, ref hasError);
}
}
示例3: RewriteStringEquality
private BoundNode RewriteStringEquality(BoundBinaryOperator node, SpecialMember member)
{
Debug.Assert(node != null);
Debug.Assert(node.ConstantValueOpt == null);
if (node.Left.ConstantValue == ConstantValue.Null || node.Right.ConstantValue == ConstantValue.Null)
{
return base.VisitBinaryOperator(node);
}
var method = (MethodSymbol)this.compilation.Assembly.GetSpecialTypeMember(member);
Debug.Assert(method != null);
return Visit(BoundCall.SynthesizedCall(null, method, node.Left, node.Right));
}
示例4: SpecialProperty
public PropertySymbol SpecialProperty(SpecialMember sm)
{
return (PropertySymbol)SpecialMember(sm);
}
示例5: SpecialMethod
public MethodSymbol SpecialMethod(SpecialMember sm)
{
return (MethodSymbol)SpecialMember(sm);
}
示例6: SpecialMember
/// <summary>
/// Get the symbol for a special member. The use of this method to get a special member
/// that does not exist will result in an exception of type MissingPredefinedMember being thrown
/// containing an appropriate diagnostic for the caller to report.
/// </summary>
/// <param name="sm">The desired special member</param>
/// <returns>A symbol for the special member.</returns>
public Symbol SpecialMember(SpecialMember sm)
{
Symbol specialMember = Compilation.GetSpecialTypeMember(sm);
if (specialMember == null)
{
RuntimeMembers.MemberDescriptor memberDescriptor = SpecialMembers.GetDescriptor(sm);
SpecialType containingType = (SpecialType)memberDescriptor.DeclaringTypeId;
var diagnostic = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, containingType.GetMetadataName(), memberDescriptor.Name), Syntax.Location);
throw new MissingPredefinedMember(diagnostic);
}
Binder.ReportUseSiteDiagnostics(specialMember, Diagnostics, Syntax);
return specialMember;
}
示例7: OpenPropertyImplementation
public MethodSymbol OpenPropertyImplementation(NamedTypeSymbol interfaceType, SpecialMember interfaceProperty, bool debuggerHidden = false)
{
var methodToImplement = (((PropertySymbol)SpecialMember(interfaceProperty)).GetMethod).AsMember(interfaceType);
return OpenPropertyImplementation(methodToImplement, debuggerHidden);
}
示例8: GetDeclaredSpecialTypeMember
/// <summary>
/// Lookup member declaration in predefined CorLib type in this Assembly. Only valid if this
/// assembly is the Cor Library
/// </summary>
internal override Symbol GetDeclaredSpecialTypeMember(SpecialMember member)
{
#if DEBUG
foreach (var module in this.Modules)
{
Debug.Assert(module.GetReferencedAssemblies().Length == 0);
}
#endif
if (_lazySpecialTypeMembers == null || ReferenceEquals(_lazySpecialTypeMembers[(int)member], ErrorTypeSymbol.UnknownResultType))
{
if (_lazySpecialTypeMembers == null)
{
var specialTypeMembers = new Symbol[(int)SpecialMember.Count];
for (int i = 0; i < specialTypeMembers.Length; i++)
{
specialTypeMembers[i] = ErrorTypeSymbol.UnknownResultType;
}
Interlocked.CompareExchange(ref _lazySpecialTypeMembers, specialTypeMembers, null);
}
var descriptor = SpecialMembers.GetDescriptor(member);
NamedTypeSymbol type = GetDeclaredSpecialType((SpecialType)descriptor.DeclaringTypeId);
Symbol result = null;
if (!type.IsErrorType())
{
result = CSharpCompilation.GetRuntimeMember(type, ref descriptor, CSharpCompilation.SpecialMembersSignatureComparer.Instance, accessWithinOpt: null);
}
Interlocked.CompareExchange(ref _lazySpecialTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType);
}
return _lazySpecialTypeMembers[(int)member];
}
示例9: RewriteStringEquality
private BoundExpression RewriteStringEquality(BoundBinaryOperator oldNode, CSharpSyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, SpecialMember member)
{
if (oldNode != null && (loweredLeft.ConstantValue == ConstantValue.Null || loweredRight.ConstantValue == ConstantValue.Null))
{
return oldNode.Update(operatorKind, loweredLeft, loweredRight, oldNode.ConstantValueOpt, oldNode.MethodOpt, oldNode.ResultKind, type);
}
var method = GetSpecialTypeMethod(syntax, member);
Debug.Assert((object)method != null);
return BoundCall.Synthesized(syntax, null, method, loweredLeft, loweredRight);
}
示例10: IsMemberMissing
internal bool IsMemberMissing(SpecialMember member)
{
return IsMemberMissing(-(int)member - 1);
}
示例11: GetDescriptor
public static MemberDescriptor GetDescriptor(SpecialMember member)
{
return descriptors[(int)member];
}
示例12: GetDeclaredSpecialTypeMember
internal override Symbol GetDeclaredSpecialTypeMember(SpecialMember member)
{
return null;
}
示例13: GetDeclaredSpecialTypeMember
/// <summary>
/// Lookup member declaration in predefined CorLib type in this Assembly. Only valid if this
/// assembly is the Cor Library
/// </summary>
internal Symbol GetDeclaredSpecialTypeMember(SpecialMember member)
{
if (_lazySpecialTypeMembers == null || ReferenceEquals(_lazySpecialTypeMembers[(int)member], ErrorTypeSymbol.UnknownResultType))
{
if (_lazySpecialTypeMembers == null)
{
var specialTypeMembers = new Symbol[(int)SpecialMember.Count];
for (int i = 0; i < specialTypeMembers.Length; i++)
{
specialTypeMembers[i] = ErrorTypeSymbol.UnknownResultType;
}
Interlocked.CompareExchange(ref _lazySpecialTypeMembers, specialTypeMembers, null);
}
var descriptor = SpecialMembers.GetDescriptor(member);
NamedTypeSymbol type = GetDeclaredSpecialType((SpecialType)descriptor.DeclaringTypeId);
Symbol result = null;
if (!type.IsErrorType())
{
result = PhpCompilation.GetRuntimeMember(type, ref descriptor, PhpCompilation.SpecialMembersSignatureComparer.Instance, null);
}
Interlocked.CompareExchange(ref _lazySpecialTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType);
}
return _lazySpecialTypeMembers[(int)member];
}
示例14: EnsureSpecialPropertyGetter
/// <summary>
/// Check that the property and its getter exist and collect any use-site errors.
/// </summary>
private void EnsureSpecialPropertyGetter(SpecialMember member, DiagnosticBag bag)
{
PropertySymbol symbol = (PropertySymbol)EnsureSpecialMember(member, bag);
if ((object)symbol != null)
{
var getter = symbol.GetMethod;
if ((object)getter == null)
{
Binder.Error(bag, ErrorCode.ERR_PropertyLacksGet, body.Syntax, symbol);
return;
}
var info = getter.GetUseSiteDiagnostic();
if ((object)info != null)
{
bag.Add(new CSDiagnostic(info, body.Syntax.Location));
}
}
}
示例15: EnsureSpecialMember
private Symbol EnsureSpecialMember(SpecialMember member, DiagnosticBag bag)
{
Symbol symbol;
Binder.TryGetSpecialTypeMember(F.Compilation, member, body.Syntax, bag, out symbol);
return symbol;
}