37 lines · cpp
1//===-- lib/runtime/connection.cpp ------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "flang-rt/runtime/connection.h"10#include "flang-rt/runtime/environment.h"11#include "flang-rt/runtime/io-stmt.h"12 13namespace Fortran::runtime::io {14RT_OFFLOAD_API_GROUP_BEGIN15 16SavedPosition::SavedPosition(IoStatementState &io) : io_{io} {17 ConnectionState &conn{io_.GetConnectionState()};18 saved_ = conn;19 conn.pinnedFrame = true;20}21 22SavedPosition::~SavedPosition() {23 if (!cancelled_) {24 ConnectionState &conn{io_.GetConnectionState()};25 while (conn.currentRecordNumber > saved_.currentRecordNumber) {26 io_.BackspaceRecord();27 }28 conn.leftTabLimit = saved_.leftTabLimit;29 conn.furthestPositionInRecord = saved_.furthestPositionInRecord;30 conn.positionInRecord = saved_.positionInRecord;31 conn.pinnedFrame = saved_.pinnedFrame;32 }33}34 35RT_OFFLOAD_API_GROUP_END36} // namespace Fortran::runtime::io37