Search in sources :

Example 1 with InitializerListExpression

use of de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression in project cpg by Fraunhofer-AISEC.

the class VariableDeclaration method typeChanged.

@Override
public void typeChanged(HasType src, HasType root, Type oldType) {
    if (!TypeManager.isTypeSystemActive()) {
        return;
    }
    if (!TypeManager.getInstance().isUnknown(this.type) && src.getPropagationType().equals(oldType)) {
        return;
    }
    Type previous = this.type;
    Type newType;
    if (src == initializer && initializer instanceof InitializerListExpression) {
        // can be ignored once we have a type
        if (isArray) {
            newType = src.getType();
        } else if (!TypeManager.getInstance().isUnknown(this.type)) {
            return;
        } else {
            newType = src.getType().dereference();
        }
    } else {
        newType = src.getPropagationType();
    }
    setType(newType, root);
    if (!previous.equals(this.type)) {
        this.type.setTypeOrigin(Type.Origin.DATAFLOW);
    }
}
Also used : Type(de.fraunhofer.aisec.cpg.graph.types.Type) HasType(de.fraunhofer.aisec.cpg.graph.HasType) InitializerListExpression(de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression)

Example 2 with InitializerListExpression

use of de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression in project cpg by Fraunhofer-AISEC.

the class FieldDeclaration method typeChanged.

@Override
public void typeChanged(HasType src, Collection<HasType> root, Type oldType) {
    if (!TypeManager.isTypeSystemActive()) {
        return;
    }
    if (!TypeManager.getInstance().isUnknown(this.type) && src.getPropagationType().equals(oldType)) {
        return;
    }
    Type previous = this.type;
    Type newType;
    if (src == initializer && initializer instanceof InitializerListExpression) {
        // can be ignored once we have a type
        if (isArray) {
            newType = src.getType();
        } else if (!TypeManager.getInstance().isUnknown(this.type)) {
            return;
        } else {
            newType = src.getType().dereference();
        }
    } else {
        newType = src.getPropagationType();
    }
    setType(newType, root);
    if (!previous.equals(this.type)) {
        this.type.setTypeOrigin(Type.Origin.DATAFLOW);
    }
}
Also used : Type(de.fraunhofer.aisec.cpg.graph.types.Type) HasType(de.fraunhofer.aisec.cpg.graph.HasType) InitializerListExpression(de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression)

Example 3 with InitializerListExpression

use of de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression in project cpg by Fraunhofer-AISEC.

the class VariableDeclaration method typeChanged.

@Override
public void typeChanged(HasType src, Collection<HasType> root, Type oldType) {
    if (!TypeManager.isTypeSystemActive()) {
        return;
    }
    if (!TypeManager.getInstance().isUnknown(this.type) && src.getPropagationType().equals(oldType)) {
        return;
    }
    Type previous = this.type;
    Type newType;
    if (src == initializer && initializer instanceof InitializerListExpression) {
        // can be ignored once we have a type
        if (isArray) {
            newType = src.getType();
        } else if (!TypeManager.getInstance().isUnknown(this.type)) {
            return;
        } else {
            newType = src.getType().dereference();
        }
    } else {
        newType = src.getPropagationType();
    }
    setType(newType, root);
    if (!previous.equals(this.type)) {
        this.type.setTypeOrigin(Type.Origin.DATAFLOW);
    }
}
Also used : Type(de.fraunhofer.aisec.cpg.graph.types.Type) HasType(de.fraunhofer.aisec.cpg.graph.HasType) InitializerListExpression(de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression)

Example 4 with InitializerListExpression

use of de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression in project cpg by Fraunhofer-AISEC.

the class FieldDeclaration method typeChanged.

@Override
public void typeChanged(HasType src, HasType root, Type oldType) {
    if (!TypeManager.isTypeSystemActive()) {
        return;
    }
    if (!TypeManager.getInstance().isUnknown(this.type) && src.getPropagationType().equals(oldType)) {
        return;
    }
    Type previous = this.type;
    Type newType;
    if (src == initializer && initializer instanceof InitializerListExpression) {
        // can be ignored once we have a type
        if (isArray) {
            newType = src.getType();
        } else if (!TypeManager.getInstance().isUnknown(this.type)) {
            return;
        } else {
            newType = src.getType().dereference();
        }
    } else {
        newType = src.getPropagationType();
    }
    setType(newType, root);
    if (!previous.equals(this.type)) {
        this.type.setTypeOrigin(Type.Origin.DATAFLOW);
    }
}
Also used : Type(de.fraunhofer.aisec.cpg.graph.types.Type) HasType(de.fraunhofer.aisec.cpg.graph.HasType) InitializerListExpression(de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression)

Aggregations

HasType (de.fraunhofer.aisec.cpg.graph.HasType)4 InitializerListExpression (de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression)4 Type (de.fraunhofer.aisec.cpg.graph.types.Type)4