public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
 {
     if (nameComparer.Equals(identifierExpression.Identifier, from)) {
         identifierExpression.Identifier = to;
     }
     return base.VisitIdentifierExpression(identifierExpression, data);
 }
예제 #2
0
 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 void IdentifierOnlyInvocation()
 {
     // InitializeComponents();
     IdentifierExpression identifier = new IdentifierExpression("InitializeComponents");
     InvocationExpression invocation = new InvocationExpression(identifier, new List<Expression>());
     object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
     Assert.IsTrue(output is CodeMethodInvokeExpression);
     CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
     Assert.AreEqual("InitializeComponents", mie.Method.MethodName);
     Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression);
 }
 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);
 }
 public override sealed object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
 {
     this.BeginVisit(identifierExpression);
     object result = this.TrackedVisitIdentifierExpression(identifierExpression, data);
     this.EndVisit(identifierExpression);
     return result;
 }
 public virtual object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
 {
     return base.VisitIdentifierExpression(identifierExpression, data);
 }
예제 #7
0
 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 virtual object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
 {
     throw new global::System.NotImplementedException("IdentifierExpression");
 }
예제 #9
0
        void SimpleNonInvocationExpression(out Expression pexpr)
        {
            Expression expr;
            CollectionInitializerExpression cie;
            TypeReference type = null;
            string name = String.Empty;
            Location startLocation = la.Location;
            pexpr = null;

            if (StartOf(34)) {
            switch (la.kind) {
            case 3: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 4: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 7: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 6: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 5: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 9: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 8: {
                Get();
                pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
                break;
            }
            case 217: {
                Get();
                pexpr = new PrimitiveExpression(true, "true");
                break;
            }
            case 122: {
                Get();
                pexpr = new PrimitiveExpression(false, "false");
                break;
            }
            case 165: {
                Get();
                pexpr = new PrimitiveExpression(null, "null");
                break;
            }
            case 37: {
                Get();
                Expr(out expr);
                Expect(38);
                pexpr = new ParenthesizedExpression(expr);
                break;
            }
            case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
                Identifier();
                pexpr = new IdentifierExpression(t.val);
                    pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;

                if (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
                    Expect(37);
                    Expect(169);
                    TypeArgumentList(((IdentifierExpression)pexpr).TypeArguments);
                    Expect(38);
                }
                break;
            }
            case 68: case 71: case 82: case 99: case 100: case 109: case 141: case 151: case 168: case 196: case 201: case 202: case 208: case 221: case 222: case 225: {
                string val = String.Empty;
                if (StartOf(13)) {
                    PrimitiveTypeName(out val);
                } else {
                    Get();
                    val = "System.Object";
                }
                pexpr = new TypeReferenceExpression(new TypeReference(val, true));
                break;
            }
            case 153: {
                Get();
                pexpr = new ThisReferenceExpression();
                break;
            }
            case 158: case 159: {
                Expression retExpr = null;
                if (la.kind == 158) {
                    Get();
                    retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
                } else {
                    Get();
                    retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
                }
                Expect(26);
                IdentifierOrKeyword(out name);
                pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
                break;
            }
            case 130: {
                Get();
                Expect(26);
                Identifier();
                type = new TypeReference(t.val ?? "");
                type.IsGlobal = true;
                pexpr = new TypeReferenceExpression(type);
                break;
            }
            case 162: {
                ObjectCreateExpression(out expr);
                pexpr = expr;
                break;
            }
            case 35: {
                CollectionInitializer(out cie);
                pexpr = cie;
                break;
            }
            case 94: case 106: case 219: {
                CastType castType = CastType.Cast;
                if (la.kind == 106) {
                    Get();
                } else if (la.kind == 94) {
                    Get();
                    castType = CastType.Conversion;
                } else {
                    Get();
                    castType = CastType.TryCast;
                }
                Expect(37);
                Expr(out expr);
                Expect(22);
                TypeName(out type);
                Expect(38);
                pexpr = new CastExpression(type, expr, castType);
                break;
            }
            case 76: case 77: case 78: case 79: case 80: case 81: case 83: case 85: case 86: case 90: case 91: case 92: case 93: case 95: case 96: case 97: {
                CastTarget(out type);
                Expect(37);
                Expr(out expr);
                Expect(38);
                pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion);
                break;
            }
            case 57: {
                Get();
                SimpleExpr(out expr);
                pexpr = new AddressOfExpression(expr);
                break;
            }
            case 129: {
                Get();
                Expect(37);
                GetTypeTypeName(out type);
                Expect(38);
                pexpr = new TypeOfExpression(type);
                break;
            }
            case 220: {
                Get();
                SimpleExpr(out expr);
                Expect(144);
                TypeName(out type);
                pexpr = new TypeOfIsExpression(expr, type);
                break;
            }
            case 135: {
                ConditionalExpression(out pexpr);
                break;
            }
            case 10: case 16: case 17: case 18: case 19: {
                XmlLiteralExpression(out pexpr);
                break;
            }
            }
            } else if (StartOf(35)) {
            if (la.kind == 26) {
                Get();
                if (la.kind == 10) {
                    Get();
                    IdentifierOrKeyword(out name);
                    Expect(11);
                    pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation };
                } else if (StartOf(33)) {
                    IdentifierOrKeyword(out name);
                    pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
                } else SynErr(281);
            } else if (la.kind == 29) {
                Get();
                IdentifierOrKeyword(out name);
                pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation });
            } else {
                XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false;
                if (la.kind == 27) {
                    Get();
                    axisType = XmlAxisType.Descendents;
                } else {
                    Get();
                    axisType = XmlAxisType.Attribute;
                }
                if (la.kind == 10) {
                    Get();
                    isXmlIdentifier = true;
                }
                IdentifierOrKeyword(out name);
                if (la.kind == 11) {
                    Get();
                }
                pexpr = new XmlMemberAccessExpression(null, axisType, name, isXmlIdentifier);
            }
            } else SynErr(282);
            if (pexpr != null) {
                pexpr.StartLocation = startLocation;
                pexpr.EndLocation = t.EndLocation;
            }
        }
 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;
 }