Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transformation to the DIST_CALL macro, used for dispatching local and…
… remote calls
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...n/java/org/overture/codegen/vdm2c/distribution/transformations/CallFuncMacroExpTrans.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|