public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (nameComparer.Equals(identifierExpression.Identifier, from)) { identifierExpression.Identifier = to; } return base.VisitIdentifierExpression(identifierExpression, data); }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (constantTable == null) { constantTable = CreateDictionary("Constants"); } Expression expr; if (constantTable.TryGetValue(identifierExpression.Identifier, out expr)) { MemberReferenceExpression fre = new MemberReferenceExpression(expr, identifierExpression.Identifier); ReplaceCurrentNode(fre); return base.VisitMemberReferenceExpression(fre, data); } return base.VisitIdentifierExpression(identifierExpression, data); }
static Dictionary<string, Expression> CreateDictionary(params string[] classNames) { Dictionary<string, Expression> d = new Dictionary<string, Expression>(StringComparer.InvariantCultureIgnoreCase); Assembly asm = Assembly.Load(VBAssemblyName); foreach (string className in classNames) { Type type = asm.GetType("Microsoft.VisualBasic." + className); Expression expr = new IdentifierExpression(className); foreach (MemberInfo member in type.GetMembers()) { if (member.DeclaringType == type) { // only direct members d[member.Name] = expr; } } } return d; }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (identifierExpression.Identifier.Equals(functionName, StringComparison.InvariantCultureIgnoreCase)) { if (!(identifierExpression.Parent is AddressOfExpression) && !(identifierExpression.Parent is InvocationExpression)) { identifierExpression.Identifier = FunctionReturnValueName; replacementCount++; } } return base.VisitIdentifierExpression(identifierExpression, data); }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { return symbols.ContainsKey(identifierExpression.Identifier) ? SymbolDefined : null; }
public virtual object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { throw new global::System.NotImplementedException("IdentifierExpression"); }
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 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; } } } }
public override object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) { string[] types = typeReferenceExpression.TypeReference.Type.Split ('.'); if (types == null || types.Length == 0) return null; if (types.Length == 1) { ResolveResult result = resolver.ResolveIdentifier (this, typeReferenceExpression.TypeReference.Type); if (result == null) result = CreateResult (typeReferenceExpression.TypeReference); result.StaticResolve = true; return result; } Expression expr = new IdentifierExpression (types[0]); for (int i = 1; i < types.Length; i++) { if (types[i] != "?") expr = new MemberReferenceExpression (expr, types[i]); } return expr.AcceptVisitor (this, data); }
/// <summary> /// Afferent coupling at field level /// </summary> /// <param name="expression"> /// A <see cref="IdentifierExpression"/> /// </param> /// <param name="meth"> /// A <see cref="MethodProperties"/> /// </param> public static void EvaluateFieldCoupling(IdentifierExpression expression, MethodProperties meth) { //TODO }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (identifierExpression.TypeArguments != null && identifierExpression.TypeArguments.Count > 0) { if (resolver.CallingType != null) { foreach (var type in resolver.Dom.GetInheritanceTree (resolver.CallingType)) { IMethod possibleMethod = type.Methods.Where (m => m.Name == identifierExpression.Identifier && m.TypeParameters.Count == identifierExpression.TypeArguments.Count && m.IsAccessibleFrom (resolver.Dom, resolver.CallingType, resolver.CallingMember, true)).FirstOrDefault (); if (possibleMethod != null) { MethodResolveResult methodResolveResult = new MethodResolveResult (possibleMethod); methodResolveResult.CallingType = resolver.CallingType; methodResolveResult.CallingMember = resolver.CallingMember; identifierExpression.TypeArguments.ForEach (arg => methodResolveResult.AddGenericArgument (resolver.ResolveType (NRefactoryResolver.ConvertTypeReference (arg)))); methodResolveResult.ResolveExtensionMethods (); return methodResolveResult; } } } TypeReference reference = new TypeReference (identifierExpression.Identifier); reference.GenericTypes.AddRange (identifierExpression.TypeArguments); ResolveResult result = CreateResult (reference); result.StaticResolve = true; return result; } // Console.WriteLine ("visit id: " + identifierExpression.Identifier); var res = resolver.ResolveIdentifier (this, identifierExpression.Identifier.TrimEnd ('.')); // Console.WriteLine ("result: " + res); return res; }
public virtual object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { Debug.Assert((identifierExpression != null)); Debug.Assert((identifierExpression.TypeArguments != null)); for (int i = 0; i < identifierExpression.TypeArguments.Count; i++) { TypeReference o = identifierExpression.TypeArguments[i]; Debug.Assert(o != null); nodeStack.Push(o); o.AcceptVisitor(this, data); o = (TypeReference)nodeStack.Pop(); if (o == null) identifierExpression.TypeArguments.RemoveAt(i--); else identifierExpression.TypeArguments[i] = o; } return null; }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { string name = identifierExpression.Identifier; foreach (VariableDeclaration var in fields) { if (var.Name == name && !IsLocal(name)) { identifierExpression.Identifier = prefix + name; break; } } return base.VisitIdentifierExpression(identifierExpression, data); }
public virtual object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { return base.VisitIdentifierExpression(identifierExpression, data); }
public override object VisitIdentifierExpression(ICSharpCode.OldNRefactory.Ast.IdentifierExpression identifierExpression, object data) { identifiers.Add(identifierExpression.Identifier); return(null); }
public sealed override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { this.BeginVisit(identifierExpression); object result = this.TrackedVisitIdentifierExpression(identifierExpression, data); this.EndVisit(identifierExpression); return result; }
public void VisitExpression (IdentifierExpression expression, MethodProperties meth) { if(cls.Fields.ContainsKey(expression.Identifier)){ cls.Fields[expression.Identifier].InternalAccessCount++; } else { foreach(var field in cls.Fields){ //TODO External access } } }
void ShortedLambdaExpression( #line 2113 "Frames/cs.ATG" IdentifierExpression ident, out Expression pexpr) { #line 2114 "Frames/cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); #line 2119 "Frames/cs.ATG" lambda.StartLocation = ident.StartLocation; SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( #line 2124 "Frames/cs.ATG" lambda); }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { usedIdentifiers[identifierExpression.Identifier] = null; return null; }
public virtual object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { Debug.Assert((identifierExpression != null)); Debug.Assert((identifierExpression.TypeArguments != null)); foreach (TypeReference o in identifierExpression.TypeArguments) { Debug.Assert(o != null); o.AcceptVisitor(this, data); } return null; }
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (!IsLocalVariable(identifierExpression.Identifier) && IsField(identifierExpression.Identifier)) { return new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), identifierExpression.Identifier); } return new CodeVariableReferenceExpression(identifierExpression.Identifier); }