Example #1
0
        public int Visit(InstanceOfExpression expression)
        {
            _writer.Write("(");
            expression.Left.Accept(this);
            _writer.Write(" instanceof ");

            var typeName = expression.Type.ToString();

            switch (typeName)
            {
            case "int":
                typeName = "Integer";
                break;

            case "float":
                typeName = "Float";
                break;

            case "boolean":
                typeName = "Boolean";
                break;
            }

            _writer.Write(typeName);
            _writer.Write(")");
            return(0);
        }
Example #2
0
 protected void addCast(InstanceOfExpression cast)
 {
     if (this.castCounts.length() > 0)
     {
         cast.implicitCasts = new List <CastExpression>();
         this.casts.push(cast);
         var last = this.castCounts.length() - 1;
         this.castCounts.set(last, this.castCounts.get(last) + 1);
     }
 }
        public object VisitInstanceOf(InstanceOfExpression node)
        {
            var value = node.Target.Accept(this);

            if (value is null && node.TypeSyntax is RefTypeSyntax refType && refType.Name.Equals("null"))
            {
                return(Boolean.True);
            }
            var type      = node.TypeSyntax.ResolveType(TypeContext);
            var valueType = value.GetType();

            if (TypeUtils.AreReferenceAssignable(type, valueType))
            {
                return(Boolean.True);
            }
            return(Boolean.False);
        }
Example #4
0
 public Expression VisitInstanceOf(InstanceOfExpression node)
 {
     node.Target.Accept(this);
     return(node);
 }
Example #5
0
 public override void Visit(InstanceOfExpression node)
 {
     Visit((BinaryExpression)node);
 }
Example #6
0
 public override void Visit(InstanceOfExpression node)
 {
     unfinishedClone = new InstanceOfExpression(GetCloneOf(node.Left), GetCloneOf(node.Right));
     base.Visit(node);
 }
Example #7
0
 public override void Visit(InstanceOfExpression node)
 {
     UpdateType(node, TypeCalculator.GetType(node));
 }
Example #8
0
 public override void Visit(InstanceOfExpression node)
 {
     AssignToImplicitReturn(node);
 }