
This commit introduces support for running clang-repl and executing C++ code interactively inside a Javascript engine using WebAssembly when built with Emscripten. This is achieved by producing WASM "shared libraries" that can be loaded by the Emscripten runtime using dlopen() More discussion is available in https://reviews.llvm.org/D158140 Co-authored-by: Anubhab Ghosh <anubhabghosh.me@gmail.com>
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
//===------------------ Wasm.h - Wasm Interpreter ---------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements interpreter support for code execution in WebAssembly.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_LIB_INTERPRETER_WASM_H
|
|
#define LLVM_CLANG_LIB_INTERPRETER_WASM_H
|
|
|
|
#ifndef __EMSCRIPTEN__
|
|
#error "This requires emscripten."
|
|
#endif // __EMSCRIPTEN__
|
|
|
|
#include "IncrementalExecutor.h"
|
|
|
|
namespace clang {
|
|
|
|
class WasmIncrementalExecutor : public IncrementalExecutor {
|
|
public:
|
|
WasmIncrementalExecutor(llvm::orc::ThreadSafeContext &TSC);
|
|
|
|
llvm::Error addModule(PartialTranslationUnit &PTU) override;
|
|
llvm::Error removeModule(PartialTranslationUnit &PTU) override;
|
|
llvm::Error runCtors() const override;
|
|
|
|
~WasmIncrementalExecutor() override;
|
|
};
|
|
|
|
} // namespace clang
|
|
|
|
#endif // LLVM_CLANG_LIB_INTERPRETER_WASM_H
|