本文整理汇总了C#中System.Compiler.TypeNode类的典型用法代码示例。如果您正苦于以下问题:C# TypeNode类的具体用法?C# TypeNode怎么用?C# TypeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeNode类属于System.Compiler命名空间,在下文中一共展示了TypeNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InferTypeOfBinaryExpression
public override TypeNode InferTypeOfBinaryExpression(TypeNode t1, TypeNode t2, BinaryExpression binaryExpression)
{
//
// For addition or subtraction operations involving a set (as either operand)
// the result will be a set of the same type. Later, in the Checker, we'll
// verify that the combination of operands is valid. Here, we can quickly infer
// the type of the result.
//
switch (binaryExpression.NodeType)
{
case NodeType.Add:
case NodeType.Sub:
if (t1 is Set)
return t1;
else if (t2 is Set)
return t2;
break;
case (NodeType)ZingNodeType.In:
return SystemTypes.Boolean;
default:
break;
}
return base.InferTypeOfBinaryExpression(t1, t2, binaryExpression);
}
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:26,代码来源:ZResolver.cs
示例2: IsExposedType
/**
* <summary>IsExposedType compares the given type to itself. If this filter
* contains a '.' designating it as for a nested class it will skip
* non-nested classes. Classes with no declaring types will not be compared to
* filters with a '.'
* </summary>
*/
public bool? IsExposedType(TypeNode type)
{
bool? typeIsExposed = null;
//check if the type was nested
if (type.DeclaringType == null)
{
if (type.Name.Name == name)
typeIsExposed = exposed;
}
//if we are nested then check if this filter is for a nested class
//check that nothing used is null also.
//if the name attribute is not there in the config name can be null here.
else if (name != null && name.Contains("."))
{
//Get a stack of declaring type names
Stack < string > parentNames = new Stack < string >();
parentNames.Push(type.Name.Name); //start with this one
TypeNode parent = type.DeclaringType;
while (parent != null)
{
parentNames.Push(parent.Name.Name);
parent = parent.DeclaringType;
}
//put them back in the correct order and check the name
if (name.Equals(String.Join(".", parentNames.ToArray())))
typeIsExposed = exposed;
}
return typeIsExposed;
}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:40,代码来源:TypeFilter.cs
示例3: CollectOldExpressions
public CollectOldExpressions(Module module, Method method, ContractNodes contractNodes, Dictionary<TypeNode, Local> closureLocals,
int localCounterStart, Class initialClosureClass)
: this(module, method, contractNodes, closureLocals, localCounterStart)
{
this.topLevelClosureClass = initialClosureClass;
this.currentClosureClass = initialClosureClass;
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:CollectOldExpressions.cs
示例4: CurrentState
private CurrentState(TypeNode type, Dictionary<string, object> typeSuppressed, Method method)
{
this.Type = type;
this.typeSuppressed = typeSuppressed;
this.Method = method;
this.methodSuppressed = null;
}
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:7,代码来源:Rewriter.cs
示例5: GetTypeName
public override string GetTypeName(TypeNode type) {
using (TextWriter writer = new StringWriter()) {
writer.Write("T:");
WriteType(type, writer);
return (writer.ToString());
}
}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:7,代码来源:OrcasNamer.cs
示例6: GetNamespace
public static Namespace GetNamespace(TypeNode type) {
if (type.DeclaringType != null) {
return (GetNamespace(type.DeclaringType));
} else {
return (new Namespace(type.Namespace));
}
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:7,代码来源:Reflection.cs
示例7: HandlersMatching
/// <summary>
/// Returns a list of CfgBlock that are handlers of the current block, handling an exception
/// of the given type, or a subtype thereof.
/// </summary>
/// <param name="exception">Type of exception thrown. It is assumed that any actual subtype could be thrown</param>
/// <returns>All handlers that could apply directly to this exception.
/// In addition, if the method might not handle it, then the ExceptionExit block is
/// part of this list.</returns>
public System.Collections.IEnumerable/*CfgBlock*/ HandlersMatching(TypeNode exception) {
ArrayList handlers = new ArrayList();
CfgBlock currentBlock = this;
while (currentBlock != null) {
CfgBlock handler = this.cfg.ExceptionHandler(currentBlock);
if (handler == null || handler.Statements == null || handler.Statements.Count < 1) break;
Catch stat = handler.Statements[0] as Catch;
if (stat != null) {
if (exception.IsAssignableTo(stat.Type)) {
// handles exceptions completely
handlers.Add(handler);
break;
}
if (stat.Type.IsAssignableTo(exception)) {
// handles part of it
handlers.Add(handler);
}
currentBlock = handler;
}
else {
// must be the Unwind block
handlers.Add(handler);
break;
}
}
return handlers;
}
开发者ID:hesam,项目名称:SketchSharp,代码行数:40,代码来源:ControlFlow.cs
示例8: ImplicitCoercionFromTo
//
// We add an implicit conversion from "object" to any of our heap-allocated
// types.
//
// We also permit implicit conversions between "int" and "byte".
//
// TODO: We may need to construct a more elaborate expression here for the
// conversion to permit the runtime to make the appropriate checks.
//
public override bool ImplicitCoercionFromTo(Expression source, TypeNode t1, TypeNode t2)
{
if (t1 == SystemTypes.Object)
{
if (t2 is Chan || t2 is Set || t2 is ZArray || t2 is Class)
return true;
else
return false;
}
if (t2 == SystemTypes.Object)
{
if (t1 is Chan || t1 is Set || t1 is ZArray || t1 is Class)
return true;
else
return false;
}
if (t1 == SystemTypes.Int32 && t2 == SystemTypes.UInt8)
return true;
if (t1 == SystemTypes.UInt8 && t2 == SystemTypes.Int32)
return true;
return base.ImplicitCoercionFromTo(source, t1, t2);
}
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:35,代码来源:TypeSystem.cs
示例9: CoerceAnonymousNestedFunction
public override Expression CoerceAnonymousNestedFunction(AnonymousNestedFunction func, TypeNode targetType, bool explicitCoercion, TypeViewer typeViewer) {
if (func is AnonymousNestedDelegate && !(targetType is DelegateNode)) {
this.HandleError(func, Error.AnonMethToNonDel, this.GetTypeName(targetType));
return null;
}
return base.CoerceAnonymousNestedFunction(func, targetType, explicitCoercion, typeViewer);
}
开发者ID:hesam,项目名称:SketchSharp,代码行数:7,代码来源:TypeSystem.cs
示例10: Duplicator
/// <param name="module">The module into which the duplicate IR will be grafted.</param>
/// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
public Duplicator(Module/*!*/ module, TypeNode type)
{
this.TargetModule = module;
this.TargetType = this.OriginalTargetType = type;
this.DuplicateFor = new TrivialHashtable();
this.TypesToBeDuplicated = new TrivialHashtable();
//^ base();
}
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:10,代码来源:Duplicator.cs
示例11: GetTypeName
/// <inheritdoc />
public override string GetTypeName(TypeNode type)
{
StringBuilder sb = new StringBuilder("T:");
WriteType(type, sb);
return sb.ToString();
}
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:9,代码来源:OrcasNamer.cs
示例12: VisitTypeNode
public override void VisitTypeNode(TypeNode typeNode)
{
if (typeNode == null) return;
ScrubAttributeList(typeNode.Attributes);
this.VisitMemberList(typeNode.Members);
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:8,代码来源:RemoveContractClasses.cs
示例13: HasExposedMembers
//Find out if any are exposed incase this class is not exposed
public bool HasExposedMembers(TypeNode type)
{
foreach (Member member in type.Members)
foreach (MemberFilter memberFilter in memberFilters)
if (memberFilter.IsExposedMember(member) == true)
return true;
return false;
}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:10,代码来源:TypeFilter.cs
示例14: IsRuntimeIgnored
public static bool IsRuntimeIgnored(Node node, ContractNodes contractNodes, TypeNode referencingType, bool skipQuantifiers)
{
CodeInspector ifrv = new CodeInspector(
ContractNodes.RuntimeIgnoredAttributeName, contractNodes, referencingType, skipQuantifiers);
ifrv.Visit(node);
return ifrv.foundAttribute;
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:9,代码来源:CodeInspector.cs
示例15: ScrubContractClass
public ScrubContractClass(ExtractorVisitor parent, Class contractClass, TypeNode originalType)
{
Contract.Requires(TypeNode.IsCompleteTemplate(contractClass));
Contract.Requires(TypeNode.IsCompleteTemplate(originalType));
this.parent = parent;
this.contractClass = contractClass;
this.abstractClass = originalType;
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:9,代码来源:ScrubContractClass.cs
示例16: Contains
/// <summary>
/// actualReturn type is null if Task is not generic, otherwise ,the Task result type.
/// </summary>
public static bool Contains(Node node, ContractNodes contractNodes, Method currentMethod,
TypeNode actualReturnType)
{
var v = new AsyncReturnValueQuery(contractNodes, currentMethod, actualReturnType);
v.Visit(node);
return v.foundReturnValueTaskResult;
}
开发者ID:a780201,项目名称:CodeContracts,代码行数:12,代码来源:AsyncReturnValueQuery.cs
示例17: IsExposedType
// we are satistied with the default namespace expose test, so don't override it
public override bool IsExposedType(TypeNode type) {
if (type == null) throw new ArgumentNullException("type");
// expose any visible types allowed by the base filter
if (type.IsVisibleOutsideAssembly) {
return (base.IsExposedType(type));
} else {
return (false);
}
// return(type.IsVisibleOutsideAssembly);
}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:12,代码来源:ExternalDocumentedFilter.cs
示例18: VisitMethod
public override Method VisitMethod(Method method)
{
Method re = base.VisitMethod(method);
System.Compiler.TypeNode sigTmp = re.ReturnType;
if(sigTmp.TypeCode!=TypeCode.Empty)
signatureType = sigTmp;
return re;
}
开发者ID:Jescy,项目名称:Matching_spec_Specification,代码行数:10,代码来源:MyVisitor.cs
示例19: AddExtensionMethod
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <param name="type">the current type being extended</param>
/// <param name="extensionMethodTemplate">A reference to the extension method. For generic methods, this is a reference to the
/// non-specialized method, e.g. System.Linq.Enumerable.Select``2.
/// </param>
/// <param name="specialization">When the current type implements or inherits from a specialization of a generic type,
/// this parameter has a TypeNode for the type used as apecialization of the generic type's first template param.
/// </param>
private void AddExtensionMethod(XmlWriter writer, TypeNode type, Method extensionMethodTemplate, TypeNode specialization)
{
// If this is a specialization of a generic method, construct a Method object that describes the specialization
Method extensionMethodTemplate2 = extensionMethodTemplate;
if (extensionMethodTemplate2.IsGeneric && (specialization != null))
{
// the specialization type is the first of the method's template arguments
TypeNodeList templateArgs = new TypeNodeList();
templateArgs.Add(specialization);
// add any additional template arguments
for (int i = 1; i < extensionMethodTemplate.TemplateParameters.Count; i++)
templateArgs.Add(extensionMethodTemplate.TemplateParameters[i]);
extensionMethodTemplate2 = extensionMethodTemplate.GetTemplateInstance(type, templateArgs);
}
TypeNode extensionMethodTemplateReturnType = extensionMethodTemplate2.ReturnType;
ParameterList extensionMethodTemplateParameters = extensionMethodTemplate2.Parameters;
ParameterList extensionMethodParameters = new ParameterList();
for (int i = 1; i < extensionMethodTemplateParameters.Count; i++)
{
Parameter extensionMethodParameter = extensionMethodTemplateParameters[i];
extensionMethodParameters.Add(extensionMethodParameter);
}
Method extensionMethod = new Method(extensionMethodTemplate.DeclaringType, new AttributeList(), extensionMethodTemplate.Name, extensionMethodParameters, extensionMethodTemplate.ReturnType, null);
extensionMethod.Flags = extensionMethodTemplate.Flags & ~MethodFlags.Static;
// for generic methods, set the template args and params so the template data is included in the id and the method data
if (extensionMethodTemplate2.IsGeneric)
{
extensionMethod.IsGeneric = true;
if (specialization != null)
{
// set the template args for the specialized generic method
extensionMethod.TemplateArguments = extensionMethodTemplate2.TemplateArguments;
}
else
{
// set the generic template params for the non-specialized generic method
extensionMethod.TemplateParameters = extensionMethodTemplate2.TemplateParameters;
}
}
// Get the id
string extensionMethodTemplateId = reflector.ApiNamer.GetMemberName(extensionMethodTemplate);
// write the element node
writer.WriteStartElement("element");
writer.WriteAttributeString("api", extensionMethodTemplateId);
writer.WriteAttributeString("source", "extension");
isExtensionMethod = true;
reflector.WriteMember(extensionMethod);
isExtensionMethod = false;
writer.WriteEndElement();
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:65,代码来源:ExtensionMethodAddIn.cs
示例20: ImplicitCoercion
public override Expression ImplicitCoercion(Expression source, TypeNode targetType, TypeViewer typeViewer)
{
// LJW: added third parameter "typeViewer" so we override the correct thing
if (source == null || source.Type == null || targetType == null)
return null;
if (source.Type is EnumNode && targetType == SystemTypes.Int32)
{
return source;
}
if (source.Type == SystemTypes.Object)
{
if (targetType is Chan || targetType is Set || targetType is ZArray || targetType is Class)
return source;
else
{
this.HandleError(source, System.Compiler.Error.NoImplicitCoercion, "object", targetType.FullName);
return null;
}
}
if (targetType == SystemTypes.Object)
{
if (!(source.Type is Chan || source.Type is Set || source.Type is ZArray || source.Type is Class))
{
this.HandleError(source, System.Compiler.Error.NoImplicitCoercion, source.Type.FullName, "object");
return null;
}
}
if (source.Type == SystemTypes.Int32 && targetType == SystemTypes.UInt8)
{
BinaryExpression binExpr = new BinaryExpression(source, new MemberBinding(null, SystemTypes.UInt8),
NodeType.Castclass, source.SourceContext);
binExpr.Type = SystemTypes.UInt8;
return binExpr;
}
if (source.Type == SystemTypes.UInt8 && targetType == SystemTypes.Int32)
{
BinaryExpression binExpr = new BinaryExpression(source, new MemberBinding(null, SystemTypes.Int32),
NodeType.Castclass, source.SourceContext);
binExpr.Type = SystemTypes.Int32;
return binExpr;
}
return base.ImplicitCoercion(source, targetType, typeViewer);
}
开发者ID:ZingModelChecker,项目名称:Zing,代码行数:53,代码来源:TypeSystem.cs
注:本文中的System.Compiler.TypeNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论