Skip to content

Commit

Permalink
Add type parameters to PO launch functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Dec 2, 2023
1 parent 9d21b92 commit 7ed4240
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions vdmj/src/main/java/com/fujitsu/vdmj/pog/ProofObligation.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
import com.fujitsu.vdmj.po.types.POPatternListTypePair;
import com.fujitsu.vdmj.runtime.Context;
import com.fujitsu.vdmj.tc.expressions.TCExpression;
import com.fujitsu.vdmj.tc.types.TCParameterType;
import com.fujitsu.vdmj.tc.types.TCType;
import com.fujitsu.vdmj.tc.types.TCTypeList;
import com.fujitsu.vdmj.values.ParameterValue;

abstract public class ProofObligation implements Comparable<ProofObligation>
{
Expand Down Expand Up @@ -259,10 +261,15 @@ private String launchExplicitFunction(POExplicitFunctionDefinition efd, Context
StringBuilder callString = new StringBuilder(efd.name.getName());
PORemoveIgnoresVisitor.init();

if (efd.typeParams != null)
{
callString.append(addTypeParams(efd.typeParams, ctxt));
}

for (POPatternList pl: efd.paramPatternList)
{
callString.append("(");
String sep = "";
callString.append("(");

for (POPattern p: pl)
{
Expand All @@ -283,14 +290,20 @@ private String launchExplicitFunction(POExplicitFunctionDefinition efd, Context

return callString.toString();
}

private String launchImplicitFunction(POImplicitFunctionDefinition ifd, Context ctxt)
{
StringBuilder callString = new StringBuilder(ifd.name.getName());
callString.append("(");
String sep = "";
PORemoveIgnoresVisitor.init();

if (ifd.typeParams != null)
{
callString.append(addTypeParams(ifd.typeParams, ctxt));
}

String sep = "";
callString.append("(");

for (POPatternListTypePair pl: ifd.parameterPatterns)
{
for (POPattern p: pl.patterns)
Expand All @@ -313,6 +326,25 @@ private String launchImplicitFunction(POImplicitFunctionDefinition ifd, Context
return callString.toString();
}

private String addTypeParams(TCTypeList params, Context ctxt)
{
StringBuilder callString = new StringBuilder();
String sep = "";
callString.append("[");

for (TCType p: params)
{
TCParameterType param = (TCParameterType)p;
ParameterValue inst = (ParameterValue) ctxt.get(param.name);
callString.append(sep);
callString.append(inst.type);
sep = ", ";
}

callString.append("]");
return callString.toString();
}

private String paramMatch(POPattern p, Context ctxt)
{
POGetMatchingConstantVisitor visitor = new POGetMatchingConstantVisitor();
Expand Down

0 comments on commit 7ed4240

Please sign in to comment.