本文整理汇总了C#中ComposedType类的典型用法代码示例。如果您正苦于以下问题:C# ComposedType类的具体用法?C# ComposedType怎么用?C# ComposedType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComposedType类属于命名空间,在下文中一共展示了ComposedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitComposedType
public override void VisitComposedType(ComposedType composedType)
{
// Note: we specifically do not handle this case because the 'base' implementation will eventually
// call VisitMemberType() or VisitSimpleType() on the ComposedType.BaseType which is all we really
// care to resolve.
base.VisitComposedType (composedType);
}
示例2: VisitComposedType
public override void VisitComposedType(ComposedType composedType)
{
var spec = composedType.ArraySpecifiers.FirstOrDefault();
if (spec != null)
ForceSpacesBefore(spec.LBracketToken, policy.SpaceBeforeArrayDeclarationBrackets);
if (composedType.HasNullableSpecifier)
ForceSpacesBefore(composedType.NullableSpecifierToken, false);
if (composedType.PointerRank > 0)
foreach (var token in composedType.PointerTokens)
ForceSpacesBefore(token, false);
base.VisitComposedType(composedType);
}
示例3: Visit
public override object Visit(ComposedCast composedCast)
{
var result = new ComposedType();
result.AddChild(ConvertToType(composedCast.Left), Roles.Type);
var spec = composedCast.Spec;
while (spec != null) {
if (spec.IsNullable) {
result.AddChild(new CSharpTokenNode(Convert(spec.Location), ComposedType.NullableRole), ComposedType.NullableRole);
} else if (spec.IsPointer) {
result.AddChild(new CSharpTokenNode(Convert(spec.Location), ComposedType.PointerRole), ComposedType.PointerRole);
} else {
var aSpec = new ArraySpecifier();
aSpec.AddChild(new CSharpTokenNode(Convert(spec.Location), Roles.LBracket), Roles.LBracket);
var location = LocationsBag.GetLocations(spec);
if (location != null)
aSpec.AddChild(new CSharpTokenNode(Convert(spec.Location), Roles.RBracket), Roles.RBracket);
result.AddChild(aSpec, ComposedType.ArraySpecifierRole);
}
spec = spec.Next;
}
return result;
}
示例4: ConvertToType
AstType ConvertToType(Mono.CSharp.Expression typeName)
{
if (typeName == null) // may happen in typeof(Generic<,,,,>)
return new SimpleType();
var typeExpr = typeName as TypeExpression;
if (typeExpr != null) {
return new PrimitiveType(typeExpr.GetSignatureForError(), Convert(typeExpr.Location));
}
var qam = typeName as QualifiedAliasMember;
if (qam != null) {
var loc = LocationsBag.GetLocations(typeName);
var memberType = new MemberType();
memberType.Target = new SimpleType(qam.alias, Convert(qam.Location));
memberType.IsDoubleColon = true;
if (loc != null && loc.Count > 0)
memberType.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.DoubleColon), Roles.DoubleColon);
memberType.MemberNameToken = Identifier.Create(qam.Name, loc != null ? Convert(loc [1]) : TextLocation.Empty);
AddTypeArguments(qam, memberType);
return memberType;
}
var ma = typeName as MemberAccess;
if (ma != null) {
var memberType = new MemberType();
memberType.AddChild(ConvertToType(ma.LeftExpression), MemberType.TargetRole);
var loc = LocationsBag.GetLocations(ma);
if (loc != null)
memberType.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Dot), Roles.Dot);
memberType.MemberNameToken = Identifier.Create(ma.Name, Convert(ma.Location));
AddTypeArguments(ma, memberType);
return memberType;
}
var sn = typeName as SimpleName;
if (sn != null) {
var result = new SimpleType(sn.Name, Convert(sn.Location));
AddTypeArguments(sn, result);
return result;
}
var cc = typeName as ComposedCast;
if (cc != null) {
var baseType = ConvertToType(cc.Left);
var result = new ComposedType { BaseType = baseType };
var ccSpec = cc.Spec;
while (ccSpec != null) {
if (ccSpec.IsNullable) {
result.AddChild(new CSharpTokenNode(Convert(ccSpec.Location), ComposedType.NullableRole), ComposedType.NullableRole);
} else if (ccSpec.IsPointer) {
result.AddChild(new CSharpTokenNode(Convert(ccSpec.Location), ComposedType.PointerRole), ComposedType.PointerRole);
} else {
var location = LocationsBag.GetLocations(ccSpec);
var spec = new ArraySpecifier { Dimensions = ccSpec.Dimension };
spec.AddChild(new CSharpTokenNode(Convert(ccSpec.Location), Roles.LBracket), Roles.LBracket);
if (location != null)
spec.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.RBracket), Roles.RBracket);
result.ArraySpecifiers.Add(spec);
}
ccSpec = ccSpec.Next;
}
return result;
}
var sce = typeName as SpecialContraintExpr;
if (sce != null) {
switch (sce.Constraint) {
case SpecialConstraint.Class:
return new PrimitiveType("class", Convert(sce.Location));
case SpecialConstraint.Struct:
return new PrimitiveType("struct", Convert(sce.Location));
case SpecialConstraint.Constructor:
return new PrimitiveType("new", Convert(sce.Location));
}
}
return new SimpleType("unknown");
}
示例5: ConvertToType
AstType ConvertToType (Mono.CSharp.Expression typeName)
{
if (typeName == null) // may happen in typeof(Generic<,,,,>)
return new SimpleType ();
if (typeName is TypeExpression) {
var typeExpr = (Mono.CSharp.TypeExpression)typeName;
return new PrimitiveType (typeExpr.GetSignatureForError (), Convert (typeExpr.Location));
}
if (typeName is Mono.CSharp.QualifiedAliasMember) {
var qam = (Mono.CSharp.QualifiedAliasMember)typeName;
var memberType = new MemberType ();
memberType.Target = new SimpleType (qam.alias, Convert (qam.Location));
memberType.IsDoubleColon = true;
memberType.MemberName = qam.Name;
return memberType;
}
if (typeName is MemberAccess) {
MemberAccess ma = (MemberAccess)typeName;
var memberType = new MemberType ();
memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole);
memberType.AddChild (new CSharpTokenNode (Convert (ma.DotLocation), 1), MemberType.Roles.Dot);
memberType.MemberNameToken = Identifier.Create (ma.Name, Convert (ma.Location));
AddTypeArguments (ma, memberType);
return memberType;
}
if (typeName is SimpleName) {
var sn = (SimpleName)typeName;
var result = new SimpleType (sn.Name, Convert (sn.Location));
AddTypeArguments (sn, result);
return result;
}
if (typeName is ComposedCast) {
var cc = (ComposedCast)typeName;
var baseType = ConvertToType (cc.Left);
var result = new ComposedType () { BaseType = baseType };
var ccSpec = cc.Spec;
while (ccSpec != null) {
if (ccSpec.IsNullable) {
result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), ComposedType.NullableRole);
} else if (ccSpec.IsPointer) {
result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), ComposedType.PointerRole);
} else {
var location = LocationsBag.GetLocations (ccSpec);
var spec = new ArraySpecifier () { Dimensions = ccSpec.Dimension };
spec.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), FieldDeclaration.Roles.LBracket);
if (location != null)
spec.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.RBracket);
result.ArraySpecifiers.Add (spec);
}
ccSpec = ccSpec.Next;
}
return result;
}
if (typeName is SpecialContraintExpr) {
var sce = (SpecialContraintExpr)typeName;
switch (sce.Constraint) {
case SpecialConstraint.Class:
return new PrimitiveType ("class", Convert (sce.Location));
case SpecialConstraint.Struct:
return new PrimitiveType ("struct", Convert (sce.Location));
case SpecialConstraint.Constructor:
return new PrimitiveType ("new", Convert (sce.Location));
}
}
System.Console.WriteLine ("Error while converting :" + typeName + " - unknown type name");
System.Console.WriteLine (Environment.StackTrace);
return new SimpleType ("unknown");
}
示例6: VisitComposedType
public virtual void VisitComposedType(ComposedType composedType)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(composedType);
}
}
示例7: VisitComposedType
public override void VisitComposedType(ComposedType composedType)
{
var spec = composedType.ArraySpecifiers.FirstOrDefault();
if (spec != null) {
ForceSpacesBefore(spec.LBracketToken, policy.SpaceBeforeArrayDeclarationBrackets);
}
base.VisitComposedType(composedType);
}
示例8: VisitComposedType
public override void VisitComposedType (ComposedType composedType)
{
base.VisitComposedType (composedType);
if (!composedType.HasNullableSpecifier)
return;
var st = new SimpleType ("Nullable", composedType.BaseType.Clone ());
composedType.ReplaceWith (st);
}
示例9: VisitComposedType
public abstract StringBuilder VisitComposedType(ComposedType composedType, int data);
示例10: VisitComposedType
public override void VisitComposedType(ComposedType composedType)
{
new TypeBlock(this, composedType).Emit();
}
示例11: VisitComposedType
public override StringBuilder VisitComposedType(ComposedType composedType, int data)
{
throw new NotImplementedException();
}
示例12: VisitComposedType
public virtual void VisitComposedType(ComposedType composedType)
{
StartNode(composedType);
composedType.BaseType.AcceptVisitor(this);
if (composedType.HasNullableSpecifier) {
WriteToken(ComposedType.NullableRole, BoxedTextColor.Operator);
}
int count = 0;
for (int i = 0; i < composedType.PointerRank; i++) {
if (count-- <= 0) {
cancellationToken.ThrowIfCancellationRequested();
count = CANCEL_CHECK_LOOP_COUNT;
}
WriteToken(ComposedType.PointerRole, BoxedTextColor.Operator);
}
count = 0;
foreach (var node in composedType.ArraySpecifiers) {
if (count-- <= 0) {
cancellationToken.ThrowIfCancellationRequested();
count = CANCEL_CHECK_LOOP_COUNT;
}
node.AcceptVisitor(this);
}
EndNode(composedType);
}
示例13: VisitComposedType
public void VisitComposedType(ComposedType composedType)
{
JsonObject jsonComposedType = new JsonObject();
jsonComposedType.Comment = "VisitComposedType";
composedType.BaseType.AcceptVisitor(this);
jsonComposedType.AddJsonValue("basetype", Pop());
if (composedType.HasNullableSpecifier)
{
jsonComposedType.AddJsonValue("nullable-specifier", ComposedType.NullableRole.Token);
}
jsonComposedType.AddJsonValue("pointerrank", composedType.PointerRank);
JsonArray arraySpecifier = new JsonArray();
foreach (var node in composedType.ArraySpecifiers)
{
node.AcceptVisitor(this);
arraySpecifier.AddJsonValue(Pop());
}
Push(jsonComposedType);
}
示例14: VisitMethodDeclaration
public override void VisitMethodDeclaration (MethodDeclaration methodDeclaration)
{
base.VisitMethodDeclaration (methodDeclaration);
var hasRefs = methodDeclaration.Parameters.Any (IsRefParam);
if (!hasRefs)
return;
var sub = new Substitute ();
foreach (var p in methodDeclaration.Parameters.Where (IsRefParam).ToList ()) {
var pty = ((ComposedType)p.Type).BaseType;
var access = new IndexerExpression (new IdentifierExpression (p.Name), new PrimitiveExpression (0));
var ptd = GetTypeDef (pty);
if (ptd != null)
access.AddAnnotation (ptd);
sub.Subs [p.Name] = access;
p.ParameterModifier = ParameterModifier.None;
var c = new ComposedType {
BaseType = p.Type.Clone (),
};
c.ArraySpecifiers.Add (new ArraySpecifier (1));
p.Type = c;
}
methodDeclaration.Body.AcceptVisitor (sub);
}
示例15: VisitComposedType
public virtual void VisitComposedType (ComposedType composedType)
{
VisitChildren (composedType);
}