public static Expression CreateDefaultValueForType(TypeReference type) { if (type != null && !type.IsArrayType) { switch (type.Type) { case "System.SByte": case "System.Byte": case "System.Int16": case "System.UInt16": case "System.Int32": case "System.UInt32": case "System.Int64": case "System.UInt64": case "System.Single": case "System.Double": return new PrimitiveExpression(0, "0"); case "System.Char": return new PrimitiveExpression('\0', "'\\0'"); case "System.Object": case "System.String": return new PrimitiveExpression(null, "null"); case "System.Boolean": return new PrimitiveExpression(false, "false"); default: return new DefaultValueExpression(type); } } else { return new PrimitiveExpression(null, "null"); } }
public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression, bool isQueryContinuation, Location inListPosition) { this.Name = name; this.TypeRef = typeRef; this.StartPos = startPos; this.EndPos = endPos; this.IsConst = isConst; this.IsLoopVariable = isLoopVariable; this.Initializer = initializer; this.ParentLambdaExpression = parentLambdaExpression; this.IsQueryContinuation = isQueryContinuation; this.InListPosition = inListPosition; }
public void AddVariable(TypeReference typeRef, string name, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression, bool isQueryContinuation, Location inListPosition) { if (name == null || name.Length == 0) { return; } List<LocalLookupVariable> list; if (!variables.ContainsKey(name)) { variables[name] = list = new List<LocalLookupVariable>(); } else { list = (List<LocalLookupVariable>)variables[name]; } list.Add(new LocalLookupVariable (name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression, isQueryContinuation, inListPosition)); }
CodeTypeReference ConvType (TypeReference type) { if (type == null || string.IsNullOrEmpty (type.Type)) return new CodeTypeReference (""); CodeTypeReference t = new CodeTypeReference(type.Type); foreach (TypeReference gt in type.GenericTypes) { t.TypeArguments.Add(ConvType(gt)); } if (type.IsArrayType) { for (int i = type.RankSpecifier.Length - 1; i >= 0; --i) { t = new CodeTypeReference(t, type.RankSpecifier[i] + 1); } } return t; }
void Type( #line 566 "Frames/cs.ATG" out TypeReference type) { TypeWithRestriction( #line 568 "Frames/cs.ATG" out type, true, false); }
public virtual object TrackedVisitTypeReference(TypeReference typeReference, object data) { return base.VisitTypeReference(typeReference, data); }
public sealed override object VisitTypeReference(TypeReference typeReference, object data) { this.BeginVisit(typeReference); object result = this.TrackedVisitTypeReference(typeReference, data); this.EndVisit(typeReference); return result; }
void TypeParameterConstraintsClauseBase( #line 2422 "Frames/cs.ATG" out TypeReference type) { #line 2423 "Frames/cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); #line 2425 "Frames/cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); #line 2426 "Frames/cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); #line 2427 "Frames/cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( #line 2428 "Frames/cs.ATG" out t); #line 2428 "Frames/cs.ATG" type = t; } else SynErr(217); }
void InterfaceMemberDecl() { #line 634 "VBNET.ATG" TypeReference type =null; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); List<TemplateDefinition> templates = new List<TemplateDefinition>(); AttributeSection section, returnTypeAttributeSection = null; ModifierList mod = new ModifierList(); List<AttributeSection> attributes = new List<AttributeSection>(); string name; if (StartOf(19)) { while (la.kind == 28) { AttributeSection( #line 642 "VBNET.ATG" out section); #line 642 "VBNET.ATG" attributes.Add(section); } while (StartOf(9)) { MemberModifier( #line 645 "VBNET.ATG" mod); } if (la.kind == 106) { lexer.NextToken(); #line 649 "VBNET.ATG" mod.Check(Modifiers.VBInterfaceEvents); Location startLocation = t.Location; Identifier(); #line 652 "VBNET.ATG" name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 653 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 654 "VBNET.ATG" out type); } EndOfStmt(); #line 657 "VBNET.ATG" EventDeclaration ed = new EventDeclaration { Name = name, TypeReference = type, Modifier = mod.Modifier, Parameters = p, Attributes = attributes, StartLocation = startLocation, EndLocation = t.EndLocation }; compilationUnit.AddChild(ed); } else if (la.kind == 195) { lexer.NextToken(); #line 667 "VBNET.ATG" Location startLocation = t.Location; mod.Check(Modifiers.VBInterfaceMethods); Identifier(); #line 670 "VBNET.ATG" name = t.val; TypeParameterList( #line 671 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 672 "VBNET.ATG" p); } Expect(26); } EndOfStmt(); #line 675 "VBNET.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod.Modifier, Parameters = p, Attributes = attributes, TypeReference = new TypeReference("System.Void", true), StartLocation = startLocation, EndLocation = t.EndLocation, Templates = templates }; compilationUnit.AddChild(md); } else if (la.kind == 114) { lexer.NextToken(); #line 690 "VBNET.ATG" mod.Check(Modifiers.VBInterfaceMethods); Location startLocation = t.Location; Identifier(); #line 693 "VBNET.ATG" name = t.val; TypeParameterList( #line 694 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 695 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( #line 696 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( #line 696 "VBNET.ATG" out type); } #line 698 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod.Modifier, TypeReference = type, Parameters = p, Attributes = attributes }; if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; md.Attributes.Add(returnTypeAttributeSection); } md.StartLocation = startLocation; md.EndLocation = t.EndLocation; md.Templates = templates; compilationUnit.AddChild(md); EndOfStmt(); } else if (la.kind == 171) { lexer.NextToken(); #line 718 "VBNET.ATG" Location startLocation = t.Location; mod.Check(Modifiers.VBInterfaceProperties); Identifier(); #line 721 "VBNET.ATG" name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 722 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 723 "VBNET.ATG" out type); } #line 725 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } EndOfStmt(); #line 731 "VBNET.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes); pd.Parameters = p; pd.EndLocation = t.EndLocation; pd.StartLocation = startLocation; compilationUnit.AddChild(pd); } else SynErr(245); } else if (StartOf(20)) { NonModuleDeclaration( #line 739 "VBNET.ATG" mod, attributes); } else SynErr(246); }
void NonArrayType( #line 601 "Frames/cs.ATG" out TypeReference type) { #line 603 "Frames/cs.ATG" Location startPos = la.Location; string name; int pointer = 0; type = null; if (StartOf(4)) { ClassType( #line 609 "Frames/cs.ATG" out type, false); } else if (StartOf(5)) { SimpleType( #line 610 "Frames/cs.ATG" out name); #line 610 "Frames/cs.ATG" type = new TypeReference(name, true); } else if (la.kind == 123) { lexer.NextToken(); Expect(6); #line 611 "Frames/cs.ATG" pointer = 1; type = new TypeReference("System.Void", true); } else SynErr(147); if (la.kind == 12) { NullableQuestionMark( #line 614 "Frames/cs.ATG" ref type); } while ( #line 616 "Frames/cs.ATG" IsPointer()) { Expect(6); #line 617 "Frames/cs.ATG" ++pointer; } #line 619 "Frames/cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; type.EndLocation = t.EndLocation; type.StartLocation = startPos; } }
void NullableQuestionMark( #line 2355 "Frames/cs.ATG" ref TypeReference typeRef) { #line 2356 "Frames/cs.ATG" List<TypeReference> typeArguments = new List<TypeReference>(1); Expect(12); #line 2360 "Frames/cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; }
void QualIdentAndTypeArguments( #line 2456 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { #line 2457 "VBNET.ATG" string name; typeref = null; Qualident( #line 2459 "VBNET.ATG" out name); #line 2460 "VBNET.ATG" typeref = new TypeReference(name); if ( #line 2461 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(155); if ( #line 2463 "VBNET.ATG" canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma)) { #line 2464 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); while (la.kind == 12) { lexer.NextToken(); #line 2465 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); } } else if (StartOf(7)) { TypeArgumentList( #line 2466 "VBNET.ATG" typeref.GenericTypes); } else SynErr(268); Expect(26); } }
void FormalParameter( #line 2642 "VBNET.ATG" out ParameterDeclarationExpression p) { #line 2644 "VBNET.ATG" AttributeSection section; List<AttributeSection> attributes = new List<AttributeSection>(); TypeReference type = null; ParamModifierList mod = new ParamModifierList(this); Expression expr = null; p = null; ArrayList arrayModifiers = null; while (la.kind == 28) { AttributeSection( #line 2653 "VBNET.ATG" out section); #line 2653 "VBNET.ATG" attributes.Add(section); } while (StartOf(35)) { ParameterModifier( #line 2654 "VBNET.ATG" mod); } Identifier(); #line 2655 "VBNET.ATG" string parameterName = t.val; if ( #line 2656 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( #line 2656 "VBNET.ATG" out arrayModifiers); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 2657 "VBNET.ATG" out type); } #line 2659 "VBNET.ATG" if(type != null) { if (arrayModifiers != null) { if (type.RankSpecifier != null) { Error("array rank only allowed one time"); } else { type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int)); } } } else { type = new TypeReference("System.Object", arrayModifiers == null ? null : (int[])arrayModifiers.ToArray(typeof(int))); } if (la.kind == 10) { lexer.NextToken(); Expr( #line 2671 "VBNET.ATG" out expr); } #line 2673 "VBNET.ATG" mod.Check(); p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr); p.Attributes = attributes; }
void CastTarget( #line 1757 "VBNET.ATG" out TypeReference type) { #line 1759 "VBNET.ATG" type = null; switch (la.kind) { case 63: { lexer.NextToken(); #line 1761 "VBNET.ATG" type = new TypeReference("System.Boolean", true); break; } case 64: { lexer.NextToken(); #line 1762 "VBNET.ATG" type = new TypeReference("System.Byte", true); break; } case 77: { lexer.NextToken(); #line 1763 "VBNET.ATG" type = new TypeReference("System.SByte", true); break; } case 65: { lexer.NextToken(); #line 1764 "VBNET.ATG" type = new TypeReference("System.Char", true); break; } case 66: { lexer.NextToken(); #line 1765 "VBNET.ATG" type = new TypeReference("System.DateTime", true); break; } case 68: { lexer.NextToken(); #line 1766 "VBNET.ATG" type = new TypeReference("System.Decimal", true); break; } case 67: { lexer.NextToken(); #line 1767 "VBNET.ATG" type = new TypeReference("System.Double", true); break; } case 78: { lexer.NextToken(); #line 1768 "VBNET.ATG" type = new TypeReference("System.Int16", true); break; } case 70: { lexer.NextToken(); #line 1769 "VBNET.ATG" type = new TypeReference("System.Int32", true); break; } case 72: { lexer.NextToken(); #line 1770 "VBNET.ATG" type = new TypeReference("System.Int64", true); break; } case 84: { lexer.NextToken(); #line 1771 "VBNET.ATG" type = new TypeReference("System.UInt16", true); break; } case 82: { lexer.NextToken(); #line 1772 "VBNET.ATG" type = new TypeReference("System.UInt32", true); break; } case 83: { lexer.NextToken(); #line 1773 "VBNET.ATG" type = new TypeReference("System.UInt64", true); break; } case 73: { lexer.NextToken(); #line 1774 "VBNET.ATG" type = new TypeReference("System.Object", true); break; } case 79: { lexer.NextToken(); #line 1775 "VBNET.ATG" type = new TypeReference("System.Single", true); break; } case 80: { lexer.NextToken(); #line 1776 "VBNET.ATG" type = new TypeReference("System.String", true); break; } default: SynErr(262); break; } }
void GetTypeTypeName( #line 2408 "VBNET.ATG" out TypeReference typeref) { #line 2409 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( #line 2411 "VBNET.ATG" out typeref, true); ArrayTypeModifiers( #line 2412 "VBNET.ATG" out rank); #line 2413 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } }
void SimpleNonInvocationExpression( #line 1645 "VBNET.ATG" out Expression pexpr) { #line 1647 "VBNET.ATG" Expression expr; TypeReference type = null; string name = String.Empty; pexpr = null; if (StartOf(32)) { switch (la.kind) { case 3: { lexer.NextToken(); #line 1655 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 4: { lexer.NextToken(); #line 1656 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 7: { lexer.NextToken(); #line 1657 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 6: { lexer.NextToken(); #line 1658 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 5: { lexer.NextToken(); #line 1659 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 9: { lexer.NextToken(); #line 1660 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 8: { lexer.NextToken(); #line 1661 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 202: { lexer.NextToken(); #line 1663 "VBNET.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 109: { lexer.NextToken(); #line 1664 "VBNET.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 151: { lexer.NextToken(); #line 1665 "VBNET.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 25: { lexer.NextToken(); Expr( #line 1666 "VBNET.ATG" out expr); Expect(26); #line 1666 "VBNET.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 85: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { Identifier(); #line 1668 "VBNET.ATG" pexpr = new IdentifierExpression(t.val); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; if ( #line 1671 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(155); TypeArgumentList( #line 1672 "VBNET.ATG" ((IdentifierExpression)pexpr).TypeArguments); Expect(26); } break; } case 55: case 58: case 69: case 86: case 87: case 96: case 128: case 137: case 154: case 181: case 186: case 187: case 193: case 206: case 207: case 210: { #line 1674 "VBNET.ATG" string val = String.Empty; if (StartOf(11)) { PrimitiveTypeName( #line 1675 "VBNET.ATG" out val); } else if (la.kind == 154) { lexer.NextToken(); #line 1675 "VBNET.ATG" val = "System.Object"; } else SynErr(257); #line 1676 "VBNET.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)); break; } case 139: { lexer.NextToken(); #line 1677 "VBNET.ATG" pexpr = new ThisReferenceExpression(); break; } case 144: case 145: { #line 1678 "VBNET.ATG" Expression retExpr = null; if (la.kind == 144) { lexer.NextToken(); #line 1679 "VBNET.ATG" retExpr = new BaseReferenceExpression(); } else if (la.kind == 145) { lexer.NextToken(); #line 1680 "VBNET.ATG" retExpr = new ClassReferenceExpression(); } else SynErr(258); Expect(16); IdentifierOrKeyword( #line 1682 "VBNET.ATG" out name); #line 1682 "VBNET.ATG" pexpr = new MemberReferenceExpression(retExpr, name); break; } case 117: { lexer.NextToken(); Expect(16); Identifier(); #line 1684 "VBNET.ATG" type = new TypeReference(t.val ?? ""); #line 1686 "VBNET.ATG" type.IsGlobal = true; #line 1687 "VBNET.ATG" pexpr = new TypeReferenceExpression(type); break; } case 148: { ObjectCreateExpression( #line 1688 "VBNET.ATG" out expr); #line 1688 "VBNET.ATG" pexpr = expr; break; } case 81: case 93: case 204: { #line 1690 "VBNET.ATG" CastType castType = CastType.Cast; if (la.kind == 93) { lexer.NextToken(); } else if (la.kind == 81) { lexer.NextToken(); #line 1692 "VBNET.ATG" castType = CastType.Conversion; } else if (la.kind == 204) { lexer.NextToken(); #line 1693 "VBNET.ATG" castType = CastType.TryCast; } else SynErr(259); Expect(25); Expr( #line 1695 "VBNET.ATG" out expr); Expect(12); TypeName( #line 1695 "VBNET.ATG" out type); Expect(26); #line 1696 "VBNET.ATG" pexpr = new CastExpression(type, expr, castType); break; } case 63: case 64: case 65: case 66: case 67: case 68: case 70: case 72: case 73: case 77: case 78: case 79: case 80: case 82: case 83: case 84: { CastTarget( #line 1697 "VBNET.ATG" out type); Expect(25); Expr( #line 1697 "VBNET.ATG" out expr); Expect(26); #line 1697 "VBNET.ATG" pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); break; } case 44: { lexer.NextToken(); Expr( #line 1698 "VBNET.ATG" out expr); #line 1698 "VBNET.ATG" pexpr = new AddressOfExpression(expr); break; } case 116: { lexer.NextToken(); Expect(25); GetTypeTypeName( #line 1699 "VBNET.ATG" out type); Expect(26); #line 1699 "VBNET.ATG" pexpr = new TypeOfExpression(type); break; } case 205: { lexer.NextToken(); SimpleExpr( #line 1700 "VBNET.ATG" out expr); Expect(131); TypeName( #line 1700 "VBNET.ATG" out type); #line 1700 "VBNET.ATG" pexpr = new TypeOfIsExpression(expr, type); break; } case 122: { ConditionalExpression( #line 1701 "VBNET.ATG" out pexpr); break; } } } else if (la.kind == 16) { lexer.NextToken(); IdentifierOrKeyword( #line 1705 "VBNET.ATG" out name); #line 1705 "VBNET.ATG" pexpr = new MemberReferenceExpression(null, name); } else SynErr(260); }
void TypeName( #line 2394 "VBNET.ATG" out TypeReference typeref) { #line 2395 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( #line 2397 "VBNET.ATG" out typeref, false); ArrayTypeModifiers( #line 2401 "VBNET.ATG" out rank); #line 2402 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } }
void VariableDeclaratorPartAfterIdentifier( #line 1406 "VBNET.ATG" List<VariableDeclaration> fieldDeclaration, string name) { #line 1408 "VBNET.ATG" Expression expr = null; TypeReference type = null; ArrayList rank = null; List<Expression> dimension = null; Location startLocation = t.Location; if ( #line 1414 "VBNET.ATG" IsSize() && !IsDims()) { ArrayInitializationModifier( #line 1414 "VBNET.ATG" out dimension); } if ( #line 1415 "VBNET.ATG" IsDims()) { ArrayNameModifier( #line 1415 "VBNET.ATG" out rank); } if ( #line 1417 "VBNET.ATG" IsObjectCreation()) { Expect(50); ObjectCreateExpression( #line 1417 "VBNET.ATG" out expr); #line 1419 "VBNET.ATG" if (expr is ObjectCreateExpression) { type = ((ObjectCreateExpression)expr).CreateType.Clone(); } else { type = ((ArrayCreateExpression)expr).CreateType.Clone(); } } else if (StartOf(23)) { if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1426 "VBNET.ATG" out type); #line 1428 "VBNET.ATG" if (type != null) { for (int i = fieldDeclaration.Count - 1; i >= 0; i--) { VariableDeclaration vd = fieldDeclaration[i]; if (vd.TypeReference.Type.Length > 0) break; TypeReference newType = type.Clone(); newType.RankSpecifier = vd.TypeReference.RankSpecifier; vd.TypeReference = newType; } } } #line 1440 "VBNET.ATG" if (type == null && (dimension != null || rank != null)) { type = new TypeReference(""); } if (dimension != null) { if(type.RankSpecifier != null) { Error("array rank only allowed one time"); } else { if (rank == null) { type.RankSpecifier = new int[] { dimension.Count - 1 }; } else { rank.Insert(0, dimension.Count - 1); type.RankSpecifier = (int[])rank.ToArray(typeof(int)); } expr = new ArrayCreateExpression(type.Clone(), dimension); } } else if (rank != null) { if(type.RankSpecifier != null) { Error("array rank only allowed one time"); } else { type.RankSpecifier = (int[])rank.ToArray(typeof(int)); } } if (la.kind == 10) { lexer.NextToken(); VariableInitializer( #line 1463 "VBNET.ATG" out expr); } } else SynErr(250); #line 1466 "VBNET.ATG" VariableDeclaration varDecl = new VariableDeclaration(name, expr, type); varDecl.StartLocation = startLocation; varDecl.EndLocation = t.Location; fieldDeclaration.Add(varDecl); }
void ClassType( #line 710 "Frames/cs.ATG" out TypeReference typeRef, bool canBeUnbound) { #line 711 "Frames/cs.ATG" TypeReference r; typeRef = null; if (StartOf(19)) { TypeName( #line 713 "Frames/cs.ATG" out r, canBeUnbound); #line 713 "Frames/cs.ATG" typeRef = r; } else if (la.kind == 91) { lexer.NextToken(); #line 714 "Frames/cs.ATG" typeRef = new TypeReference("System.Object", true); typeRef.StartLocation = t.Location; } else if (la.kind == 108) { lexer.NextToken(); #line 715 "Frames/cs.ATG" typeRef = new TypeReference("System.String", true); typeRef.StartLocation = t.Location; } else SynErr(159); }
void LoopControlVariable( #line 3061 "VBNET.ATG" out TypeReference type, out string name) { #line 3062 "VBNET.ATG" ArrayList arrayModifiers = null; type = null; Qualident( #line 3066 "VBNET.ATG" out name); if ( #line 3067 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( #line 3067 "VBNET.ATG" out arrayModifiers); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 3068 "VBNET.ATG" out type); #line 3068 "VBNET.ATG" if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } } #line 3070 "VBNET.ATG" if (type != null) { if(type.RankSpecifier != null && arrayModifiers != null) { Error("array rank only allowed one time"); } else if (arrayModifiers != null) { type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int)); } } }
void TypeName( #line 2322 "Frames/cs.ATG" out TypeReference typeRef, bool canBeUnbound) { #line 2323 "Frames/cs.ATG" List<TypeReference> typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( #line 2329 "Frames/cs.ATG" IdentAndDoubleColon()) { Identifier(); #line 2330 "Frames/cs.ATG" alias = t.val; Expect(10); } Qualident( #line 2333 "Frames/cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( #line 2334 "Frames/cs.ATG" out typeArguments, canBeUnbound); } #line 2336 "Frames/cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { typeRef = new TypeReference(qualident, typeArguments); typeRef.IsGlobal = true; } else { typeRef = new TypeReference(alias + "." + qualident, typeArguments); } while ( #line 2345 "Frames/cs.ATG" DotAndIdent()) { Expect(15); #line 2346 "Frames/cs.ATG" typeArguments = null; Qualident( #line 2347 "Frames/cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( #line 2348 "Frames/cs.ATG" out typeArguments, canBeUnbound); } #line 2349 "Frames/cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } #line 2351 "Frames/cs.ATG" typeRef.StartLocation = startLocation; }
void NonArrayTypeName( #line 2420 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { #line 2422 "VBNET.ATG" string name; typeref = null; bool isGlobal = false; if (StartOf(10)) { if (la.kind == 117) { lexer.NextToken(); Expect(16); #line 2427 "VBNET.ATG" isGlobal = true; } QualIdentAndTypeArguments( #line 2428 "VBNET.ATG" out typeref, canBeUnbound); #line 2429 "VBNET.ATG" typeref.IsGlobal = isGlobal; while (la.kind == 16) { lexer.NextToken(); #line 2430 "VBNET.ATG" TypeReference nestedTypeRef; QualIdentAndTypeArguments( #line 2431 "VBNET.ATG" out nestedTypeRef, canBeUnbound); #line 2432 "VBNET.ATG" typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); } } else if (la.kind == 154) { lexer.NextToken(); #line 2435 "VBNET.ATG" typeref = new TypeReference("System.Object", true); if (la.kind == 21) { lexer.NextToken(); #line 2439 "VBNET.ATG" List<TypeReference> typeArguments = new List<TypeReference>(1); if (typeref != null) typeArguments.Add(typeref); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; } } else if (StartOf(11)) { PrimitiveTypeName( #line 2445 "VBNET.ATG" out name); #line 2445 "VBNET.ATG" typeref = new TypeReference(name, true); if (la.kind == 21) { lexer.NextToken(); #line 2449 "VBNET.ATG" List<TypeReference> typeArguments = new List<TypeReference>(1); if (typeref != null) typeArguments.Add(typeref); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; } } else SynErr(236); }
void TypeWithRestriction( #line 571 "Frames/cs.ATG" out TypeReference type, bool allowNullable, bool canBeUnbound) { #line 573 "Frames/cs.ATG" Location startPos = la.Location; string name; int pointer = 0; type = null; if (StartOf(4)) { ClassType( #line 579 "Frames/cs.ATG" out type, canBeUnbound); } else if (StartOf(5)) { SimpleType( #line 580 "Frames/cs.ATG" out name); #line 580 "Frames/cs.ATG" type = new TypeReference(name, true); } else if (la.kind == 123) { lexer.NextToken(); Expect(6); #line 581 "Frames/cs.ATG" pointer = 1; type = new TypeReference("System.Void", true); } else SynErr(178); #line 582 "Frames/cs.ATG" List<int> r = new List<int>(); if ( #line 584 "Frames/cs.ATG" allowNullable && la.kind == Tokens.Question) { NullableQuestionMark( #line 584 "Frames/cs.ATG" ref type); } while ( #line 586 "Frames/cs.ATG" IsPointerOrDims()) { #line 586 "Frames/cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); #line 587 "Frames/cs.ATG" ++pointer; } else if (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); #line 588 "Frames/cs.ATG" ++i; } Expect(19); #line 588 "Frames/cs.ATG" r.Add(i); } else SynErr(179); } #line 591 "Frames/cs.ATG" if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; type.EndLocation = t.EndLocation; type.StartLocation = startPos; } }
internal ResolveResult CreateResult (TypeReference typeReference) { return CreateResult (NRefactoryResolver.ConvertTypeReference (typeReference)); }
void PrimaryExpr( #line 1888 "Frames/cs.ATG" out Expression pexpr) { #line 1890 "Frames/cs.ATG" TypeReference type = null; Expression expr; pexpr = null; #line 1895 "Frames/cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); #line 1897 "Frames/cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); #line 1898 "Frames/cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); #line 1899 "Frames/cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); #line 1900 "Frames/cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( #line 1901 "Frames/cs.ATG" StartOfQueryExpression()) { QueryExpression( #line 1902 "Frames/cs.ATG" out pexpr); } else if ( #line 1903 "Frames/cs.ATG" IdentAndDoubleColon()) { Identifier(); #line 1904 "Frames/cs.ATG" type = new TypeReference(t.val); Expect(10); #line 1905 "Frames/cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); #line 1906 "Frames/cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); #line 1910 "Frames/cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || #line 1913 "Frames/cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( #line 1912 "Frames/cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { #line 1914 "Frames/cs.ATG" List<TypeReference> typeList; TypeArgumentList( #line 1915 "Frames/cs.ATG" out typeList, false); #line 1916 "Frames/cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( #line 1918 "Frames/cs.ATG" IsLambdaExpression()) { LambdaExpression( #line 1919 "Frames/cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( #line 1922 "Frames/cs.ATG" out expr); Expect(21); #line 1922 "Frames/cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { #line 1925 "Frames/cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); #line 1926 "Frames/cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); #line 1927 "Frames/cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); #line 1928 "Frames/cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); #line 1929 "Frames/cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); #line 1930 "Frames/cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); #line 1931 "Frames/cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); #line 1932 "Frames/cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); #line 1933 "Frames/cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); #line 1934 "Frames/cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); #line 1935 "Frames/cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); #line 1936 "Frames/cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); #line 1937 "Frames/cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); #line 1938 "Frames/cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); #line 1939 "Frames/cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); #line 1940 "Frames/cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); #line 1941 "Frames/cs.ATG" val = "System.Void"; break; } } #line 1943 "Frames/cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); #line 1946 "Frames/cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); #line 1948 "Frames/cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( #line 1951 "Frames/cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( #line 1955 "Frames/cs.ATG" NotVoidPointer()) { Expect(123); #line 1955 "Frames/cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( #line 1956 "Frames/cs.ATG" out type, true, true); } else SynErr(207); Expect(21); #line 1958 "Frames/cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( #line 1960 "Frames/cs.ATG" out type); Expect(21); #line 1960 "Frames/cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( #line 1961 "Frames/cs.ATG" out type); Expect(21); #line 1961 "Frames/cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( #line 1962 "Frames/cs.ATG" out expr); Expect(21); #line 1962 "Frames/cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( #line 1963 "Frames/cs.ATG" out expr); Expect(21); #line 1963 "Frames/cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( #line 1964 "Frames/cs.ATG" out expr); #line 1964 "Frames/cs.ATG" pexpr = expr; } else SynErr(208); #line 1966 "Frames/cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; if (pexpr.EndLocation.IsEmpty) pexpr.EndLocation = t.EndLocation; } while (StartOf(36)) { if (la.kind == 31 || la.kind == 32) { #line 1974 "Frames/cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); #line 1976 "Frames/cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); #line 1977 "Frames/cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(209); } else if (la.kind == 47) { PointerMemberAccess( #line 1980 "Frames/cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( #line 1981 "Frames/cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); #line 1985 "Frames/cs.ATG" List<Expression> parameters = new List<Expression>(); #line 1986 "Frames/cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); pexpr.StartLocation = startLocation; if (StartOf(26)) { Argument( #line 1987 "Frames/cs.ATG" out expr); #line 1987 "Frames/cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( #line 1988 "Frames/cs.ATG" out expr); #line 1988 "Frames/cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { #line 1994 "Frames/cs.ATG" List<Expression> indices = new List<Expression>(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( #line 1997 "Frames/cs.ATG" out expr); #line 1997 "Frames/cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( #line 1998 "Frames/cs.ATG" out expr); #line 1998 "Frames/cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); #line 2001 "Frames/cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; } } } }
object ToTargetType (TypeReference type) { if (type.IsNull) throw CreateParseError ("Invalid type reference"); if (type.GenericTypes.Count == 0) return ctx.Adapter.GetType (ctx, type.Type); else { object[] args = new object [type.GenericTypes.Count]; for (int n=0; n<args.Length; n++) { object t = ToTargetType (type.GenericTypes [n]); if (t == null) return null; args [n] = t; } return ctx.Adapter.GetType (ctx, type.Type + "`" + args.Length, args); } }
void TypeParameterConstraint( #line 415 "VBNET.ATG" out TypeReference constraint) { #line 416 "VBNET.ATG" constraint = null; if (la.kind == 71) { lexer.NextToken(); #line 417 "VBNET.ATG" constraint = TypeReference.ClassConstraint; } else if (la.kind == 194) { lexer.NextToken(); #line 418 "VBNET.ATG" constraint = TypeReference.StructConstraint; } else if (la.kind == 148) { lexer.NextToken(); #line 419 "VBNET.ATG" constraint = TypeReference.NewConstraint; } else if (StartOf(7)) { TypeName( #line 420 "VBNET.ATG" out constraint); } else SynErr(235); }
void StructureMemberDecl( #line 775 "VBNET.ATG" ModifierList m, List<AttributeSection> attributes) { #line 777 "VBNET.ATG" TypeReference type = null; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); Statement stmt = null; List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>(); List<TemplateDefinition> templates = new List<TemplateDefinition>(); switch (la.kind) { case 71: case 90: case 102: case 129: case 141: case 194: { NonModuleDeclaration( #line 784 "VBNET.ATG" m, attributes); break; } case 195: { lexer.NextToken(); #line 788 "VBNET.ATG" Location startPos = t.Location; if (StartOf(14)) { #line 792 "VBNET.ATG" string name = String.Empty; MethodDeclaration methodDeclaration; List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 798 "VBNET.ATG" name = t.val; m.Check(Modifiers.VBMethods); TypeParameterList( #line 801 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 802 "VBNET.ATG" p); } Expect(26); } if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( #line 805 "VBNET.ATG" out implementsClause); } else { HandlesClause( #line 807 "VBNET.ATG" out handlesClause); } } #line 810 "VBNET.ATG" Location endLocation = t.EndLocation; if ( #line 813 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); #line 816 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; compilationUnit.AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); #line 829 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; compilationUnit.AddChild(methodDeclaration); #line 840 "VBNET.ATG" if (ParseMethodBodies) { Block( #line 841 "VBNET.ATG" out stmt); Expect(100); Expect(195); #line 843 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } #line 849 "VBNET.ATG" methodDeclaration.Body = (BlockStatement)stmt; #line 850 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(238); } else if (la.kind == 148) { lexer.NextToken(); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 854 "VBNET.ATG" p); } Expect(26); } #line 855 "VBNET.ATG" m.Check(Modifiers.Constructors); #line 856 "VBNET.ATG" Location constructorEndLocation = t.EndLocation; Expect(1); #line 859 "VBNET.ATG" if (ParseMethodBodies) { Block( #line 860 "VBNET.ATG" out stmt); Expect(100); Expect(195); #line 862 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } #line 868 "VBNET.ATG" Location endLocation = t.EndLocation; EndOfStmt(); #line 871 "VBNET.ATG" ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; cd.Body = (BlockStatement)stmt; cd.Body.EndLocation = endLocation; compilationUnit.AddChild(cd); } else SynErr(239); break; } case 114: { lexer.NextToken(); #line 883 "VBNET.ATG" m.Check(Modifiers.VBMethods); string name = String.Empty; Location startPos = t.Location; MethodDeclaration methodDeclaration;List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; AttributeSection returnTypeAttributeSection = null; Identifier(); #line 890 "VBNET.ATG" name = t.val; TypeParameterList( #line 891 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 892 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( #line 893 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( #line 893 "VBNET.ATG" out type); } #line 895 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( #line 901 "VBNET.ATG" out implementsClause); } else { HandlesClause( #line 903 "VBNET.ATG" out handlesClause); } } if ( #line 908 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); #line 911 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, HandlesClause = handlesClause, Templates = templates, InterfaceImplementations = implementsClause }; if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); } compilationUnit.AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); #line 929 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); } compilationUnit.AddChild(methodDeclaration); if (ParseMethodBodies) { Block( #line 946 "VBNET.ATG" out stmt); Expect(100); Expect(114); #line 948 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); } methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(240); break; } case 88: { lexer.NextToken(); #line 962 "VBNET.ATG" m.Check(Modifiers.VBExternalMethods); Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; string library = String.Empty; string alias = null; string name = String.Empty; if (StartOf(15)) { Charset( #line 969 "VBNET.ATG" out charsetModifer); } if (la.kind == 195) { lexer.NextToken(); Identifier(); #line 972 "VBNET.ATG" name = t.val; Expect(135); Expect(3); #line 973 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); #line 974 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 975 "VBNET.ATG" p); } Expect(26); } EndOfStmt(); #line 978 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; compilationUnit.AddChild(declareDeclaration); } else if (la.kind == 114) { lexer.NextToken(); Identifier(); #line 985 "VBNET.ATG" name = t.val; Expect(135); Expect(3); #line 986 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); #line 987 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 988 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 989 "VBNET.ATG" out type); } EndOfStmt(); #line 992 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; compilationUnit.AddChild(declareDeclaration); } else SynErr(241); break; } case 106: { lexer.NextToken(); #line 1002 "VBNET.ATG" m.Check(Modifiers.VBEvents); Location startPos = t.Location; EventDeclaration eventDeclaration; string name = String.Empty; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1008 "VBNET.ATG" name= t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1010 "VBNET.ATG" out type); } else if (StartOf(16)) { if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 1012 "VBNET.ATG" p); } Expect(26); } } else SynErr(242); if (la.kind == 123) { ImplementsClause( #line 1014 "VBNET.ATG" out implementsClause); } #line 1016 "VBNET.ATG" eventDeclaration = new EventDeclaration { Name = name, TypeReference = type, Modifier = m.Modifier, Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation }; compilationUnit.AddChild(eventDeclaration); EndOfStmt(); break; } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { #line 1026 "VBNET.ATG" Location startPos = t.Location; #line 1028 "VBNET.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); IdentifierForFieldDeclaration(); #line 1032 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( #line 1033 "VBNET.ATG" variableDeclarators, name); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( #line 1034 "VBNET.ATG" variableDeclarators); } EndOfStmt(); #line 1037 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); break; } case 75: { #line 1042 "VBNET.ATG" m.Check(Modifiers.Fields); lexer.NextToken(); #line 1043 "VBNET.ATG" m.Add(Modifiers.Const, t.Location); #line 1045 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>(); ConstantDeclarator( #line 1049 "VBNET.ATG" constantDeclarators); while (la.kind == 12) { lexer.NextToken(); ConstantDeclarator( #line 1050 "VBNET.ATG" constantDeclarators); } #line 1052 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; EndOfStmt(); #line 1057 "VBNET.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); break; } case 171: { lexer.NextToken(); #line 1063 "VBNET.ATG" m.Check(Modifiers.VBProperties); Location startPos = t.Location; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1067 "VBNET.ATG" string propertyName = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 1068 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1069 "VBNET.ATG" out type); } #line 1071 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 123) { ImplementsClause( #line 1075 "VBNET.ATG" out implementsClause); } EndOfStmt(); if ( #line 1079 "VBNET.ATG" IsMustOverride(m)) { #line 1081 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; pDecl.TypeReference = type; pDecl.InterfaceImplementations = implementsClause; pDecl.Parameters = p; compilationUnit.AddChild(pDecl); } else if (StartOf(17)) { #line 1091 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; pDecl.BodyStart = t.Location; pDecl.TypeReference = type; pDecl.InterfaceImplementations = implementsClause; pDecl.Parameters = p; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 1101 "VBNET.ATG" out getRegion, out setRegion); Expect(100); Expect(171); EndOfStmt(); #line 1105 "VBNET.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; compilationUnit.AddChild(pDecl); } else SynErr(243); break; } case 85: { lexer.NextToken(); #line 1112 "VBNET.ATG" Location startPos = t.Location; Expect(106); #line 1114 "VBNET.ATG" m.Check(Modifiers.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; EventRemoveRegion removeHandlerAccessorDeclaration = null; EventRaiseRegion raiseEventAccessorDeclaration = null; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1121 "VBNET.ATG" string customEventName = t.val; Expect(50); TypeName( #line 1122 "VBNET.ATG" out type); if (la.kind == 123) { ImplementsClause( #line 1123 "VBNET.ATG" out implementsClause); } EndOfStmt(); while (StartOf(18)) { EventAccessorDeclaration( #line 1126 "VBNET.ATG" out eventAccessorDeclaration); #line 1128 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRemoveRegion) { removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRaiseRegion) { raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration; } } Expect(100); Expect(106); EndOfStmt(); #line 1144 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); } if(removeHandlerAccessorDeclaration == null) { Error("Need to provide RemoveHandler accessor."); } if(raiseEventAccessorDeclaration == null) { Error("Need to provide RaiseEvent accessor."); } EventDeclaration decl = new EventDeclaration { TypeReference = type, Name = customEventName, Modifier = m.Modifier, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, AddRegion = addHandlerAccessorDeclaration, RemoveRegion = removeHandlerAccessorDeclaration, RaiseRegion = raiseEventAccessorDeclaration }; compilationUnit.AddChild(decl); break; } case 147: case 158: case 217: { #line 1170 "VBNET.ATG" ConversionType opConversionType = ConversionType.None; if (la.kind == 147 || la.kind == 217) { if (la.kind == 217) { lexer.NextToken(); #line 1171 "VBNET.ATG" opConversionType = ConversionType.Implicit; } else { lexer.NextToken(); #line 1172 "VBNET.ATG" opConversionType = ConversionType.Explicit; } } Expect(158); #line 1175 "VBNET.ATG" m.Check(Modifiers.VBOperators); Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; TypeReference operandType = NullTypeReference.Instance; string operandName; OverloadableOperatorType operatorType; AttributeSection section; List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); List<AttributeSection> returnTypeAttributes = new List<AttributeSection>(); OverloadableOperator( #line 1185 "VBNET.ATG" out operatorType); Expect(25); if (la.kind == 59) { lexer.NextToken(); } Identifier(); #line 1186 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1187 "VBNET.ATG" out operandType); } #line 1188 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); while (la.kind == 12) { lexer.NextToken(); if (la.kind == 59) { lexer.NextToken(); } Identifier(); #line 1192 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1193 "VBNET.ATG" out operandType); } #line 1194 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); } Expect(26); #line 1197 "VBNET.ATG" Location endPos = t.EndLocation; if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( #line 1198 "VBNET.ATG" out section); #line 1198 "VBNET.ATG" returnTypeAttributes.Add(section); } TypeName( #line 1198 "VBNET.ATG" out returnType); #line 1198 "VBNET.ATG" endPos = t.EndLocation; } Expect(1); Block( #line 1200 "VBNET.ATG" out stmt); Expect(100); Expect(158); EndOfStmt(); #line 1202 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = returnType, OverloadableOperator = operatorType, ConversionType = opConversionType, ReturnTypeAttributes = returnTypeAttributes, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; operatorDeclaration.Body.StartLocation = startPos; operatorDeclaration.Body.EndLocation = t.Location; compilationUnit.AddChild(operatorDeclaration); break; } default: SynErr(244); break; } }
public virtual object VisitTypeReference(TypeReference typeReference, object data) { Debug.Assert((typeReference != null)); Debug.Assert((typeReference.GenericTypes != null)); foreach (TypeReference o in typeReference.GenericTypes) { Debug.Assert(o != null); o.AcceptVisitor(this, data); } return null; }
void ClassBaseType( #line 765 "VBNET.ATG" out TypeReference typeRef) { #line 767 "VBNET.ATG" typeRef = null; Expect(127); TypeName( #line 770 "VBNET.ATG" out typeRef); EndOfStmt(); }