本文整理汇总了C#中DType.GetConstant方法的典型用法代码示例。如果您正苦于以下问题:C# DType.GetConstant方法的具体用法?C# DType.GetConstant怎么用?C# DType.GetConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DType
的用法示例。
在下文中一共展示了DType.GetConstant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveClassConstantName
internal DConstant ResolveClassConstantName(DType/*!*/ type, VariableName constantName,
Position position, PhpType referringType, PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime)
{
checkVisibilityAtRuntime = false;
// we cannot resolve a class constant unless we know the inherited members:
if (type.IsDefinite)
{
ClassConstant constant;
GetMemberResult member_result = type.GetConstant(constantName, referringType, out constant);
switch (member_result)
{
case GetMemberResult.OK:
return constant;
case GetMemberResult.NotFound:
ErrorSink.Add(Errors.UnknownClassConstantAccessed, SourceUnit, position, type.FullName, constantName);
return new UnknownClassConstant(type, constantName.Value);
case GetMemberResult.BadVisibility:
if (referringType == null && referringRoutine == null)
{
// visibility must be checked at run-time:
checkVisibilityAtRuntime = true;
return constant;
}
else
{
// definitive error:
if (constant.IsPrivate)
{
ErrorSink.Add(Errors.PrivateConstantAccessed, SourceUnit, position, type.FullName, constantName.Value,
referringType.FullName);
}
else
{
ErrorSink.Add(Errors.ProtectedConstantAccessed, SourceUnit, position, type.FullName, constantName.Value,
referringType.FullName);
}
return new UnknownClassConstant(type, constantName.Value);
}
default:
Debug.Fail();
throw null;
}
}
else
{
// warning (if any) reported by the type resolver:
return new UnknownClassConstant(type, constantName.Value);
}
}