public override void VisitAsExpression (AsExpression asExpression)
			{
				base.VisitAsExpression (asExpression);

				CheckTypeCast (asExpression, asExpression.Expression, asExpression.Expression.EndLocation,
					asExpression.EndLocation);
			}
			public override void VisitAsExpression (AsExpression asExpression)
			{
				base.VisitAsExpression (asExpression);

				VisitTypeCastExpression (asExpression, ctx.Resolve (asExpression.Expression).Type,
					ctx.ResolveType (asExpression.Type));
			}
 public override void VisitAsExpression(AsExpression asExpression)
 {
     if (InsertParenthesesForReadability) {
         // few people know the precedence of 'as', so always put parentheses in nice-looking mode.
         ParenthesizeIfRequired(asExpression.Expression, Primary);
     } else {
         ParenthesizeIfRequired(asExpression.Expression, RelationalAndTypeTesting);
     }
     base.VisitAsExpression(asExpression);
 }
 public override void VisitAsExpression(AsExpression asExpression)
 {
     HandleExpressionNode(asExpression);
 }
Пример #5
0
			public override object Visit (As asExpression)
			{
				var result = new AsExpression ();
				result.AddChild ((INode)asExpression.Expr.Accept (this), AsExpression.Roles.Expression);
				result.AddChild (new CSharpTokenNode (Convert (asExpression.Location), "as".Length), AsExpression.Roles.Keyword);
				result.AddChild ((INode)asExpression.ProbeType.Accept (this), AsExpression.Roles.ReturnType);
				return result;
			}
Пример #6
0
			public override object Visit(As asExpression)
			{
				var result = new AsExpression();
				if (asExpression.Expr != null)
					result.AddChild((Expression)asExpression.Expr.Accept(this), Roles.Expression);
				result.AddChild(new CSharpTokenNode(Convert(asExpression.Location), AsExpression.AsKeywordRole), AsExpression.AsKeywordRole);
				if (asExpression.ProbeType != null)
					result.AddChild(ConvertToType(asExpression.ProbeType), Roles.Type);
				return result;
			}
        /// <summary>
        /// Reads an as expression.
        /// </summary>
        /// <param name="leftHandSide">The expression on the left hand side of the operator.</param>
        /// <param name="previousPrecedence">The precedence of the expression just before this one.</param>
        /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param>
        /// <returns>Returns the expression.</returns>
        private AsExpression GetAsExpression(
            Expression leftHandSide, ExpressionPrecedence previousPrecedence, bool unsafeCode)
        {
            Param.AssertNotNull(leftHandSide, "leftHandSide");
            Param.Ignore(previousPrecedence);
            Param.Ignore(unsafeCode);

            AsExpression expression = null;

            // Check the previous precedence to see if we are allowed to gather up the as expression.
            if (this.CheckPrecedence(previousPrecedence, ExpressionPrecedence.Relational))
            {
                // Make sure the left hand side has at least one token.
                Debug.Assert(leftHandSide.Tokens.First != null, "The left hand side should not be empty");

                // Get the as symbol.
                this.tokens.Add(this.GetToken(CsTokenType.As, SymbolType.As));

                // The next token must be the type.
                this.GetNextSymbol(SymbolType.Other);

                // Get the expression representing the type.
                LiteralExpression rightHandSide = this.GetTypeTokenExpression(unsafeCode, true, true);
                if (rightHandSide == null || rightHandSide.Tokens.First == null)
                {
                    throw this.CreateSyntaxException();
                }

                // Create the partial token list for the expression.
                CsTokenList partialTokens = new CsTokenList(this.tokens, leftHandSide.Tokens.First, this.tokens.Last);

                // Create and return the expression.
                expression = new AsExpression(partialTokens, leftHandSide, rightHandSide);
            }

            return expression;
        }
Пример #8
0
 public CastBlock(IEmitter emitter, AsExpression asExpression)
     : base(emitter, asExpression)
 {
     this.Emitter = emitter;
     this.AsExpression = asExpression;
 }
Пример #9
0
 public override object VisitAsExpression(AsExpression asExpression, object data)
 {
     UnlockWith(asExpression);
     return base.VisitAsExpression(asExpression, data);
 }
Пример #10
0
 public RedILNode VisitAsExpression(AsExpression asExpression, State data)
 {
     // We only support casting into primitives for now
     return(asExpression.Expression.AcceptVisitor(this, data.NewState(asExpression, null)));
 }
Пример #11
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            AsExpression o = other as AsExpression;

            return(o != null && this.Expression.DoMatch(o.Expression, match) && this.Type.DoMatch(o.Type, match));
        }
Пример #12
0
 public override void VisitAsExpression(AsExpression asExpression)
 {
     new CastBlock(this, asExpression).Emit();
 }
Пример #13
0
 public virtual Node VisitAsExpression(AsExpression asExpression)
 {
     throw new System.NotImplementedException();
 }
Пример #14
0
 public override void VisitAsExpression(AsExpression asExpression)
 {
     asExpression.Expression.AcceptVisitor(this);
 }
Пример #15
0
 internal AstNode EmitAsExpression(AsExpression asExpression, ILGenerator ilGenerator)
 {
     return(new AsExpressionEmitter(asExpression, ilGenerator, _instructionIndexer, _visitor).Emit());
 }
Пример #16
0
 public override object VisitAsExpression(AsExpression asExpression, object data)
 {
     UnlockWith(asExpression);
     return(base.VisitAsExpression(asExpression, data));
 }
Пример #17
0
 public override void VisitAsExpression(AsExpression asExpression)
 {
     new CastBlock(this, asExpression).Emit();
 }
Пример #18
0
 public StringBuilder VisitAsExpression(AsExpression asExpression, int data)
 {
     throw new ASLException("ASL does not have reflection-supported casts.");
 }
Пример #19
0
		public void VisitAsExpression(AsExpression asExpression)
		{
			StartNode(asExpression);
			LPar ();
			LPar ();
			asExpression.Expression.AcceptVisitor(this);
			Space();
			WriteKeyword("instanceof", AsExpression.AsKeywordRole);
			Space();
			asExpression.Type.AcceptVisitor(this);
			EndNode(asExpression);
			RPar ();
			WriteToken ("?<", Roles.Expression);
			asExpression.Type.AcceptVisitor(this);
			WriteToken (">", Roles.Expression);
			asExpression.Expression.AcceptVisitor(this);
			WriteToken (":null", Roles.Expression);
			RPar ();
		}
Пример #20
0
 public CastBlock(IEmitter emitter, AsExpression asExpression)
     : base(emitter, asExpression)
 {
     this.Emitter      = emitter;
     this.AsExpression = asExpression;
 }
Пример #21
0
 public StringBuilder VisitAsExpression(AsExpression asExpression, int data)
 {
     throw new SLSharpException("SL# does not have reflection-supported casts.");
 }
Пример #22
0
 public void VisitAsExpression(AsExpression asExpression)
 {
     throw new NotImplementedException();
 }
 public virtual void VisitAsExpression(AsExpression asExpression)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(asExpression);
     }
 }
Пример #24
0
 public void VisitAsExpression(AsExpression node)
 {
     NotSupported(node);
 }
		public virtual void VisitAsExpression (AsExpression asExpression)
		{
			VisitChildren (asExpression);
		}
Пример #26
0
 public void VisitAsExpression(AsExpression asExpression)
 {
     JsonObject expression = CreateJsonExpression(asExpression);
     AddKeyword(expression, AsExpression.AsKeywordRole);
     expression.AddJsonValue("type-info", GenTypeInfo(asExpression.Type));
     Push(expression);
 }
Пример #27
0
		public void VisitAsExpression(AsExpression asExpression)
		{
			StartNode(asExpression);
			asExpression.Expression.AcceptVisitor(this);
			Space();
			WriteKeyword(AsExpression.AsKeywordRole);
			Space();
			asExpression.Type.AcceptVisitor(this);
			EndNode(asExpression);
		}
Пример #28
0
 public JsNode VisitAsExpression(AsExpression node)
 {
     return(Visit(node.Resolve()));
 }