@SuppressWarnings("unchecked") @Override public SExpIR caseAApplyObjectDesignatorIR(AApplyObjectDesignatorIR node) throws AnalysisException { SObjectDesignatorIR object = node.getObject(); SourceNode sourceNode = node.getSourceNode(); LinkedList<SExpIR> args = node.getArgs(); SExpIR root = object.apply(this); STypeIR rootType = root.getType(); STypeIR applyType = null; if (rootType instanceof SSeqTypeIR) { applyType = ((SSeqTypeIR) rootType).getSeqOf(); } else if (rootType instanceof SMapTypeIR) { applyType = ((SMapTypeIR) rootType).getTo(); } else if (rootType instanceof AMethodTypeIR) { applyType = ((AMethodTypeIR) rootType).getResult(); } applyType = applyType.clone(); AApplyExpIR applyExp = new AApplyExpIR(); applyExp.setArgs((List<? extends SExpIR>) args.clone()); applyExp.setRoot(root); applyExp.setType(applyType); applyExp.setSourceNode(sourceNode); return applyExp; }
@Override public void caseAFieldExpIR(AFieldExpIR node) throws AnalysisException { node.getObject().apply(this); if (node.getObject().getType() instanceof ARecordTypeIR && !(node.parent() instanceof AApplyExpIR)) { AMethodTypeIR getterType = new AMethodTypeIR(); getterType.setResult(node.getType().clone()); AFieldExpIR getterField = node.clone(); getterField.setType(getterType); AApplyExpIR getCall = new AApplyExpIR(); getCall.setRoot(getterField); getCall.setType(node.getType().clone()); getCall.setSourceNode(node.getSourceNode()); getterField.setMemberName(consGetCallName(node.getMemberName())); /** * The getters added to the record classes do not copy object references representing values. Therefore we * need to take it into account when we do the field read call */ if (cloneFieldRead(node)) { getCall = makeCopy(getCall); } jmlGen.getJavaGen().getTransAssistant().replaceNodeWith(node, getCall); } }
apply.setType(type.clone()); apply.setRoot(field); apply.setSourceNode(callStmIR.getSourceNode());