Exemplo n.º 1
0
        public virtual bool VisitCastExpr(CastExpr stmt)
        {
            if (!VisitExpr(stmt))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validate a cast expression.
        /// </summary>
        /// <param name="cexp">
        ///            is the expression. </param>
        /// <returns> null. </returns>
        public virtual object visit(CastExpr cexp)
        {
            printBinExpr("CAST", cexp);

            SingleType st   = (SingleType)cexp.right();
            QName      type = st.type();

            [email protected] qName = type.asQName();
            Function f = _sc.resolveFunction(qName, 1);

            if (f == null)
            {
                reportError(new StaticFunctNameError("Type does not exist: " + type.ToString()));
            }
            cexp.set_function(f);
            _resolvedFunctions.Add(qName);

            return(null);
        }
Exemplo n.º 3
0
 public bool VisitCastExpr(CastExpr stmt)
 {
     throw new NotImplementedException();
 }
 void IVisitor.VisitBefore(CastExpr expr)
 {
     this.ParentExists(expr);
 }
 void IVisitor.VisitAfter(CastExpr expr)
 {
     this.ParentExists(expr);
 }
Exemplo n.º 6
0
    public override Null Visit(CastExpr node)
    {
        context = null;
        node.computedType = new ErrorType();
        node.target.Accept(this);

        // Check that the cast is valid
        if (!node.target.computedType.IsInstantiatableType()) {
            log.ErrorNotUseableType(node.location, node.target.computedType);
        } else {
            Type targetType = node.target.computedType.InstanceType();
            context = new Context { targetType = targetType };
            node.value.Accept(this);
            if (!IsValidCast(node.value.computedType, targetType)) {
                log.ErrorInvalidCast(node.value.location, node.value.computedType, targetType);
            } else {
                node.computedType = targetType;
            }
        }

        return null;
    }
Exemplo n.º 7
0
 /// <param name="cexp">
 ///            is the cast expression. </param>
 /// <returns> cexp. </returns>
 public virtual object visit(CastExpr cexp)
 {
     cexp.left().accept(this);
     cexp.right().accept(this);
     return(null);
 }
Exemplo n.º 8
0
    public override Null Visit(CastExpr node)
    {
        base.Visit(node);

        // Check for provably invalid dereferences of local variables
        if (node.value is IdentExpr) {
            IdentExpr identExpr = (IdentExpr)node.value;
            if (identExpr.symbol.def.info.funcDef != null) {
                FlowNode flowNode = builder.nodeMap[node];
                if (flowNode.knowledge != null) {
                    IsNull isNull = flowNode.knowledge.isNull.GetOrDefault(identExpr.symbol, IsNull.Maybe);
                    if (isNull == IsNull.Yes) {
                        log.WarningNullDereference(node.location, identExpr.name);
                    } else if (isNull == IsNull.Maybe) {
                        log.WarningNullableDereference(node.location, identExpr.name);
                    }
                    return null;
                }
            }

            // Be conservative and warn about all other dereferences
            if ((node.value.computedType is NullableType) && !(node.computedType is NullableType)) {
                log.WarningNullableDereference(node.location, identExpr.name);
                return null;
            }
        }

        // Be conservative and warn about all other dereferences
        if ((node.value.computedType is NullableType) && !(node.computedType is NullableType)) {
            log.WarningNullableDereference(node.location, null);
        }

        return null;
    }
Exemplo n.º 9
0
    public override Null Visit(CastExpr node)
    {
        base.Visit(node);

        // Remember the current flow node for later
        nodeMap.Add(node, next.GetTrue());

        return null;
    }
Exemplo n.º 10
0
 /// <param name="cexp">
 ///            is the cast expression. </param>
 /// <returns> cexp. </returns>
 public virtual object visit(CastExpr cexp)
 {
     printBinExpr("CAST", cexp);
     return(cexp);
 }