public boolean isUsedWithKeywordInCallStmt(ASTSubroutineParNode parameterNode) { for (ASTCallStmtNode callStmtNode : getCallSites()) for (ASTSubroutineArgNode argument : callStmtNode.getArgList()) if (argument.getName() != null && parameterNode.getVariableName() != null) { String argumentName = PhotranVPG.canonicalizeIdentifier(argument.getName().getText()); String parameterName = PhotranVPG.canonicalizeIdentifier(parameterNode.getVariableName().getText()); if (argumentName.equals(parameterName)) return true; } return false; }
private ASTSubroutineArgNode getActualArgFromCallStmt( ASTCallStmtNode callStmt, Token desiredParName, int desiredParIndex) { for (int i = 0; i < callStmt.getArgList().size(); i++) { ASTSubroutineArgNode argument = callStmt.getArgList().get(i); if (argument.getName() == null || desiredParName == null) { if (i == desiredParIndex) return argument; } else { String argumentName = PhotranVPG.canonicalizeIdentifier(argument.getName().getText()); String parameterName = PhotranVPG.canonicalizeIdentifier(desiredParName.getText()); if (argumentName.equals(parameterName)) return argument; } } return null; }
private void permuteCallSites() { for (ASTCallStmtNode callStmt : getCallSites()) { int m = 0; if (callStmt.getArgList() != null) { m = callStmt.getArgList().size(); } // 2a boolean K = false; // 2b ArrayList<ASTSubroutineArgNode> L_prime = new ArrayList<ASTSubroutineArgNode>(); // step 2c for (int i : sigma) { ASTSubroutineParNode desiredPar = oldParameterList.get(i); ASTSubroutineArgNode A_i = getActualArgFromCallStmt(callStmt, desiredPar.getVariableName(), i); if (i > m) K = true; // 2cii if (A_i != null) { // 2ciiA if (A_i.getName() != null) K = true; // 2ciiB if (K == false || A_i.getName() != null) L_prime.add(A_i); // 2ciiC if (K == true && A_i.getName() == null) { A_i.setName(new Token(Terminal.T_IDENT, desiredPar.getVariableName().getText())); L_prime.add(A_i); } } } ASTSeparatedListNode<ASTSubroutineArgNode> newArgList = new ASTSeparatedListNode<ASTSubroutineArgNode>( new Token(Terminal.T_COMMA, ","), L_prime); // $NON-NLS-1$ callStmt.setArgList(newArgList); } }