public virtual void VisitArraySpecifier(ArraySpecifier arraySpecifier) { if (this.ThrowException) { throw (System.Exception) this.CreateException(arraySpecifier); } }
public virtual void VisitArraySpecifier(ArraySpecifier arraySpecifier) { if (ThrowException) { throw (Exception)CreateException(arraySpecifier); } }
public override void VisitArraySpecifier(ArraySpecifier node, CloningAstVisitorContext context) { context.Result = new ArraySpecifier() { ArraySizeExpression = this.CloneNode <Expression>(node.ArraySizeExpression, context) }; }
public override object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) { if (arraySpecifier.Dimensions >= 10) { UnlockWith(arraySpecifier); } return base.VisitArraySpecifier(arraySpecifier, data); }
public override object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) { if (arraySpecifier.Dimensions >= 10) { UnlockWith(arraySpecifier); } return(base.VisitArraySpecifier(arraySpecifier, data)); }
S IAstVisitor <T, S> .VisitArraySpecifier(ArraySpecifier arraySpecifier, T data) { var handler = ArraySpecifierVisited; if (handler != null) { handler(arraySpecifier, data); } return(VisitChildren(arraySpecifier, data)); }
public static bool ArraySpecifiersAreEquivalent(ArraySpecifier arraySpecifier1, ArraySpecifier arraySpecifier2) { if (arraySpecifier1 == null && arraySpecifier2 == null) { return(true); } if (arraySpecifier1 == null || arraySpecifier2 == null) { return(false); } return(ConstantExpressionValuesAreEquivalent(arraySpecifier1.ArraySizeExpression, arraySpecifier2.ArraySizeExpression)); }
/// <summary> /// Translates an array specifier, e.g. "[10]". /// </summary> public override StringBuilder VisitArraySpecifier(ArraySpecifier arraySpecifier) { return(new StringBuilder(arraySpecifier.Dimensions)); }
public override StringBuilder VisitArraySpecifier(ArraySpecifier arraySpecifier, int data) { throw new NotImplementedException(); }
public virtual void VisitArraySpecifier(ArraySpecifier arraySpecifier) { if (this.ThrowException) { throw (Exception)this.CreateException(arraySpecifier); } }
public override AstNode VisitArraySpecifier(ArraySpecifier arraySpecifier, ILGenerator data) { return(base.VisitArraySpecifier(arraySpecifier, data)); }
AstType ConvertToType (Mono.CSharp.Expression typeName) { 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; return new SimpleType (qam.Name, Convert (qam.Location)); } if (typeName is MemberAccess) { MemberAccess ma = (MemberAccess)typeName; var memberType = new MemberType (); memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole); memberType.MemberName = ma.Name; 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 }; if (cc.Spec.IsNullable) { result.HasNullableSpecifier = true; } else if (cc.Spec.IsPointer) { result.PointerRank++; } else { var location = LocationsBag.GetLocations (cc.Spec); var spec = new ArraySpecifier () { Dimensions = cc.Spec.Dimension - 1 }; spec.AddChild (new CSharpTokenNode (Convert (cc.Spec.Location), 1), FieldDeclaration.Roles.LBracket); if (location != null) spec.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.RBracket); result.ArraySpecifiers.Add(spec); } return result; } System.Console.WriteLine ("Error while converting :" + typeName + " - unknown type name"); return new SimpleType ("unknown"); }
public Node VisitArraySpecifier(ArraySpecifier arraySpecifier) { return(CreateDummy(arraySpecifier)); }
public abstract StringBuilder VisitArraySpecifier(ArraySpecifier arraySpecifier, int data);
public virtual void VisitArraySpecifier(ArraySpecifier arraySpecifier) { StartNode(arraySpecifier); var braceHelper = BraceHelper.LeftBracket(this, CodeBracesRangeFlags.SquareBrackets); int count = 0; foreach (var comma in arraySpecifier.GetChildrenByRole(Roles.Comma)) { if (count-- <= 0) { cancellationToken.ThrowIfCancellationRequested(); count = CANCEL_CHECK_LOOP_COUNT; } writer.WriteTokenPunctuation(Roles.Comma, ","); } braceHelper.RightBracket(); EndNode(arraySpecifier); }
public object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) { throw new NotImplementedException(); }
public override void VisitArraySpecifier(ArraySpecifier node, AstPrinterContext context) { context.Write("["); this.Visit(node.ArraySizeExpression, context); context.Write("]"); }
public virtual void VisitArraySpecifier(ArraySpecifier arraySpecifier) { StartNode(arraySpecifier); WriteToken(Roles.LBracket); int count = 0; foreach (var comma in arraySpecifier.GetChildrenByRole(Roles.Comma)) { if (count-- <= 0) { cancellationToken.ThrowIfCancellationRequested(); count = CANCEL_CHECK_LOOP_COUNT; } writer.WriteTokenOperator(Roles.Comma, ","); } WriteToken(Roles.RBracket); EndNode(arraySpecifier); }
public UnifiedElement VisitArraySpecifier( ArraySpecifier arraySpecifier, object data) { throw new NotImplementedException("ArraySpecifier"); }
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; }
public virtual void VisitArraySpecifier (ArraySpecifier arraySpecifier) { VisitChildren (arraySpecifier); }
public void VisitArraySpecifier(ArraySpecifier arraySpecifier) { throw new NotImplementedException(); }
public void VisitArraySpecifier(ArraySpecifier node) { VisitChildren(node); }
/// <inheritdoc/> public virtual void VisitArraySpecifier(ArraySpecifier syntax) { VisitNode(syntax); }
public override object Visit (ArrayCreation arrayCreationExpression) { var result = new ArrayCreateExpression (); var location = LocationsBag.GetLocations (arrayCreationExpression); if (arrayCreationExpression.NewType != null) result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket); if (arrayCreationExpression.Arguments != null) { var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments); for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) { result.AddChild ((Expression)arrayCreationExpression.Arguments[i].Accept (this), ArrayCreateExpression.Roles.Argument); if (commaLocations != null && i > 0) result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), ArrayCreateExpression.Roles.Comma); } } var next = arrayCreationExpression.Rank.Next; while (next != null) { ArraySpecifier spec = new ArraySpecifier (next.Dimension); var loc = LocationsBag.GetLocations (next); spec.AddChild (new CSharpTokenNode (Convert (next.Location), 1), ArraySpecifier.Roles.LBracket); if (loc != null) result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), ArraySpecifier.Roles.RBracket); result.AddChild (spec, ArrayCreateExpression.AdditionalArraySpecifierRole); next = next.Next; } if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket); if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) { var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers); ArrayInitializerExpression initializer = new ArrayInitializerExpression(); initializer.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayCreateExpression.Roles.LBrace); var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements); for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) { initializer.AddChild ((Expression)arrayCreationExpression.Initializers[i].Accept (this), ArrayInitializerExpression.Roles.Expression); if (commaLocations != null && i > 0) { initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma); } } if (initLocation != null) initializer.AddChild (new CSharpTokenNode (Convert (initLocation[initLocation.Count - 1]), 1), ArrayCreateExpression.Roles.RBrace); result.AddChild (initializer, ArrayCreateExpression.InitializerRole); } return result; }
public virtual S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data) { return(VisitChildren(arraySpecifier, data)); }
public override void VisitArraySpecifier(ArraySpecifier syntax) { _underlyingVisitor.VisitArraySpecifier(syntax); }
public JNode VisitArraySpecifier(ArraySpecifier node) { throw new NotImplementedException(); }
public void VisitArraySpecifier(ArraySpecifier arraySpecifier) { StartNode(arraySpecifier); WriteToken(Roles.LBracket); foreach (var comma in arraySpecifier.GetChildrenByRole(Roles.Comma)) { writer.WriteToken(Roles.Comma, ","); } WriteToken(Roles.RBracket); EndNode(arraySpecifier); }
public virtual void VisitArraySpecifier(ArraySpecifier node, TContext context) { this.Visit(node.ArraySizeExpression, context); }
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"); }
public virtual Node VisitArraySpecifier(ArraySpecifier arraySpecifier) { throw new System.NotImplementedException(); }
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"); }
public RedILNode VisitArraySpecifier(ArraySpecifier arraySpecifier, State data) { throw new System.NotImplementedException(); }
public override object Visit(ArrayCreation arrayCreationExpression) { var result = new ArrayCreateExpression(); var location = LocationsBag.GetLocations(arrayCreationExpression); result.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Location), ArrayCreateExpression.NewKeywordRole), ArrayCreateExpression.NewKeywordRole); if (arrayCreationExpression.TypeExpression != null) result.AddChild(ConvertToType(arrayCreationExpression.TypeExpression), Roles.Type); var next = arrayCreationExpression.Rank; if (arrayCreationExpression.Arguments != null) { // skip first array rank. next = next.Next; if (location != null) result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBracket), Roles.LBracket); var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Arguments); for (int i = 0; i < arrayCreationExpression.Arguments.Count; i++) { var arg = arrayCreationExpression.Arguments [i]; if (arg != null) result.AddChild((Expression)arg.Accept(this), Roles.Argument); if (commaLocations != null && i < commaLocations.Count) result.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma); } if (location != null && location.Count > 1) result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBracket), Roles.RBracket); } while (next != null) { var spec = new ArraySpecifier(next.Dimension); var loc = LocationsBag.GetLocations(next); spec.AddChild(new CSharpTokenNode(Convert(next.Location), Roles.LBracket), Roles.LBracket); result.AddChild(spec, ArrayCreateExpression.AdditionalArraySpecifierRole); if (loc != null) result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.RBracket), Roles.RBracket); next = next.Next; } if (arrayCreationExpression.Initializers != null) { var initLocation = LocationsBag.GetLocations(arrayCreationExpression.Initializers); var initializer = new ArrayInitializerExpression(); initializer.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Initializers.Location), Roles.LBrace), Roles.LBrace); var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Initializers.Elements); for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) { var init = arrayCreationExpression.Initializers [i]; if (init == null) continue; initializer.AddChild((Expression)init.Accept(this), Roles.Expression); if (commaLocations != null && i < commaLocations.Count) { initializer.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma); } } if (initLocation != null) { if (initLocation.Count == 2) // optional comma initializer.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Comma), Roles.Comma); initializer.AddChild(new CSharpTokenNode(Convert(initLocation [initLocation.Count - 1]), Roles.RBrace), Roles.RBrace); } result.AddChild(initializer, ArrayCreateExpression.InitializerRole); } return result; }
/* * public override void VisitSimpleType (SimpleType simpleType) * { * }*/ /* * public override void VisitMemberType (MemberType memberType) * { * }*/ /* * public override void VisitComposedType (ComposedType composedType) * { * }*/ public override void VisitArraySpecifier(ArraySpecifier arraySpecifier) { throw NotSupportedToConsistency(); }
public void VisitArraySpecifier(ArraySpecifier arraySpecifier) { StartNode(arraySpecifier); WriteToken(Roles.LBracket); foreach (var comma in arraySpecifier.GetChildrenByRole(Roles.Comma)) { WriteSpecialsUpToNode(comma); formatter.WriteToken(","); lastWritten = LastWritten.Other; } WriteToken(Roles.RBracket); EndNode(arraySpecifier); }
public void VisitArraySpecifier(ArraySpecifier arraySpecifier) { JsonObject arrSpec = new JsonObject(); arrSpec.Comment = "VisitArraySpecifier"; arrSpec.AddJsonValue("array-specifier", arraySpecifier.GetChildrenByRole(Roles.Comma).Count); if (arraySpecifier.GetChildrenByRole(Roles.Comma).Count == 0) { arrSpec = null; } Push(arrSpec); }