Files
swift-mirror/include/swift/Immediate/Immediate.h
Ben Langmuir 8a824d70a0 [immediate] Load Foundation early enough for bridging
Foundation needs to be loaded early in the process for Swift's runtime
to properly initialize bridging support; otherwise it may cause issues
like unrecognized selectors. When scripting, load Foundation early in
performFrontend before any swift code runs.

rdar://129528115
2024-08-01 15:02:13 -07:00

54 lines
1.9 KiB
C++

//===--- Immediate.h - Entry point for swift immediate mode -----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This is the entry point to the swift immediate mode, which takes a
// source file, and runs it immediately using the JIT.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_IMMEDIATE_IMMEDIATE_H
#define SWIFT_IMMEDIATE_IMMEDIATE_H
#include <memory>
#include <string>
#include <vector>
namespace swift {
class CompilerInstance;
class DiagnosticEngine;
class IRGenOptions;
class SILOptions;
class SILModule;
// Using LLVM containers to store command-line arguments turns out
// to be a lose, because LLVM's execution engine demands this vector
// type. We can flip the typedef if/when the LLVM interface
// supports LLVM containers.
using ProcessCmdLine = std::vector<std::string>;
/// Attempt to run the script identified by the given compiler instance.
///
/// \return the result returned from main(), if execution succeeded
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
std::unique_ptr<SILModule> &&SM);
int RunImmediatelyFromAST(CompilerInstance &CI);
/// On platforms that support ObjC bridging from the Foundation framework,
/// ensure that Foundation is loaded early enough. Otherwise does nothing.
void loadFoundationIfNeeded(DiagnosticEngine &Diags);
} // end namespace swift
#endif // SWIFT_IMMEDIATE_IMMEDIATE_H