Grab whatever ProgramStart has stored in executionEnvironment.argc and subtract 1 (based on the assumption that ProgramStart is called with a C-style argc that counts the command name as an argument). Spoiler alert: The tests will evolve into fixtures when we implement GET_COMMAND_ARGUMENT etc. Differential Revision: https://reviews.llvm.org/D109048
22 lines
716 B
C++
22 lines
716 B
C++
//===-- runtime/command.cpp -----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "command.h"
|
|
#include "environment.h"
|
|
|
|
namespace Fortran::runtime {
|
|
CppTypeFor<TypeCategory::Integer, 4> RTNAME(ArgumentCount)() {
|
|
int argc{executionEnvironment.argc};
|
|
if (argc > 1) {
|
|
// C counts the command name as one of the arguments, but Fortran doesn't.
|
|
return argc - 1;
|
|
}
|
|
return 0;
|
|
}
|
|
} // namespace Fortran::runtime
|