public UnifiedElement VisitTypeOfExpression( TypeOfExpression expr, object data) { var type = LookupType(expr.Type); return(UnifiedTypeof.Create(type)); }
public override object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { ForceSpacesBefore(typeOfExpression.LParToken, policy.BeforeTypeOfParentheses); ForceSpacesAfter(typeOfExpression.LParToken, policy.WithinTypeOfParentheses); ForceSpacesBefore(typeOfExpression.RParToken, policy.WithinTypeOfParentheses); return(base.VisitTypeOfExpression(typeOfExpression, data)); }
public void CSharpCodeGenerator_TypeOf() { var statement = new TypeOfExpression(typeof(string)); var generator = new CSharpCodeGenerator(); var result = generator.Write(statement); Assert.That.StringEquals("typeof(string)", result); }
public void GetActionForExpressionTypeMeetsExpectation(TypeOfExpression expression, string expectation) { // arrange var sut = MakeSUT(); // act var result = sut.GetActionFor(expression); // assert Assert.Equal(expectation, result.Method.Name); }
public void ActionMapContentsMeetsExpectation(TypeOfExpression expression, bool expectation) { // arrange var sut = MakeSUT(); // act var result = sut.ActionMap.ContainsKey(expression); // assert Assert.Equal(expectation, result); }
public CSharpSyntaxNode Convert(TypeOfExpression node) { //return SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression( // SyntaxKind.SimpleMemberAccessExpression, // node.Expression.ToCsNode<ExpressionSyntax>(), // SyntaxFactory.IdentifierName("GetTypeName"))); return(SyntaxFactory .InvocationExpression(SyntaxFactory.IdentifierName("TypeOf")) .AddArgumentListArguments(this.ToArgumentList(new List <Node>() { node.Expression }))); }
private void Format_TypeOf_Expression(StringBuilder sb, TypeOfExpression expression) { sb.Append("typeof(") .Append(FormatterUtility.FormatDataType(expression.TypeReference, document, controller)) .Append(")"); }
public override object Visit(TypeOf typeOfExpression) { var result = new TypeOfExpression(); var location = LocationsBag.GetLocations(typeOfExpression); result.AddChild(new CSharpTokenNode(Convert(typeOfExpression.Location), TypeOfExpression.TypeofKeywordRole), TypeOfExpression.TypeofKeywordRole); if (location != null) result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar); if (typeOfExpression.TypeExpression != null) result.AddChild(ConvertToType(typeOfExpression.TypeExpression), Roles.Type); if (location != null && location.Count > 1) result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar); return result; }
public virtual object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { throw new global::System.NotImplementedException("TypeOfExpression"); }
public TooltipInformation GetTypeOfTooltip (TypeOfExpression typeOfExpression, TypeOfResolveResult resolveResult) { var result = new TooltipInformation (); if (resolveResult == null) { result.SignatureMarkup = AmbienceService.EscapeText (typeOfExpression.Type.ToString ()); } else { result.SignatureMarkup = GetTypeMarkup (resolveResult.ReferencedType, true); } return result; }
public virtual void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { if (this.ThrowException) { throw (Exception)this.CreateException(typeOfExpression); } }
public override void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { new TypeofBlock(this, typeOfExpression).Emit(); //typeOfExpression.Type.AcceptVisitor(this); }
public StringBuilder VisitTypeOfExpression(TypeOfExpression typeOfExpression, int data) { throw new SLSharpException("SL# does not have reflection."); }
public virtual object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { Debug.Assert((typeOfExpression != null)); Debug.Assert((typeOfExpression.TypeReference != null)); return typeOfExpression.TypeReference.AcceptVisitor(this, data); }
public override void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { typeOfExpression.Type.AcceptVisitor(this); }
public override void VisitTypeOfExpression (TypeOfExpression typeOfExpression) { base.VisitTypeOfExpression (typeOfExpression); var nt = new ObjectCreateExpression ( new SimpleType ("Type"), new PrimitiveExpression (GetJsConstructor (typeOfExpression.Type))); typeOfExpression.ReplaceWith (nt); }
public void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { JsonObject expression = CreateJsonExpression(typeOfExpression); AddKeyword(expression, TypeOfExpression.TypeofKeywordRole); expression.AddJsonValue("type-info", GenTypeInfo(typeOfExpression.Type)); Push(expression); }
private void PrimaryExpr(out Expression pexpr) { TypeReference typeReference = null; List<TypeReference> types = null; Expression expression; bool flag = false; pexpr = null; if (this.la.kind == 0x70) { base.lexer.NextToken(); pexpr = new PrimitiveExpression(true, "true"); } else if (this.la.kind == 0x47) { base.lexer.NextToken(); pexpr = new PrimitiveExpression(false, "false"); } else if (this.la.kind == 0x59) { base.lexer.NextToken(); pexpr = new PrimitiveExpression(null, "null"); } else if (this.la.kind == 2) { base.lexer.NextToken(); pexpr = new PrimitiveExpression(this.t.literalValue, this.t.val); } else if ((this.la.kind == 1) && (this.Peek(1).kind == 10)) { base.Expect(1); typeReference = new TypeReference(this.t.val); base.Expect(10); pexpr = new TypeReferenceExpression(typeReference); base.Expect(1); if (typeReference.Type == "global") { typeReference.IsGlobal = true; typeReference.Type = this.t.val ?? "?"; } else { typeReference.Type = typeReference.Type + "." + (this.t.val ?? "?"); } } else if (this.la.kind == 1) { base.lexer.NextToken(); pexpr = new IdentifierExpression(this.t.val); } else if (this.la.kind == 20) { base.lexer.NextToken(); this.Expr(out expression); base.Expect(0x15); pexpr = new ParenthesizedExpression(expression); } else if (!this.StartOf(0x1a)) { if (this.la.kind == 110) { base.lexer.NextToken(); pexpr = new ThisReferenceExpression(); } else if (this.la.kind == 50) { base.lexer.NextToken(); Expression targetObject = new BaseReferenceExpression(); if (this.la.kind == 15) { base.lexer.NextToken(); base.Expect(1); targetObject = new FieldReferenceExpression(targetObject, this.t.val); } else if (this.la.kind == 0x12) { base.lexer.NextToken(); this.Expr(out expression); List<Expression> indices = new List<Expression>(); if (expression != null) { indices.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); this.Expr(out expression); if (expression != null) { indices.Add(expression); } } base.Expect(0x13); targetObject = new IndexerExpression(targetObject, indices); } else { base.SynErr(0xb3); } pexpr = targetObject; } else if (this.la.kind == 0x58) { base.lexer.NextToken(); this.NonArrayType(out typeReference); List<Expression> parameters = new List<Expression>(); if (this.la.kind == 20) { base.lexer.NextToken(); ObjectCreateExpression expression3 = new ObjectCreateExpression(typeReference, parameters); if (this.StartOf(0x15)) { this.Argument(out expression); if (expression != null) { parameters.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); this.Argument(out expression); if (expression != null) { parameters.Add(expression); } } } base.Expect(0x15); pexpr = expression3; } else if (this.la.kind == 0x12) { base.lexer.NextToken(); flag = true; ArrayCreateExpression expression4 = new ArrayCreateExpression(typeReference); pexpr = expression4; int item = 0; List<int> list4 = new List<int>(); if ((this.la.kind == 14) || (this.la.kind == 0x13)) { while (this.la.kind == 14) { base.lexer.NextToken(); item++; } base.Expect(0x13); list4.Add(item); item = 0; while (this.la.kind == 0x12) { base.lexer.NextToken(); while (this.la.kind == 14) { base.lexer.NextToken(); item++; } base.Expect(0x13); list4.Add(item); item = 0; } expression4.CreateType.RankSpecifier = list4.ToArray(); this.ArrayInitializer(out expression); expression4.ArrayInitializer = (ArrayInitializerExpression) expression; } else if (this.StartOf(5)) { this.Expr(out expression); if (expression != null) { parameters.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); item++; this.Expr(out expression); if (expression != null) { parameters.Add(expression); } } base.Expect(0x13); list4.Add(item); expression4.Arguments = parameters; for (item = 0; this.la.kind == 0x12; item = 0) { base.lexer.NextToken(); while (this.la.kind == 14) { base.lexer.NextToken(); item++; } base.Expect(0x13); list4.Add(item); } expression4.CreateType.RankSpecifier = list4.ToArray(); if (this.la.kind == 0x10) { this.ArrayInitializer(out expression); expression4.ArrayInitializer = (ArrayInitializerExpression) expression; } } else { base.SynErr(180); } } else { base.SynErr(0xb5); } } else if (this.la.kind == 0x72) { base.lexer.NextToken(); base.Expect(20); if (this.NotVoidPointer()) { base.Expect(0x7a); typeReference = new TypeReference("void"); } else if (this.StartOf(9)) { this.TypeWithRestriction(out typeReference, true, true); } else { base.SynErr(0xb6); } base.Expect(0x15); pexpr = new TypeOfExpression(typeReference); } else if ((this.la.kind == 0x3e) && (this.Peek(1).kind == 20)) { base.Expect(0x3e); base.Expect(20); this.Type(out typeReference); base.Expect(0x15); pexpr = new DefaultValueExpression(typeReference); } else if (this.la.kind == 0x68) { base.lexer.NextToken(); base.Expect(20); this.Type(out typeReference); base.Expect(0x15); pexpr = new SizeOfExpression(typeReference); } else if (this.la.kind == 0x39) { base.lexer.NextToken(); base.Expect(20); this.Expr(out expression); base.Expect(0x15); pexpr = new CheckedExpression(expression); } else if (this.la.kind == 0x75) { base.lexer.NextToken(); base.Expect(20); this.Expr(out expression); base.Expect(0x15); pexpr = new UncheckedExpression(expression); } else if (this.la.kind == 0x3f) { base.lexer.NextToken(); this.AnonymousMethodExpr(out expression); pexpr = expression; } else { base.SynErr(0xb7); } } else { string typeName = null; switch (this.la.kind) { case 0x3d: base.lexer.NextToken(); typeName = "decimal"; break; case 0x41: base.lexer.NextToken(); typeName = "double"; break; case 0x4a: base.lexer.NextToken(); typeName = "float"; break; case 0x33: base.lexer.NextToken(); typeName = "bool"; break; case 0x35: base.lexer.NextToken(); typeName = "byte"; break; case 0x38: base.lexer.NextToken(); typeName = "char"; break; case 0x51: base.lexer.NextToken(); typeName = "int"; break; case 0x56: base.lexer.NextToken(); typeName = "long"; break; case 90: base.lexer.NextToken(); typeName = "object"; break; case 0x65: base.lexer.NextToken(); typeName = "sbyte"; break; case 0x67: base.lexer.NextToken(); typeName = "short"; break; case 0x6b: base.lexer.NextToken(); typeName = "string"; break; case 0x73: base.lexer.NextToken(); typeName = "uint"; break; case 0x74: base.lexer.NextToken(); typeName = "ulong"; break; case 0x77: base.lexer.NextToken(); typeName = "ushort"; break; } this.t.val = ""; base.Expect(15); base.Expect(1); pexpr = new FieldReferenceExpression(new TypeReferenceExpression(typeName), this.t.val); } while ((this.StartOf(0x1b) || (this.IsGenericFollowedBy(15) && this.IsTypeReferenceExpression(pexpr))) || this.IsGenericFollowedBy(20)) { if ((this.la.kind == 0x1f) || (this.la.kind == 0x20)) { if (this.la.kind == 0x1f) { base.lexer.NextToken(); pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (this.la.kind == 0x20) { base.lexer.NextToken(); pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else { base.SynErr(0xb8); } } else { if (this.la.kind == 0x2f) { base.lexer.NextToken(); base.Expect(1); pexpr = new PointerReferenceExpression(pexpr, this.t.val); continue; } if (this.la.kind == 15) { base.lexer.NextToken(); base.Expect(1); pexpr = new FieldReferenceExpression(pexpr, this.t.val); continue; } if (this.IsGenericFollowedBy(15) && this.IsTypeReferenceExpression(pexpr)) { this.TypeArgumentList(out types, false); base.Expect(15); base.Expect(1); pexpr = new FieldReferenceExpression(this.GetTypeReferenceExpression(pexpr, types), this.t.val); continue; } if (this.la.kind == 20) { base.lexer.NextToken(); List<Expression> arguments = new List<Expression>(); if (this.StartOf(0x15)) { this.Argument(out expression); if (expression != null) { arguments.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); this.Argument(out expression); if (expression != null) { arguments.Add(expression); } } } base.Expect(0x15); pexpr = new InvocationExpression(pexpr, arguments); continue; } if (this.IsGenericFollowedBy(20)) { this.TypeArgumentList(out types, false); base.Expect(20); List<Expression> list6 = new List<Expression>(); if (this.StartOf(0x15)) { this.Argument(out expression); if (expression != null) { list6.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); this.Argument(out expression); if (expression != null) { list6.Add(expression); } } } base.Expect(0x15); pexpr = new InvocationExpression(pexpr, list6, types); continue; } if (flag) { this.Error("element access not allow on array creation"); } List<Expression> list7 = new List<Expression>(); base.lexer.NextToken(); this.Expr(out expression); if (expression != null) { list7.Add(expression); } while (this.la.kind == 14) { base.lexer.NextToken(); this.Expr(out expression); if (expression != null) { list7.Add(expression); } } base.Expect(0x13); pexpr = new IndexerExpression(pexpr, list7); } } }
public void VisitTypeOfExpression(TypeOfExpression node) { NotSupported(node); }
internal TypeOfExpressionEmitter(TypeOfExpression typeOfExpression, ILGenerator ilGenerator, IOpCodeIndexer instructionsIndexer) : base(ilGenerator, instructionsIndexer) { _typeOfExpression = typeOfExpression; }
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); }
public virtual object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { Debug.Assert((typeOfExpression != null)); Debug.Assert((typeOfExpression.TypeReference != null)); nodeStack.Push(typeOfExpression.TypeReference); typeOfExpression.TypeReference.AcceptVisitor(this, data); typeOfExpression.TypeReference = ((TypeReference)(nodeStack.Pop())); return null; }
/// <summary> /// Adds the linking attribute. /// </summary> /// <param name="contractClass">The contract class.</param> private void AddLinkingAttribute(Class contractClass) { Contract.Requires(contractClass != null, "contractClass must not be null."); var typeOfExp = new TypeOfExpression(new TypeReferenceExpression(this.InterfaceName)); var attribute = new CustomAttribute() { Name = ContractClassFor }; if (attribute.Arguments != null) { attribute.Arguments.Add(typeOfExp); } var section = new AttributeSection(); if (section.AttributeCollection != null) { section.AttributeCollection.Add(attribute); } contractClass.AddAttributeSection(section); }
public sealed override object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { BeginVisit(typeOfExpression); object result = TrackedVisitTypeOfExpression(typeOfExpression, data); EndVisit(typeOfExpression); return result; }
public override object Visit(TypeOfExpression typeOfExpression, object data) { return new ReturnType("System.Type"); }
public override object Visit (TypeOf typeOfExpression) { var result = new TypeOfExpression (); var location = LocationsBag.GetLocations (typeOfExpression); result.AddChild (new CSharpTokenNode (Convert (typeOfExpression.Location), "typeof".Length), TypeOfExpression.Roles.Keyword); result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); result.AddChild ((INode)typeOfExpression.TypeExpression.Accept (this), TypeOfExpression.Roles.ReturnType); result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); return result; }
public TypeofBlock(IEmitter emitter, TypeOfExpression typeOfExpression) : base(emitter, typeOfExpression) { this.Emitter = emitter; this.TypeOfExpression = typeOfExpression; }
public virtual object TrackedVisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { return base.VisitTypeOfExpression(typeOfExpression, data); }
public override void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { ForceSpacesBefore(typeOfExpression.LParToken, policy.SpaceBeforeTypeOfParentheses); ForceSpacesAfter(typeOfExpression.LParToken, policy.SpacesWithinTypeOfParentheses); ForceSpacesBefore(typeOfExpression.RParToken, policy.SpacesWithinTypeOfParentheses); base.VisitTypeOfExpression(typeOfExpression); }
public virtual void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { DebugExpression(typeOfExpression); StartNode(typeOfExpression); WriteKeyword(TypeOfExpression.TypeofKeywordRole); var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses); Space(policy.SpacesWithinTypeOfParentheses); typeOfExpression.Type.AcceptVisitor(this); Space(policy.SpacesWithinTypeOfParentheses); braceHelper.RightParen(); EndNode(typeOfExpression); }
public override object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) { UnlockWith(typeOfExpression); return base.VisitTypeOfExpression(typeOfExpression, data); }
public Expression ConvertConstantValue(ResolveResult rr) { if (rr == null) throw new ArgumentNullException("rr"); if (rr is ConversionResolveResult) { // unpack ConversionResolveResult if necessary // (e.g. a boxing conversion or string->object reference conversion) rr = ((ConversionResolveResult)rr).Input; } if (rr is TypeOfResolveResult) { var expr = new TypeOfExpression(ConvertType(((TypeOfResolveResult)rr).ReferencedType)); if (AddResolveResultAnnotations) expr.AddAnnotation(rr); return expr; } else if (rr is ArrayCreateResolveResult) { ArrayCreateResolveResult acrr = (ArrayCreateResolveResult)rr; ArrayCreateExpression ace = new ArrayCreateExpression(); ace.Type = ConvertType(acrr.Type); ComposedType composedType = ace.Type as ComposedType; if (composedType != null) { composedType.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers); if (!composedType.HasNullableSpecifier && composedType.PointerRank == 0) ace.Type = composedType.BaseType; } if (acrr.SizeArguments != null && acrr.InitializerElements == null) { ace.AdditionalArraySpecifiers.FirstOrNullObject().Remove(); ace.Arguments.AddRange(acrr.SizeArguments.Select(ConvertConstantValue)); } if (acrr.InitializerElements != null) { ArrayInitializerExpression initializer = new ArrayInitializerExpression(); initializer.Elements.AddRange(acrr.InitializerElements.Select(ConvertConstantValue)); ace.Initializer = initializer; } if (AddResolveResultAnnotations) ace.AddAnnotation(rr); return ace; } else if (rr.IsCompileTimeConstant) { return ConvertConstantValue(rr.Type, rr.ConstantValue); } else { return new ErrorExpression(); } }
public virtual void VisitTypeOfExpression (TypeOfExpression typeOfExpression) { VisitChildren (typeOfExpression); }
private static Expression ConvertArgumentValue(CustomAttributeArgument parameter) { var type = parameter.Type.Resolve(); Expression parameterValue; if (type.IsEnum) { parameterValue = MakePrimitive(Convert.ToInt64(parameter.Value), type); } else if (parameter.Value is TypeReference) { parameterValue = new TypeOfExpression() { Type = ConvertType((TypeReference)parameter.Value), }; } else { parameterValue = new PrimitiveExpression(parameter.Value); } return parameterValue; }
public void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { StartNode(typeOfExpression); WriteKeyword(TypeOfExpression.TypeofKeywordRole); LPar(); Space(policy.SpacesWithinTypeOfParentheses); typeOfExpression.Type.AcceptVisitor(this); Space(policy.SpacesWithinTypeOfParentheses); RPar(); EndNode(typeOfExpression); }
void PrimaryExpr( #line 1862 "cs.ATG" out Expression pexpr) { #line 1864 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; #line 1869 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); #line 1871 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); #line 1872 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); #line 1873 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); #line 1874 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( #line 1875 "cs.ATG" StartOfQueryExpression()) { QueryExpression( #line 1876 "cs.ATG" out pexpr); } else if ( #line 1877 "cs.ATG" IdentAndDoubleColon()) { Identifier(); #line 1878 "cs.ATG" type = new TypeReference(t.val); Expect(10); #line 1879 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); #line 1880 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); #line 1884 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || #line 1887 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( #line 1886 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { #line 1888 "cs.ATG" List<TypeReference> typeList; TypeArgumentList( #line 1889 "cs.ATG" out typeList, false); #line 1890 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( #line 1892 "cs.ATG" IsLambdaExpression()) { LambdaExpression( #line 1893 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( #line 1896 "cs.ATG" out expr); Expect(21); #line 1896 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { #line 1899 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); #line 1900 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); #line 1901 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); #line 1902 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); #line 1903 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); #line 1904 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); #line 1905 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); #line 1906 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); #line 1907 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); #line 1908 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); #line 1909 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); #line 1910 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); #line 1911 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); #line 1912 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); #line 1913 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); #line 1914 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); #line 1915 "cs.ATG" val = "System.Void"; break; } } #line 1917 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); #line 1920 "cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); #line 1922 "cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( #line 1925 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( #line 1929 "cs.ATG" NotVoidPointer()) { Expect(123); #line 1929 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( #line 1930 "cs.ATG" out type, true, true); } else SynErr(208); Expect(21); #line 1932 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( #line 1934 "cs.ATG" out type); Expect(21); #line 1934 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( #line 1935 "cs.ATG" out type); Expect(21); #line 1935 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( #line 1936 "cs.ATG" out expr); Expect(21); #line 1936 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( #line 1937 "cs.ATG" out expr); Expect(21); #line 1937 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( #line 1938 "cs.ATG" out expr); #line 1938 "cs.ATG" pexpr = expr; } else SynErr(209); #line 1940 "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 1948 "cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); #line 1950 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); #line 1951 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(210); } else if (la.kind == 47) { PointerMemberAccess( #line 1954 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( #line 1955 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); #line 1959 "cs.ATG" List<Expression> parameters = new List<Expression>(); #line 1960 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); if (StartOf(26)) { Argument( #line 1961 "cs.ATG" out expr); #line 1961 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( #line 1962 "cs.ATG" out expr); #line 1962 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { #line 1968 "cs.ATG" List<Expression> indices = new List<Expression>(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( #line 1971 "cs.ATG" out expr); #line 1971 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( #line 1972 "cs.ATG" out expr); #line 1972 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); #line 1975 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; } } } }