Skip to content

Commit

Permalink
Trigger build
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusluizfb committed Jun 13, 2021
1 parent 960c69a commit b7d7a04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/main/rascal/lang/jimple/toolkit/ssa/Helpers.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lang::jimple::toolkit::FlowGraph;
import lang::jimple::core::Syntax;

public Variable returnStmtVariable(Node graphNode) {
stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];

switch(variableArg) {
Expand All @@ -22,6 +22,18 @@ public Statement returnStmtNodeBody(Node stmtNode) {
}
}

public Variable returnPhiFunctionLeftHandSide(Expression phiFunctionExpr) {
switch(phiFunctionExpr) {
case phiFunction(leftHandSide, _): return leftHandSide;
}
}

public list[Variable] returnPhiFunctionRightHandSide(Expression phiFunctionExpr) {
switch(phiFunctionExpr) {
case phiFunction(_, rightHandSide): return rightHandSide;
}
}

public Variable returnLeftHandSideVariable(Node stmtNode) {
switch(stmtNode) {
case stmtNode(assign(leftHandSide, _)): return leftHandSide;
Expand Down
19 changes: 11 additions & 8 deletions src/main/rascal/lang/jimple/toolkit/ssa/VariableRenaming.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,12 @@ public bool isSkipableStatement(stmtArgument) {
}

public Node replacePhiFunctionVersion(map[Node, list[Node]] blockTree, Node variableNode) {
assignStatement = returnStmtNodeBody(variableNode);
assign(assignVariable, assignPhiFunction) = assignStatement;
phiFunction(phiFunctionVariable, variableVersionList) = assignPhiFunction;
assignVariable = returnLeftHandSideVariable(variableNode);
assignPhiFunction = returnRightHandSideExpression(variableNode);

phiFunctionVariable = returnPhiFunctionLeftHandSide(assignPhiFunction);
variableVersionList = returnPhiFunctionRightHandSide(assignPhiFunction);

variableName = phiFunctionVariable[0];
Immediate localVariableImmediate = local(variableName);
versionIndex = getVariableVersionStacked(localVariableImmediate);
Expand Down Expand Up @@ -274,7 +277,7 @@ public String returnCurrentVersionName(Immediate immediate) {
public bool isRenamed(Node assignNode) {
if(ignoreNode(assignNode)) return false;

stmtNode(assignStmt) = assignNode;
assignStmt = returnStmtNodeBody(assignNode);

switch(assignNode) {
case stmtNode(assign(localVariable(name), _)) : return contains(name, "version");
Expand Down Expand Up @@ -310,7 +313,7 @@ public bool ignoreNode(Node variableNode) {
public bool isOrdinaryAssignment(Node variableNode) {
if(ignoreNode(variableNode)) return false;

stmtNode(statement) = variableNode;
statement = returnStmtNodeBody(variableNode);
switch(statement) {
case assign(_, _): return true;
default: return false;
Expand All @@ -320,7 +323,7 @@ public bool isOrdinaryAssignment(Node variableNode) {
public bool isPhiFunctionAssigment(Node variableNode) {
if(ignoreNode(variableNode)) return false;

stmtNode(assignStatement) = variableNode;
assignStatement = returnStmtNodeBody(variableNode);
if(size(assignStatement[..]) != 2) return false;

possiblePhiFunction = assignStatement[1];
Expand All @@ -334,7 +337,7 @@ public bool isPhiFunctionAssigment(Node variableNode) {
public bool isVariable(Node graphNode) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];
typeOfVariableArg = typeOf(variableArg);

Expand All @@ -346,7 +349,7 @@ public bool isVariable(Node graphNode) {
public bool isSameVariable(Node graphNode, Variable variable) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];
typeOfVariableArg = typeOf(variableArg);

Expand Down

0 comments on commit b7d7a04

Please sign in to comment.