Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions flang-rt/include/flang-rt/runtime/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ enum class Access { Sequential, Direct, Stream };
// established in an OPEN statement.
struct ConnectionAttributes {
Access access{Access::Sequential}; // ACCESS='SEQUENTIAL', 'DIRECT', 'STREAM'
Fortran::common::optional<bool> isUnformatted; // FORM='UNFORMATTED' if true
common::optional<bool> isUnformatted; // FORM='UNFORMATTED' if true
bool isUTF8{false}; // ENCODING='UTF-8'
unsigned char internalIoCharKind{0}; // 0->external, 1/2/4->internal
Fortran::common::optional<std::int64_t> openRecl; // RECL= on OPEN
common::optional<std::int64_t> openRecl; // RECL= on OPEN

RT_API_ATTRS bool IsRecordFile() const {
// Formatted stream files are viewed as having records, at least on input
Expand Down Expand Up @@ -82,15 +82,14 @@ struct ConnectionState : public ConnectionAttributes {
unterminatedRecord = false;
}

RT_API_ATTRS Fortran::common::optional<std::int64_t>
EffectiveRecordLength() const {
RT_API_ATTRS common::optional<std::int64_t> EffectiveRecordLength() const {
// When an input record is longer than an explicit RECL= from OPEN
// it is effectively truncated on input.
return openRecl && recordLength && *openRecl < *recordLength ? openRecl
: recordLength;
}

Fortran::common::optional<std::int64_t> recordLength;
common::optional<std::int64_t> recordLength;

std::int64_t currentRecordNumber{1}; // 1 is first

Expand All @@ -106,12 +105,11 @@ struct ConnectionState : public ConnectionAttributes {
std::int64_t furthestPositionInRecord{0}; // max(position+bytes)

// Set at end of non-advancing I/O data transfer
Fortran::common::optional<std::int64_t>
leftTabLimit; // offset in current record
common::optional<std::int64_t> leftTabLimit; // offset in current record

// currentRecordNumber value captured after ENDFILE/REWIND/BACKSPACE statement
// or an end-of-file READ condition on a sequential access file
Fortran::common::optional<std::int64_t> endfileRecordNumber;
common::optional<std::int64_t> endfileRecordNumber;

// Mutable modes set at OPEN() that can be overridden in READ/WRITE & FORMAT
MutableModes modes; // BLANK=, DECIMAL=, SIGN=, ROUND=, PAD=, DELIM=, kP
Expand Down
2 changes: 1 addition & 1 deletion flang-rt/include/flang-rt/runtime/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RT_OFFLOAD_VAR_GROUP_END
// External unformatted I/O data conversions
enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap };

RT_API_ATTRS Fortran::common::optional<Convert> GetConvertFromString(
RT_API_ATTRS common::optional<Convert> GetConvertFromString(
const char *, std::size_t);

struct ExecutionEnvironment {
Expand Down
9 changes: 4 additions & 5 deletions flang-rt/include/flang-rt/runtime/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ class OpenFile {
void set_mayAsynchronous(bool yes) { mayAsynchronous_ = yes; }
bool isTerminal() const { return isTerminal_; }
bool isWindowsTextFile() const { return isWindowsTextFile_; }
Fortran::common::optional<FileOffset> knownSize() const { return knownSize_; }
common::optional<FileOffset> knownSize() const { return knownSize_; }

bool IsConnected() const { return fd_ >= 0; }
void Open(OpenStatus, Fortran::common::optional<Action>, Position,
IoErrorHandler &);
void Open(OpenStatus, common::optional<Action>, Position, IoErrorHandler &);
void Predefine(int fd);
void Close(CloseStatus, IoErrorHandler &);

Expand Down Expand Up @@ -95,10 +94,10 @@ class OpenFile {
bool mayWrite_{false};
bool mayPosition_{false};
bool mayAsynchronous_{false};
Fortran::common::optional<Position>
common::optional<Position>
openPosition_; // from Open(); reset after positioning
FileOffset position_{0};
Fortran::common::optional<FileOffset> knownSize_;
common::optional<FileOffset> knownSize_;
bool isTerminal_{false};
bool isWindowsTextFile_{false}; // expands LF to CR+LF on write

Expand Down
14 changes: 7 additions & 7 deletions flang-rt/include/flang-rt/runtime/format-implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
}
}
while (true) {
Fortran::common::optional<int> repeat;
common::optional<int> repeat;
bool unlimited{false};
auto maybeReversionPoint{offset_};
CharType ch{GetNextChar(context)};
Expand Down Expand Up @@ -498,8 +498,8 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(

// Returns the next data edit descriptor
template <typename CONTEXT>
RT_API_ATTRS Fortran::common::optional<DataEdit>
FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
RT_API_ATTRS common::optional<DataEdit> FormatControl<CONTEXT>::GetNextDataEdit(
Context &context, int maxRepeat) {
int repeat{CueUpNextDataEdit(context)};
auto start{offset_};
DataEdit edit;
Expand Down Expand Up @@ -530,7 +530,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
}
if (edit.ioTypeChars >= edit.maxIoTypeChars) {
ReportBadFormat(context, "Excessive DT'iotype' in FORMAT", start);
return Fortran::common::nullopt;
return common::nullopt;
}
edit.ioType[edit.ioTypeChars++] = ch;
if (ch == quote) {
Expand All @@ -539,7 +539,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
}
if (!ok) {
ReportBadFormat(context, "Unclosed DT'iotype' in FORMAT", start);
return Fortran::common::nullopt;
return common::nullopt;
}
}
if (PeekNext() == '(') {
Expand All @@ -554,7 +554,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
}
if (edit.vListEntries >= edit.maxVListEntries) {
ReportBadFormat(context, "Excessive DT(v_list) in FORMAT", start);
return Fortran::common::nullopt;
return common::nullopt;
}
edit.vList[edit.vListEntries++] = n;
auto ch{static_cast<char>(GetNextChar(context))};
Expand All @@ -565,7 +565,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
}
if (!ok) {
ReportBadFormat(context, "Unclosed DT(v_list) in FORMAT", start);
return Fortran::common::nullopt;
return common::nullopt;
}
}
} else { // not DT'iotype'
Expand Down
8 changes: 4 additions & 4 deletions flang-rt/include/flang-rt/runtime/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ struct DataEdit {
}

char variation{'\0'}; // N, S, or X for EN, ES, EX; G/l for original G/list
Fortran::common::optional<int> width; // the 'w' field; optional for A
Fortran::common::optional<int> digits; // the 'm' or 'd' field
Fortran::common::optional<int> expoDigits; // 'Ee' field
common::optional<int> width; // the 'w' field; optional for A
common::optional<int> digits; // the 'm' or 'd' field
common::optional<int> expoDigits; // 'Ee' field
MutableModes modes;
int repeat{1};

Expand Down Expand Up @@ -116,7 +116,7 @@ template <typename CONTEXT> class FormatControl {
// Extracts the next data edit descriptor, handling control edit descriptors
// along the way. If maxRepeat==0, this is a peek at the next data edit
// descriptor.
RT_API_ATTRS Fortran::common::optional<DataEdit> GetNextDataEdit(
RT_API_ATTRS common::optional<DataEdit> GetNextDataEdit(
Context &, int maxRepeat = 1);

// Emit any remaining character literals after the last data item (on output)
Expand Down
Loading
Loading