Skip to content

Commit

Permalink
Transformation to the DIST_CALL macro, used for dispatching local and…
Browse files Browse the repository at this point in the history
… remote calls
  • Loading branch information
miranha committed Oct 12, 2016
1 parent 189f904 commit 225a9e5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Expand Up @@ -21,6 +21,7 @@
import org.overture.codegen.trans.patterns.PatternVarPrefixes;
import org.overture.codegen.vdm2c.CGen;
import org.overture.codegen.vdm2c.VarPrefixManager;
import org.overture.codegen.vdm2c.distribution.transformations.CallFuncMacroExpTrans;
import org.overture.codegen.vdm2c.distribution.transformations.DistTransTest;

public class CDistTransSeries
Expand Down Expand Up @@ -73,6 +74,8 @@ public List<DepthFirstAnalysisAdaptor> consAnalyses()
//transformations.add(new CallObjStmTrans(info));

transformations.add(new DistTransTest(transAssistant));
transformations.add(new CallFuncMacroExpTrans(transAssistant));


return transformations;
}
Expand Down
@@ -0,0 +1,51 @@
package org.overture.codegen.vdm2c.distribution.transformations;
import java.util.LinkedList;

import org.overture.cgc.extast.analysis.DepthFirstAnalysisCAdaptor;
import org.overture.codegen.ir.SExpIR;
import org.overture.codegen.ir.analysis.AnalysisException;
import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
import org.overture.codegen.ir.expressions.AIntLiteralExpIR;
import org.overture.codegen.trans.assistants.TransAssistantIR;
import org.overture.codegen.vdm2c.extast.expressions.AMacroApplyExpIR;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CallFuncMacroExpTrans extends DepthFirstAnalysisCAdaptor
{
final static Logger logger = LoggerFactory.getLogger(CallFuncMacroExpTrans.class);
public TransAssistantIR assist;

final static String retPrefix = "embeding_";

public CallFuncMacroExpTrans(TransAssistantIR assist)
{
this.assist = assist;
}

@Override
public void caseAMacroApplyExpIR(AMacroApplyExpIR node)
throws AnalysisException
{

if(node.getRoot() instanceof AIdentifierVarExpIR){
AIdentifierVarExpIR id_exp = (AIdentifierVarExpIR) node.getRoot();

if(id_exp.getName().equals("CALL_FUNC")){

int args_len = node.getArgs().size() - 4;

AIntLiteralExpIR a = new AIntLiteralExpIR();
a.setValue((long) args_len);

// Add number of function arguments to second last position
node.getArgs().add(node.getArgs().size() - 1, a);

AIdentifierVarExpIR id_class = (AIdentifierVarExpIR) node.getArgs().get(0);
id_exp.setName("DIST_CALL" + id_class.getName());
}
}
}

}

0 comments on commit 225a9e5

Please sign in to comment.