Can I convert a FieldValue to a DomainValue in OPAL?

35 views Asked by At

I am writing a static analysis using the OPAL framework.

Therefore, I invoke an abstract interpretation of a method, where I have upper type bounds for the passed parameters as FieldTypes.

It looks like this:

BaseAI.perform(classFile, caller, domain)(parameters)

Where parameters is an IndexedSeq[FieldType].

This results in the following type error:

type mismatch; found : scala.collection.immutable.IndexedSeq[org.opalj.br.FieldType] required: Option[scala.collection.IndexedSeq[domain.DomainValue]] (which expands to) Option[scala.collection.IndexedSeq[domain.Value]]

Is there any possibility to convert my FieldTypes to DomainValues?

Can I use

domain.ClassValue(origin, identifiedFieldType)

to convert it, even if the type is e.g. an int? (since int is not a class)

If yes, is there a method, which computes the origin index for method parameters?

1

There are 1 answers

0
Delors On BEST ANSWER

Part one of the question:

You can use:

domain.TypedValue(origin, parameterType) 

In this case parameterType can be "any type".

Part two of the question:

The following function defined by the package object org.opalj.ai can be used compute the correct value index.

def parameterToValueIndex(
    isStaticMethod: Boolean,
    descriptor:     MethodDescriptor,
    parameterIndex: Int
): Int = {