Inheritance: ICSharpCode.NRefactory.Ast.Expression
Exemple #1
0
        public override object VisitUnaryOperatorExpression(ICSharpCode.NRefactory.Ast.UnaryOperatorExpression unaryOperatorExpression, object data)
        {
            switch (unaryOperatorExpression.Op)
            {
            case UnaryOperatorType.Increment:
            case UnaryOperatorType.Decrement:
            case UnaryOperatorType.PostIncrement:
            case UnaryOperatorType.PostDecrement:
                valueGetsChanged = true;
                break;
            }
            object result = base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);

            valueGetsChanged = false;
            switch (unaryOperatorExpression.Op)
            {
            case UnaryOperatorType.Increment:
            case UnaryOperatorType.Decrement:
            case UnaryOperatorType.PostIncrement:
            case UnaryOperatorType.PostDecrement:
                IdentifierExpression left = unaryOperatorExpression.Expression as IdentifierExpression;
                if (left != null && variables.ContainsKey(left.Identifier))
                {
                    variables[left.Identifier].GetsChanged = true;
                }
                break;
            }
            return(result);
        }
		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			if (unaryOperatorExpression.Op == UnaryOperatorType.Not) {
				return unaryOperatorExpression.Expression.AcceptVisitor(this, data) == SymbolDefined ? null : SymbolDefined;
			} else {
				return null;
			}
		}
		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			TypeReference intReference = new TypeReference("System.Int32");
			MethodDeclaration method = new MethodDeclaration("GetHashCode", Modifiers.Public | Modifiers.Override, intReference, null, null);
			Expression expr = CallGetHashCode(new IdentifierExpression(currentClass.Fields[0].Name));
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				IdentifierExpression identifier = new IdentifierExpression(currentClass.Fields[i].Name);
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ExclusiveOr,
				                                    CallGetHashCode(identifier));
			}
			method.Body = new BlockStatement();
			method.Body.AddChild(new ReturnStatement(expr));
			nodes.Add(method);
			
			TypeReference boolReference = new TypeReference("System.Boolean");
			TypeReference objectReference = new TypeReference("System.Object");
			
			method = new MethodDeclaration("Equals", Modifiers.Public | Modifiers.Override, boolReference, null, null);
			method.Parameters.Add(new ParameterDeclarationExpression(objectReference, "obj"));
			method.Body = new BlockStatement();
			
			TypeReference currentType = ConvertType(currentClass.DefaultReturnType);
			expr = new TypeOfIsExpression(new IdentifierExpression("obj"), currentType);
			expr = new ParenthesizedExpression(expr);
			expr = new UnaryOperatorExpression(expr, UnaryOperatorType.Not);
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(false, "false"))));
			
			expr = new BinaryOperatorExpression(new ThisReferenceExpression(),
			                                    BinaryOperatorType.Equality,
			                                    new IdentifierExpression("obj"));
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(true, "true"))));
			
			VariableDeclaration var = new VariableDeclaration("my" + currentClass.Name,
			                                                  new CastExpression(currentType, new IdentifierExpression("obj"), CastType.Cast),
			                                                  currentType);
			method.Body.AddChild(new LocalVariableDeclaration(var));
			
			expr = TestEquality(var.Name, currentClass.Fields[0]);
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
				                                    TestEquality(var.Name, currentClass.Fields[i]));
			}
			
			method.Body.AddChild(new ReturnStatement(expr));
			
			nodes.Add(method);
		}
Exemple #4
0
	void NotExpr(
//#line  1993 "VBNET.ATG" 
out Expression outExpr) {

//#line  1994 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 164) {
			lexer.NextToken();

//#line  1995 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
//#line  1996 "VBNET.ATG" 
out outExpr);

//#line  1997 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
 private object CreateIncrementStatement(UnaryOperatorExpression unaryOperatorExpression)
 {
     object obj = this.CreateIncrementStatement(unaryOperatorExpression, 1, NRefactoryToPythonConverter.GetBinaryOperator(BinaryOperatorType.Add));
     return obj;
 }
		public sealed override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			this.BeginVisit(unaryOperatorExpression);
			object result = this.TrackedVisitUnaryOperatorExpression(unaryOperatorExpression, data);
			this.EndVisit(unaryOperatorExpression);
			return result;
		}
		public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			throw new global::System.NotImplementedException("UnaryOperatorExpression");
		}
	void NotExpr(
#line  1810 "VBNET.ATG" 
out Expression outExpr) {

#line  1811 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 150) {
			lexer.NextToken();

#line  1812 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
#line  1813 "VBNET.ATG" 
out outExpr);

#line  1814 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
Exemple #9
0
	void PrimaryExpr(
#line  1895 "cs.ATG" 
out Expression pexpr) {

#line  1897 "cs.ATG" 
		TypeReference type = null;
		Expression expr;
		pexpr = null;
		

#line  1902 "cs.ATG" 
		Location startLocation = la.Location; 
		if (la.kind == 113) {
			lexer.NextToken();

#line  1904 "cs.ATG" 
			pexpr = new PrimitiveExpression(true, "true");  
		} else if (la.kind == 72) {
			lexer.NextToken();

#line  1905 "cs.ATG" 
			pexpr = new PrimitiveExpression(false, "false"); 
		} else if (la.kind == 90) {
			lexer.NextToken();

#line  1906 "cs.ATG" 
			pexpr = new PrimitiveExpression(null, "null");  
		} else if (la.kind == 2) {
			lexer.NextToken();

#line  1907 "cs.ATG" 
			pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
		} else if (
#line  1908 "cs.ATG" 
StartOfQueryExpression()) {
			QueryExpression(
#line  1909 "cs.ATG" 
out pexpr);
		} else if (
#line  1910 "cs.ATG" 
IdentAndDoubleColon()) {
			Identifier();

#line  1911 "cs.ATG" 
			type = new TypeReference(t.val); 
			Expect(10);

#line  1912 "cs.ATG" 
			pexpr = new TypeReferenceExpression(type); 
			Identifier();

#line  1913 "cs.ATG" 
			if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); 
		} else if (la.kind == 64) {
			lexer.NextToken();
			AnonymousMethodExpr(
#line  1915 "cs.ATG" 
out expr);

#line  1915 "cs.ATG" 
			pexpr = expr; 
		} else if (
#line  1916 "cs.ATG" 
la.kind == Tokens.Async && Peek(1).kind == Tokens.Delegate) {
			Expect(145);
			Expect(64);
			AnonymousMethodExpr(
#line  1917 "cs.ATG" 
out expr);

#line  1917 "cs.ATG" 
			pexpr = expr; 

#line  1918 "cs.ATG" 
			((AnonymousMethodExpression)expr).IsAsync = true; 
		} else if (
#line  1920 "cs.ATG" 
la.kind == Tokens.Async && Peek(1).kind == Tokens.OpenParenthesis) {
			Expect(145);
			LambdaExpression(
#line  1922 "cs.ATG" 
out pexpr);

#line  1923 "cs.ATG" 
			((LambdaExpression)pexpr).IsAsync = true; 
		} else if (
#line  1925 "cs.ATG" 
la.kind == Tokens.Async && IsIdentifierToken(Peek(1))) {
			Expect(145);
			Identifier();

#line  1927 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			ShortedLambdaExpression(
#line  1928 "cs.ATG" 
(IdentifierExpression)pexpr, out pexpr);

#line  1929 "cs.ATG" 
			((LambdaExpression)pexpr).IsAsync = true; 
		} else if (StartOf(18)) {
			Identifier();

#line  1933 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			if (la.kind == 48 || 
#line  1936 "cs.ATG" 
IsGenericInSimpleNameOrMemberAccess()) {
				if (la.kind == 48) {
					ShortedLambdaExpression(
#line  1935 "cs.ATG" 
(IdentifierExpression)pexpr, out pexpr);
				} else {

#line  1937 "cs.ATG" 
					List<TypeReference> typeList; 
					TypeArgumentList(
#line  1938 "cs.ATG" 
out typeList, false);

#line  1939 "cs.ATG" 
					((IdentifierExpression)pexpr).TypeArguments = typeList; 
				}
			}
		} else if (
#line  1942 "cs.ATG" 
IsLambdaExpression()) {
			LambdaExpression(
#line  1943 "cs.ATG" 
out pexpr);
		} else if (la.kind == 20) {
			lexer.NextToken();
			Expr(
#line  1946 "cs.ATG" 
out expr);
			Expect(21);

#line  1946 "cs.ATG" 
			pexpr = new ParenthesizedExpression(expr); 
		} else if (StartOf(34)) {

#line  1949 "cs.ATG" 
			string val = null; 
			switch (la.kind) {
			case 52: {
				lexer.NextToken();

#line  1950 "cs.ATG" 
				val = "System.Boolean"; 
				break;
			}
			case 54: {
				lexer.NextToken();

#line  1951 "cs.ATG" 
				val = "System.Byte"; 
				break;
			}
			case 57: {
				lexer.NextToken();

#line  1952 "cs.ATG" 
				val = "System.Char"; 
				break;
			}
			case 62: {
				lexer.NextToken();

#line  1953 "cs.ATG" 
				val = "System.Decimal"; 
				break;
			}
			case 66: {
				lexer.NextToken();

#line  1954 "cs.ATG" 
				val = "System.Double"; 
				break;
			}
			case 75: {
				lexer.NextToken();

#line  1955 "cs.ATG" 
				val = "System.Single"; 
				break;
			}
			case 82: {
				lexer.NextToken();

#line  1956 "cs.ATG" 
				val = "System.Int32"; 
				break;
			}
			case 87: {
				lexer.NextToken();

#line  1957 "cs.ATG" 
				val = "System.Int64"; 
				break;
			}
			case 91: {
				lexer.NextToken();

#line  1958 "cs.ATG" 
				val = "System.Object"; 
				break;
			}
			case 102: {
				lexer.NextToken();

#line  1959 "cs.ATG" 
				val = "System.SByte"; 
				break;
			}
			case 104: {
				lexer.NextToken();

#line  1960 "cs.ATG" 
				val = "System.Int16"; 
				break;
			}
			case 108: {
				lexer.NextToken();

#line  1961 "cs.ATG" 
				val = "System.String"; 
				break;
			}
			case 116: {
				lexer.NextToken();

#line  1962 "cs.ATG" 
				val = "System.UInt32"; 
				break;
			}
			case 117: {
				lexer.NextToken();

#line  1963 "cs.ATG" 
				val = "System.UInt64"; 
				break;
			}
			case 120: {
				lexer.NextToken();

#line  1964 "cs.ATG" 
				val = "System.UInt16"; 
				break;
			}
			case 123: {
				lexer.NextToken();

#line  1965 "cs.ATG" 
				val = "System.Void"; 
				break;
			}
			}

#line  1967 "cs.ATG" 
			pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1970 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  1972 "cs.ATG" 
			pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 89) {
			NewExpression(
#line  1975 "cs.ATG" 
out pexpr);
		} else if (la.kind == 115) {
			lexer.NextToken();
			Expect(20);
			if (
#line  1979 "cs.ATG" 
NotVoidPointer()) {
				Expect(123);

#line  1979 "cs.ATG" 
				type = new TypeReference("System.Void", true); 
			} else if (StartOf(10)) {
				TypeWithRestriction(
#line  1980 "cs.ATG" 
out type, true, true);
			} else SynErr(208);
			Expect(21);

#line  1982 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1984 "cs.ATG" 
out type);
			Expect(21);

#line  1984 "cs.ATG" 
			pexpr = new DefaultValueExpression(type); 
		} else if (la.kind == 105) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1985 "cs.ATG" 
out type);
			Expect(21);

#line  1985 "cs.ATG" 
			pexpr = new SizeOfExpression(type); 
		} else if (la.kind == 58) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1986 "cs.ATG" 
out expr);
			Expect(21);

#line  1986 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
		} else if (la.kind == 118) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1987 "cs.ATG" 
out expr);
			Expect(21);

#line  1987 "cs.ATG" 
			pexpr = new UncheckedExpression(expr); 
		} else SynErr(209);

#line  1989 "cs.ATG" 
		if (pexpr != null) {
		if (pexpr.StartLocation.IsEmpty)
			pexpr.StartLocation = startLocation;
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(35)) {

#line  1997 "cs.ATG" 
			startLocation = la.Location; 
			switch (la.kind) {
			case 31: {
				lexer.NextToken();

#line  1999 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				break;
			}
			case 32: {
				lexer.NextToken();

#line  2001 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				break;
			}
			case 47: {
				PointerMemberAccess(
#line  2003 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 15: {
				MemberAccess(
#line  2004 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 20: {
				lexer.NextToken();

#line  2008 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  2009 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(25)) {
					Argument(
#line  2010 "cs.ATG" 
out expr);

#line  2010 "cs.ATG" 
					SafeAdd(pexpr, parameters, expr); 
					while (la.kind == 14) {
						lexer.NextToken();
						Argument(
#line  2011 "cs.ATG" 
out expr);

#line  2011 "cs.ATG" 
						SafeAdd(pexpr, parameters, expr); 
					}
				}
				Expect(21);
				break;
			}
			case 18: {

#line  2017 "cs.ATG" 
				List<Expression> indices = new List<Expression>();
				pexpr = new IndexerExpression(pexpr, indices);
				
				lexer.NextToken();
				Expr(
#line  2020 "cs.ATG" 
out expr);

#line  2020 "cs.ATG" 
				SafeAdd(pexpr, indices, expr); 
				while (la.kind == 14) {
					lexer.NextToken();
					Expr(
#line  2021 "cs.ATG" 
out expr);

#line  2021 "cs.ATG" 
					SafeAdd(pexpr, indices, expr); 
				}
				Expect(19);
				break;
			}
			}

#line  2024 "cs.ATG" 
			if (pexpr != null) {
			if (pexpr.StartLocation.IsEmpty)
				pexpr.StartLocation = startLocation;
			if (pexpr.EndLocation.IsEmpty)
				pexpr.EndLocation = t.EndLocation;
			}
			
		}
	}
Exemple #10
0
	void NotExpr(
#line  1735 "VBNET.ATG" 
out Expression outExpr) {

#line  1736 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 129) {
			lexer.NextToken();

#line  1737 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
#line  1738 "VBNET.ATG" 
out outExpr);

#line  1739 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
Exemple #11
0
 public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
     throw CreateException(unaryOperatorExpression);
 }
		public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			Debug.Assert((unaryOperatorExpression != null));
			Debug.Assert((unaryOperatorExpression.Expression != null));
			nodeStack.Push(unaryOperatorExpression.Expression);
			unaryOperatorExpression.Expression.AcceptVisitor(this, data);
			unaryOperatorExpression.Expression = ((Expression)(nodeStack.Pop()));
			return null;
		}
		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			TypedValue value = Evaluate(unaryOperatorExpression.Expression);
			UnaryOperatorType op = unaryOperatorExpression.Op;
			
			if (op == UnaryOperatorType.Dereference) {
				if (!value.Type.IsPointer)
					throw new GetValueException("Target object is not a pointer");
				return new TypedValue(value.Value.Dereference(), (DebugType)value.Type.GetElementType());
			}
			
			if (!value.Type.IsPrimitive)
				throw new GetValueException("Primitive value expected");
			
			if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement ||
			    op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement)
			{
				TypedValue oldValue = value;
				TypedValue newValue = null;
				try {
					if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement)
						newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Subtract, new PrimitiveExpression(1)), null);
					if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement)
						newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Add, new PrimitiveExpression(1)), null);
				} catch (EvaluateException e) {
					throw new EvaluateException(unaryOperatorExpression, e.Message);
				}
				if (op == UnaryOperatorType.PostDecrement || op == UnaryOperatorType.PostIncrement) {
					return oldValue;
				} else {
					// Note: the old unaryOparatorExpression is still cached and still has the old value
					return newValue;
				}
			}
			
			if (op == UnaryOperatorType.Minus) {
				object val = value.PrimitiveValue;
				// Special case - it would promote the value to long otherwise
				if (val is uint && (uint)val == (uint)1 << 31)
					return CreateValue(int.MinValue);
				
				// Special case - it would overflow otherwise
				if (val is ulong && (ulong)val == (ulong)1 << 63)
					return CreateValue(long.MinValue);
			}
			
			if (op == UnaryOperatorType.Plus || op == UnaryOperatorType.Minus ||
			    op == UnaryOperatorType.BitNot || op == UnaryOperatorType.Not)
			{
				Type[] overloads;
				if (op == UnaryOperatorType.Not) {
					overloads = new Type[] { typeof(bool) };
				} else if (op == UnaryOperatorType.Minus) {
					overloads = new Type[] { typeof(int), typeof(long), typeof(ulong), typeof(float), typeof(double) };
				} else {
					overloads = new Type[] { typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double) };
				}
				foreach(Type argType in overloads) {
					if (value.Type.CanPromoteTo(argType)) {
						object a = Convert.ChangeType(value.PrimitiveValue, argType);
						object res;
						try {
							res = PerformUnaryOperation(a, op, argType);
						} catch (ArithmeticException e) {
							// Can happen for smaller int or long
							throw new EvaluateException(unaryOperatorExpression, e.Message);
						}
						if (res != null)
							return CreateValue(res);
						break; // Match only one overload
					}
				}
			}
			
			throw new EvaluateException(unaryOperatorExpression, "Can not use the unary operator {0} on type {1}", op.ToString(), value.Type.FullName);
		}
 public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 {
     if (unaryOperatorExpression.Op == UnaryOperatorType.PostIncrement || unaryOperatorExpression.Op == UnaryOperatorType.Increment)
         UnlockWith(unaryOperatorExpression);
     return base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
 }
Exemple #15
0
	void PrimaryExpr(
#line  1849 "cs.ATG" 
out Expression pexpr) {

#line  1851 "cs.ATG" 
		TypeReference type = null;
		Expression expr;
		pexpr = null;
		

#line  1856 "cs.ATG" 
		Location startLocation = la.Location; 
		if (la.kind == 113) {
			lexer.NextToken();

#line  1858 "cs.ATG" 
			pexpr = new PrimitiveExpression(true, "true");  
		} else if (la.kind == 72) {
			lexer.NextToken();

#line  1859 "cs.ATG" 
			pexpr = new PrimitiveExpression(false, "false"); 
		} else if (la.kind == 90) {
			lexer.NextToken();

#line  1860 "cs.ATG" 
			pexpr = new PrimitiveExpression(null, "null");  
		} else if (la.kind == 2) {
			lexer.NextToken();

#line  1861 "cs.ATG" 
            PrimitiveExpression primitiveExpression = new PrimitiveExpression(t.literalValue, t.val);
            primitiveExpression.LiteralFormat = t.literalFormat;
            pexpr = primitiveExpression;
            
		} else if (
#line  1862 "cs.ATG" 
StartOfQueryExpression()) {
			QueryExpression(
#line  1863 "cs.ATG" 
out pexpr);
		} else if (
#line  1864 "cs.ATG" 
IdentAndDoubleColon()) {
			Identifier();

#line  1865 "cs.ATG" 
			type = new TypeReference(t.val); 
			Expect(10);

#line  1866 "cs.ATG" 
			pexpr = new TypeReferenceExpression(type); 
			Identifier();

#line  1867 "cs.ATG" 
			if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); 
		} else if (StartOf(19)) {
			Identifier();

#line  1871 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			if (la.kind == 48 || 
#line  1874 "cs.ATG" 
IsGenericInSimpleNameOrMemberAccess()) {
				if (la.kind == 48) {
					ShortedLambdaExpression(
#line  1873 "cs.ATG" 
(IdentifierExpression)pexpr, out pexpr);
				} else {

#line  1875 "cs.ATG" 
					List<TypeReference> typeList; 
					TypeArgumentList(
#line  1876 "cs.ATG" 
out typeList, false);

#line  1877 "cs.ATG" 
					((IdentifierExpression)pexpr).TypeArguments = typeList; 
				}
			}
		} else if (
#line  1879 "cs.ATG" 
IsLambdaExpression()) {
			LambdaExpression(
#line  1880 "cs.ATG" 
out pexpr);
		} else if (la.kind == 20) {
			lexer.NextToken();
			Expr(
#line  1883 "cs.ATG" 
out expr);
			Expect(21);

#line  1883 "cs.ATG" 
			pexpr = new ParenthesizedExpression(expr); 
		} else if (StartOf(35)) {

#line  1886 "cs.ATG" 
			string val = null; 
			switch (la.kind) {
			case 52: {
				lexer.NextToken();

#line  1887 "cs.ATG" 
				val = "System.Boolean"; 
				break;
			}
			case 54: {
				lexer.NextToken();

#line  1888 "cs.ATG" 
				val = "System.Byte"; 
				break;
			}
			case 57: {
				lexer.NextToken();

#line  1889 "cs.ATG" 
				val = "System.Char"; 
				break;
			}
			case 62: {
				lexer.NextToken();

#line  1890 "cs.ATG" 
				val = "System.Decimal"; 
				break;
			}
			case 66: {
				lexer.NextToken();

#line  1891 "cs.ATG" 
				val = "System.Double"; 
				break;
			}
			case 75: {
				lexer.NextToken();

#line  1892 "cs.ATG" 
				val = "System.Single"; 
				break;
			}
			case 82: {
				lexer.NextToken();

#line  1893 "cs.ATG" 
				val = "System.Int32"; 
				break;
			}
			case 87: {
				lexer.NextToken();

#line  1894 "cs.ATG" 
				val = "System.Int64"; 
				break;
			}
			case 91: {
				lexer.NextToken();

#line  1895 "cs.ATG" 
				val = "System.Object"; 
				break;
			}
			case 102: {
				lexer.NextToken();

#line  1896 "cs.ATG" 
				val = "System.SByte"; 
				break;
			}
			case 104: {
				lexer.NextToken();

#line  1897 "cs.ATG" 
				val = "System.Int16"; 
				break;
			}
			case 108: {
				lexer.NextToken();

#line  1898 "cs.ATG" 
				val = "System.String"; 
				break;
			}
			case 116: {
				lexer.NextToken();

#line  1899 "cs.ATG" 
				val = "System.UInt32"; 
				break;
			}
			case 117: {
				lexer.NextToken();

#line  1900 "cs.ATG" 
				val = "System.UInt64"; 
				break;
			}
			case 120: {
				lexer.NextToken();

#line  1901 "cs.ATG" 
				val = "System.UInt16"; 
				break;
			}
			case 123: {
				lexer.NextToken();

#line  1902 "cs.ATG" 
				val = "System.Void"; 
				break;
			}
			}

#line  1904 "cs.ATG" 
			pexpr = new TypeReferenceExpression(new TypeReference(val, true));
            pexpr.StartLocation = t.Location;
            pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1907 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  1909 "cs.ATG" 
			pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 89) {
			NewExpression(
#line  1912 "cs.ATG" 
out pexpr);
		} else if (la.kind == 115) {
			lexer.NextToken();
			Expect(20);
			if (
#line  1916 "cs.ATG" 
NotVoidPointer()) {
				Expect(123);

#line  1916 "cs.ATG" 
				type = new TypeReference("System.Void", true); 
			} else if (StartOf(10)) {
				TypeWithRestriction(
#line  1917 "cs.ATG" 
out type, true, true);
			} else SynErr(207);
			Expect(21);

#line  1919 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1921 "cs.ATG" 
out type);
			Expect(21);

#line  1921 "cs.ATG" 
			pexpr = new DefaultValueExpression(type); 
		} else if (la.kind == 105) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1922 "cs.ATG" 
out type);
			Expect(21);

#line  1922 "cs.ATG" 
			pexpr = new SizeOfExpression(type); 
		} else if (la.kind == 58) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1923 "cs.ATG" 
out expr);
			Expect(21);

#line  1923 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
		} else if (la.kind == 118) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1924 "cs.ATG" 
out expr);
			Expect(21);

#line  1924 "cs.ATG" 
			pexpr = new UncheckedExpression(expr); 
		} else if (la.kind == 64) {
			lexer.NextToken();
			AnonymousMethodExpr(
#line  1925 "cs.ATG" 
out expr);

#line  1925 "cs.ATG" 
			pexpr = expr; 
		} else SynErr(208);

#line  1927 "cs.ATG" 
		if (pexpr != null) {
		if (pexpr.StartLocation.IsEmpty)
			pexpr.StartLocation = startLocation;
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(36)) {

#line  1935 "cs.ATG" 
			startLocation = la.Location; 
			switch (la.kind) {
			case 31: {
				lexer.NextToken();

#line  1937 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				break;
			}
			case 32: {
				lexer.NextToken();

#line  1939 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				break;
			}
			case 47: {
				PointerMemberAccess(
#line  1941 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 15: {
				MemberAccess(
#line  1942 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 20: {
				lexer.NextToken();

#line  1946 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  1947 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(26)) {
					Argument(
#line  1948 "cs.ATG" 
out expr);

#line  1948 "cs.ATG" 
					SafeAdd(pexpr, parameters, expr); 
					while (la.kind == 14) {
						lexer.NextToken();
						Argument(
#line  1949 "cs.ATG" 
out expr);

#line  1949 "cs.ATG" 
						SafeAdd(pexpr, parameters, expr); 
					}
				}
				Expect(21);
				break;
			}
			case 18: {

#line  1955 "cs.ATG" 
				List<Expression> indices = new List<Expression>();
				pexpr = new IndexerExpression(pexpr, indices);
				
				lexer.NextToken();
				Expr(
#line  1958 "cs.ATG" 
out expr);

#line  1958 "cs.ATG" 
				SafeAdd(pexpr, indices, expr); 
				while (la.kind == 14) {
					lexer.NextToken();
					Expr(
#line  1959 "cs.ATG" 
out expr);

#line  1959 "cs.ATG" 
					SafeAdd(pexpr, indices, expr); 
				}
				Expect(19);
				break;
			}
			}

#line  1962 "cs.ATG" 
			if (pexpr != null) {
			if (pexpr.StartLocation.IsEmpty)
				pexpr.StartLocation = startLocation;
			if (pexpr.EndLocation.IsEmpty)
				pexpr.EndLocation = t.EndLocation;
			}
			
		}
	}
Exemple #16
0
		public override object VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			string name = GetOperatorName (unaryOperatorExpression.Op);
			if (!String.IsNullOrEmpty (name)) {
				IReturnType returnType = GetTypeSafe (unaryOperatorExpression.Expression);
				IType type  = returnType != null ? this.resolver.Dom.GetType (returnType) : null;
				if (type != null) {
					int level;
					IMethod op = FindOperator (type, name, out level);
					if (op != null) {
						return CreateResult (op.ReturnType);
					}
				}
			
			}
			return Resolve (unaryOperatorExpression.Expression);
		}
		public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			switch (unaryOperatorExpression.Op) {
				case UnaryOperatorType.PostIncrement:
				case UnaryOperatorType.Increment:
					// Change i++ or ++i to i += 1
					return CreateIncrementStatement(unaryOperatorExpression);
				case UnaryOperatorType.Decrement:
				case UnaryOperatorType.PostDecrement:
					// Change --i or i-- to i -= 1.
					return CreateDecrementStatement(unaryOperatorExpression);
				case UnaryOperatorType.Minus:
					return CreateUnaryOperatorStatement(GetBinaryOperator(BinaryOperatorType.Subtract), unaryOperatorExpression.Expression);
				case UnaryOperatorType.Plus:
					return CreateUnaryOperatorStatement(GetBinaryOperator(BinaryOperatorType.Add), unaryOperatorExpression.Expression);
				case UnaryOperatorType.Not:
					return CreateUnaryOperatorStatement("not ", unaryOperatorExpression.Expression);
				case UnaryOperatorType.BitNot:
					return CreateUnaryOperatorStatement("~", unaryOperatorExpression.Expression);
			}
			return null;
		}
Exemple #18
0
	void UnaryExpr(
#line  1834 "VBNET.ATG" 
out Expression uExpr) {

#line  1836 "VBNET.ATG" 
		Expression expr;
		UnaryOperatorType uop = UnaryOperatorType.None;
		bool isUOp = false;
		
		while (la.kind == 14 || la.kind == 15 || la.kind == 16) {
			if (la.kind == 14) {
				lexer.NextToken();

#line  1840 "VBNET.ATG" 
				uop = UnaryOperatorType.Plus; isUOp = true; 
			} else if (la.kind == 15) {
				lexer.NextToken();

#line  1841 "VBNET.ATG" 
				uop = UnaryOperatorType.Minus; isUOp = true; 
			} else {
				lexer.NextToken();

#line  1842 "VBNET.ATG" 
				uop = UnaryOperatorType.Star;  isUOp = true;
			}
		}
		ExponentiationExpr(
#line  1844 "VBNET.ATG" 
out expr);

#line  1846 "VBNET.ATG" 
		if (isUOp) {
		uExpr = new UnaryOperatorExpression(expr, uop);
		} else {
			uExpr = expr;
		}
		
	}
		/// <summary>
		/// Converts a post or pre decrement expression to an assign statement.
		/// This converts "i--" and "--i" to "i -= 1" since python
		/// does not support post increment expressions.
		/// </summary>
		object CreateDecrementStatement(UnaryOperatorExpression unaryOperatorExpression)
		{
			return CreateIncrementStatement(unaryOperatorExpression, 1, GetBinaryOperator(BinaryOperatorType.Subtract));
		}
			public override object VisitUnaryOperatorExpression (UnaryOperatorExpression expression, object data)
			{
				Console.WriteLine ("UnaryOperatorExpression");
				IntegrateTemporaryVariableVisitorOptions options = (IntegrateTemporaryVariableVisitorOptions)data;
				if (IsExpressionToReplace (expression.Expression, options)) {
					if (IsUnary (options.Initializer))
						options.Changes.Add (ReplaceExpression (expression.Expression, options.Initializer, options)); else
						options.Changes.Add (ReplaceExpression (expression.Expression, new ParenthesizedExpression (options.Initializer), options));
					return null;
				} else {
					return base.VisitUnaryOperatorExpression (expression, data);
				}
			}
		/// <summary>
		/// Converts a post or pre increment expression to an assign statement.
		/// This converts "i++" and "++i" to "i += 1" since python
		/// does not support post increment expressions.
		/// </summary>
		object CreateIncrementStatement(UnaryOperatorExpression unaryOperatorExpression, int increment, string binaryOperator)
		{
			unaryOperatorExpression.Expression.AcceptVisitor(this, null);
			Append(" " + binaryOperator + "= ");
			Append(increment.ToString());
			
			return null;
		}
Exemple #22
0
	void UnaryExpr(
#line  1909 "VBNET.ATG" 
out Expression uExpr) {

#line  1911 "VBNET.ATG" 
		Expression expr;
		UnaryOperatorType uop = UnaryOperatorType.None;
		bool isUOp = false;
		
		while (la.kind == 18 || la.kind == 19 || la.kind == 22) {
			if (la.kind == 19) {
				lexer.NextToken();

#line  1915 "VBNET.ATG" 
				uop = UnaryOperatorType.Plus; isUOp = true; 
			} else if (la.kind == 18) {
				lexer.NextToken();

#line  1916 "VBNET.ATG" 
				uop = UnaryOperatorType.Minus; isUOp = true; 
			} else {
				lexer.NextToken();

#line  1917 "VBNET.ATG" 
				uop = UnaryOperatorType.Dereference;  isUOp = true;
			}
		}
		ExponentiationExpr(
#line  1919 "VBNET.ATG" 
out expr);

#line  1921 "VBNET.ATG" 
		if (isUOp) {
		uExpr = new UnaryOperatorExpression(expr, uop);
		} else {
			uExpr = expr;
		}
		
	}
Exemple #23
0
		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			IReturnType type = ResolveType(unaryOperatorExpression.Expression);
			if (type == null)
				return null;
			switch (unaryOperatorExpression.Op) {
				case UnaryOperatorType.AddressOf:
					return CreateResolveResult(new PointerReturnType(type));
				case UnaryOperatorType.Dereference:
					PointerReturnType prt = type.CastToDecoratingReturnType<PointerReturnType>();
					if (prt != null) {
						return CreateResolveResult(prt.BaseType);
					} else {
						return null;
					}
				case UnaryOperatorType.Await:
					var crt = type.CastToConstructedReturnType();
					if (crt != null && crt.Name == "Task" && crt.TypeArguments.Count == 1) {
						return CreateResolveResult(crt.TypeArguments[0]);
					} else {
						return null;
					}
				default:
					return CreateResolveResult(type);
			}
		}
		public virtual object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			return base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
		}
		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			IReturnType type = ResolveType(unaryOperatorExpression.Expression);
			if (type == null)
				return null;
			switch (unaryOperatorExpression.Op) {
				case UnaryOperatorType.AddressOf:
					return CreateResolveResult(new PointerReturnType(type));
				case UnaryOperatorType.Dereference:
					PointerReturnType prt = type.CastToDecoratingReturnType<PointerReturnType>();
					if (prt != null) {
						return CreateResolveResult(prt.BaseType);
					} else {
						return null;
					}
				default:
					return CreateResolveResult(type);
			}
		}
 public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 {
     object obj;
     switch (unaryOperatorExpression.Op)
     {
         case UnaryOperatorType.Not:
             {
                 obj = this.CreateUnaryOperatorStatement("not ", unaryOperatorExpression.Expression);
                 break;
             }
         case UnaryOperatorType.BitNot:
             {
                 obj = this.CreateUnaryOperatorStatement("~", unaryOperatorExpression.Expression);
                 break;
             }
         case UnaryOperatorType.Minus:
             {
                 obj = this.CreateUnaryOperatorStatement(NRefactoryToPythonConverter.GetBinaryOperator(BinaryOperatorType.Subtract), unaryOperatorExpression.Expression);
                 break;
             }
         case UnaryOperatorType.Plus:
             {
                 obj = this.CreateUnaryOperatorStatement(NRefactoryToPythonConverter.GetBinaryOperator(BinaryOperatorType.Add), unaryOperatorExpression.Expression);
                 break;
             }
         case UnaryOperatorType.Increment:
         case UnaryOperatorType.PostIncrement:
             {
                 obj = this.CreateIncrementStatement(unaryOperatorExpression);
                 break;
             }
         case UnaryOperatorType.Decrement:
         case UnaryOperatorType.PostDecrement:
             {
                 obj = this.CreateDecrementStatement(unaryOperatorExpression);
                 break;
             }
         default:
             {
                 obj = null;
                 break;
             }
     }
     return obj;
 }
 public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 {
     base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
     if (unaryOperatorExpression.Op == UnaryOperatorType.Not) {
         if (unaryOperatorExpression.Expression is BinaryOperatorExpression) {
             unaryOperatorExpression.Expression = new ParenthesizedExpression(unaryOperatorExpression.Expression);
         }
         ParenthesizedExpression pe = unaryOperatorExpression.Expression as ParenthesizedExpression;
         if (pe != null) {
             BinaryOperatorExpression boe = pe.Expression as BinaryOperatorExpression;
             if (boe != null && boe.Op == BinaryOperatorType.ReferenceEquality) {
                 boe.Op = BinaryOperatorType.ReferenceInequality;
                 ReplaceCurrentNode(pe);
             }
         }
     }
     return null;
 }
 private object CreateIncrementStatement(UnaryOperatorExpression unaryOperatorExpression, int increment, string binaryOperator)
 {
     unaryOperatorExpression.Expression.AcceptVisitor(this, null);
     this.Append(string.Concat(" ", binaryOperator, "= "));
     this.Append(increment.ToString());
     return null;
 }
 public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 {
     base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
     switch (unaryOperatorExpression.Op) {
         case UnaryOperatorType.Dereference:
             ReplaceCurrentNode(unaryOperatorExpression.Expression.Member("Target"));
             break;
         case UnaryOperatorType.AddressOf:
             ResolveResult rr = resolver.ResolveInternal(unaryOperatorExpression.Expression, ExpressionContext.Default);
             if (rr != null && rr.ResolvedType != null) {
                 TypeReference targetType = Refactoring.CodeGenerator.ConvertType(rr.ResolvedType, CreateContext());
                 TypeReference pointerType = new TypeReference("Pointer", new List<TypeReference>().add(targetType));
                 ReplaceCurrentNode(pointerType.New(unaryOperatorExpression.Expression));
             }
             break;
     }
     return null;
 }
Exemple #30
0
	void UnaryExpr(
//#line  2096 "VBNET.ATG" 
out Expression uExpr) {

//#line  2098 "VBNET.ATG" 
		Expression expr;
		UnaryOperatorType uop = UnaryOperatorType.None;
		Location startLocation = la.Location;
		bool isUOp = false;
		
		while (la.kind == 30 || la.kind == 31 || la.kind == 34) {
			if (la.kind == 31) {
				lexer.NextToken();

//#line  2103 "VBNET.ATG" 
				uop = UnaryOperatorType.Plus; isUOp = true; 
			} else if (la.kind == 30) {
				lexer.NextToken();

//#line  2104 "VBNET.ATG" 
				uop = UnaryOperatorType.Minus; isUOp = true; 
			} else {
				lexer.NextToken();

//#line  2105 "VBNET.ATG" 
				uop = UnaryOperatorType.Dereference;  isUOp = true;
			}
		}
		ExponentiationExpr(
//#line  2107 "VBNET.ATG" 
out expr);

//#line  2109 "VBNET.ATG" 
		if (isUOp) {
		uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation };
		} else {
			uExpr = expr;
		}
		
	}
Exemple #31
0
        public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
        {
            CodeExpression var;
            CodeAssignStatement assign;

            switch (unaryOperatorExpression.Op) {
                case UnaryOperatorType.Minus:
                    if (unaryOperatorExpression.Expression is PrimitiveExpression) {
                        PrimitiveExpression expression = (PrimitiveExpression)unaryOperatorExpression.Expression;
                        if (expression.Value is int) {
                            return new CodePrimitiveExpression(- (int)expression.Value);
                        }
                        if (expression.Value is System.UInt32 || expression.Value is System.UInt16) {
                            return new CodePrimitiveExpression(Int32.Parse("-" + expression.StringValue));
                        }

                        if (expression.Value is long) {
                            return new CodePrimitiveExpression(- (long)expression.Value);
                        }
                        if (expression.Value is double) {
                            return new CodePrimitiveExpression(- (double)expression.Value);
                        }
                        if (expression.Value is float) {
                            return new CodePrimitiveExpression(- (float)expression.Value);
                        }

                    }
                    return  new CodeBinaryOperatorExpression(new CodePrimitiveExpression(0),
                                                             CodeBinaryOperatorType.Subtract,
                                                             (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data));
                case UnaryOperatorType.Plus:
                    return unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                case UnaryOperatorType.PostIncrement:
                    // emulate i++, with i = i + 1
                    var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                    assign = new CodeAssignStatement(var,
                                                     new CodeBinaryOperatorExpression(var,
                                                                                      CodeBinaryOperatorType.Add,
                                                                                      new CodePrimitiveExpression(1)));

                    AddStmt(assign);

                    return assign;

                    //return new CodeAssignStatement(var,
                    //               new CodeBinaryOperatorExpression(var,
                    //                                                CodeBinaryOperatorType.Add,
                    //                                                new CodePrimitiveExpression(1)));

                    // RG: needs to return an Expression - Not a Statement
                    //return new CodeBinaryOperatorExpression(var,
                    //                               CodeBinaryOperatorType.Assign,
                    //                               new CodeBinaryOperatorExpression(var,
                    //                                                                CodeBinaryOperatorType.Add,
                    //                                                                new CodePrimitiveExpression(1)));

                case UnaryOperatorType.PostDecrement:
                    // emulate i--, with i = i - 1
                    var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                    assign = new CodeAssignStatement(var,
                                                     new CodeBinaryOperatorExpression(var,
                                                                                      CodeBinaryOperatorType.Subtract,
                                                                                      new CodePrimitiveExpression(1)));

                    AddStmt(assign);

                    return assign;

                    //return new CodeAssignStatement(var,
                    //                               new CodeBinaryOperatorExpression(var,
                    //                                                                CodeBinaryOperatorType.Subtract,
                    //                                                                new CodePrimitiveExpression(1)));

                    // RG: needs to return an Expression - Not a Statement
                    //return new CodeBinaryOperatorExpression(var,
                    //               CodeBinaryOperatorType.Assign,
                    //               new CodeBinaryOperatorExpression(var,
                    //                                                CodeBinaryOperatorType.Subtract,
                    //                                                new CodePrimitiveExpression(1)));

                case UnaryOperatorType.Decrement:
                    // emulate --i, with i = i - 1
                    var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                    assign = new CodeAssignStatement(var,
                                                     new CodeBinaryOperatorExpression(var,
                                                                                      CodeBinaryOperatorType.Subtract,
                                                                                      new CodePrimitiveExpression(1)));
                    AddStmt(assign);

                    return assign;
                    //return new CodeAssignStatement(var,
                    //                               new CodeBinaryOperatorExpression(var,
                    //                                                                CodeBinaryOperatorType.Subtract,
                    //                                                                new CodePrimitiveExpression(1)));

                    //return new CodeBinaryOperatorExpression(var,
                    //                CodeBinaryOperatorType.Assign,
                    //               new CodeBinaryOperatorExpression(var,
                    //                                                CodeBinaryOperatorType.Subtract,
                    //                                                new CodePrimitiveExpression(1)));

                case UnaryOperatorType.Increment:
                    // emulate ++i, with i = i + 1
                    var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                    assign = new CodeAssignStatement(var,
                                                     new CodeBinaryOperatorExpression(var,
                                                                                      CodeBinaryOperatorType.Add,
                                                                                      new CodePrimitiveExpression(1)));

                    AddStmt(assign);

                    return assign;

                    //return new CodeAssignStatement(var,
                    //                               new CodeBinaryOperatorExpression(var,
                    //                                                                CodeBinaryOperatorType.Add,
                    //                                                                new CodePrimitiveExpression(1)));

                    //return new CodeBinaryOperatorExpression(var,
                    //                CodeBinaryOperatorType.Assign,
                    //                new CodeBinaryOperatorExpression(var,
                    //                                                CodeBinaryOperatorType.Add,
                    //                                                new CodePrimitiveExpression(1)));

                    // RG:
                case UnaryOperatorType.Not:
                    // emulate !a with a == false
                    var = (CodeExpression)unaryOperatorExpression.Expression.AcceptVisitor(this, data);

                    return new CodeBinaryOperatorExpression(var,CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression(false));

                default:
                    throw new NotSupportedException("CodeDom does not support Unary Operators");
            }
        }