Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #4
0
 public Expression VisitInstanceOf(InstanceOfExpression node)
 {
     node.Target.Accept(this);
     return(node);
 }
Beispiel #5
0
 public override void Visit(InstanceOfExpression node)
 {
     Visit((BinaryExpression)node);
 }
Beispiel #6
0
 public override void Visit(InstanceOfExpression node)
 {
     unfinishedClone = new InstanceOfExpression(GetCloneOf(node.Left), GetCloneOf(node.Right));
     base.Visit(node);
 }
Beispiel #7
0
 public override void Visit(InstanceOfExpression node)
 {
     UpdateType(node, TypeCalculator.GetType(node));
 }
Beispiel #8
0
 public override void Visit(InstanceOfExpression node)
 {
     AssignToImplicitReturn(node);
 }