public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value is bool)
				return (bool)primitiveExpression.Value ? SymbolDefined : null;
			else
				return null;
		}
Exemplo n.º 2
0
		public virtual object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) {
			Debug.Assert((primitiveExpression != null));
			return null;
		}
Exemplo n.º 3
0
	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;
				}
				
			}
		}
	}
Exemplo n.º 4
0
	void UnaryExpr(
#line  1828 "Frames/cs.ATG" 
out Expression uExpr) {

#line  1830 "Frames/cs.ATG" 
		TypeReference type = null;
		Expression expr = null;
		ArrayList expressions = new ArrayList();
		uExpr = null;
		
		while (StartOf(33) || 
#line  1852 "Frames/cs.ATG" 
IsTypeCast()) {
			if (la.kind == 4) {
				lexer.NextToken();

#line  1839 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); 
			} else if (la.kind == 5) {
				lexer.NextToken();

#line  1840 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); 
			} else if (la.kind == 24) {
				lexer.NextToken();

#line  1841 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); 
			} else if (la.kind == 27) {
				lexer.NextToken();

#line  1842 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); 
			} else if (la.kind == 6) {
				lexer.NextToken();

#line  1843 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference)); 
			} else if (la.kind == 31) {
				lexer.NextToken();

#line  1844 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); 
			} else if (la.kind == 32) {
				lexer.NextToken();

#line  1845 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); 
			} else if (la.kind == 28) {
				lexer.NextToken();

#line  1846 "Frames/cs.ATG" 
				expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf)); 
			} else {
				Expect(20);
				Type(
#line  1852 "Frames/cs.ATG" 
out type);
				Expect(21);

#line  1852 "Frames/cs.ATG" 
				expressions.Add(new CastExpression(type)); 
			}
		}
		if (
#line  1857 "Frames/cs.ATG" 
LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) {
			Expect(2);

#line  1860 "Frames/cs.ATG" 
			expressions.RemoveAt(expressions.Count - 1);
			if (t.literalValue is uint) {
				expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString());
			} else if (t.literalValue is ulong) {
				expr = new PrimitiveExpression(long.MinValue, long.MinValue.ToString());
			} else {
				throw new Exception("t.literalValue must be uint or ulong");
			}
			
		} else if (StartOf(34)) {
			PrimaryExpr(
#line  1869 "Frames/cs.ATG" 
out expr);
		} else SynErr(206);

#line  1871 "Frames/cs.ATG" 
		for (int i = 0; i < expressions.Count; ++i) {
		Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr;
		if (expressions[i] is CastExpression) {
			((CastExpression)expressions[i]).Expression = nextExpression;
		} else {
			((UnaryOperatorExpression)expressions[i]).Expression = nextExpression;
		}
		}
		if (expressions.Count > 0) {
			uExpr = (Expression)expressions[0];
		} else {
			uExpr = expr;
		}
		
	}
		public sealed override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) {
			this.BeginVisit(primitiveExpression);
			object result = this.TrackedVisitPrimitiveExpression(primitiveExpression, data);
			this.EndVisit(primitiveExpression);
			return result;
		}
		public virtual object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) {
			return base.VisitPrimitiveExpression(primitiveExpression, data);
		}
Exemplo n.º 7
0
			public void VisitExpression (PrimitiveExpression expression, MethodProperties meth)
			{
				return;
			}
Exemplo n.º 8
0
	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);
	}
Exemplo n.º 9
0
        /// <summary>
        /// Returns the existing expression plus the specified integer value.
        /// The old <paramref name="expr"/> object is not modified, but might be a subobject on the new expression
        /// (and thus its parent property is modified).
        /// </summary>
        public static Expression AddInteger(Expression expr, int value)
        {
            PrimitiveExpression pe = expr as PrimitiveExpression;

            if (pe != null && pe.Value is int)
            {
                int newVal = (int)pe.Value + value;
                return(new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
            }
            BinaryOperatorExpression boe = expr as BinaryOperatorExpression;

            if (boe != null && boe.Op == BinaryOperatorType.Add)
            {
                // clone boe:
                boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);

                boe.Right = AddInteger(boe.Right, value);
                if (boe.Right is PrimitiveExpression && ((PrimitiveExpression)boe.Right).Value is int)
                {
                    int newVal = (int)((PrimitiveExpression)boe.Right).Value;
                    if (newVal == 0)
                    {
                        return(boe.Left);
                    }
                    else if (newVal < 0)
                    {
                        ((PrimitiveExpression)boe.Right).Value = -newVal;
                        boe.Op = BinaryOperatorType.Subtract;
                    }
                }
                return(boe);
            }
            if (boe != null && boe.Op == BinaryOperatorType.Subtract)
            {
                pe = boe.Right as PrimitiveExpression;
                if (pe != null && pe.Value is int)
                {
                    int newVal = (int)pe.Value - value;
                    if (newVal == 0)
                    {
                        return(boe.Left);
                    }

                    // clone boe:
                    boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);

                    if (newVal < 0)
                    {
                        newVal = -newVal;
                        boe.Op = BinaryOperatorType.Add;
                    }
                    boe.Right = new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
                    return(boe);
                }
            }
            BinaryOperatorType opType = BinaryOperatorType.Add;

            if (value < 0)
            {
                value  = -value;
                opType = BinaryOperatorType.Subtract;
            }
            return(new BinaryOperatorExpression(expr, opType, new PrimitiveExpression(value, value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo))));
        }
Exemplo n.º 10
0
		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value == null) 
				return CreateResult ("");
			Type type = primitiveExpression.Value.GetType();
			return CreateResult (type.FullName);
		}
		public virtual object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) {
			throw new global::System.NotImplementedException("PrimitiveExpression");
		}
Exemplo n.º 12
0
		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			return new CodePrimitiveExpression(primitiveExpression.Value);
		}