Finish the review of SereneContext

This commit is contained in:
Sameer Rahmani 2022-03-02 18:26:39 +00:00
parent 644cf11c89
commit 6f4c6b3398
4 changed files with 16 additions and 6 deletions

View File

@ -124,6 +124,10 @@ functions and detect hot functions similar to how javascript jits do it
and recompile those functions with more optimization passes
* TODOs
** TODO In =SereneContext::getLatestJITDylib= function, make sure that the JITDylib is still valid
Make sure that the returning Dylib still exists in the JIT
by calling =jit->engine->getJITDylibByName(dylib_name);=
** TODO Provide the CLI arguments to pass the =createTargetMachine=.
We need a way to tweak the target machine object. It's better to provide cli tools
to do so.

View File

@ -186,8 +186,8 @@ public:
NSPtr makeNamespace(llvm::StringRef name,
llvm::Optional<llvm::StringRef> filename);
/// Read a namespace with the given \p name and returne a share pointer
/// to the name or an Error tree.
/// Read a namespace with the given \p name and returns a share pointer
/// to the name or an Error.
///
/// It just `read` the namespace by parsing it and running the semantic
/// analyzer on it.

View File

@ -25,6 +25,10 @@
* any given time. For example via iteration of a REPL
* - `environments` vector is the owner of all the semantic envs
* - The first env in the `environments` is the root env.
*
* How to create a namespace ?
* The official way to create a namespace object is to use the `SereneContext`
* object and call `readNamespace` or `importNamespace`.
*/
// TODO: Add a mechanism to figure out whether a namespace has changed or not
@ -109,13 +113,13 @@ private:
static NSPtr make(SereneContext &ctx, llvm::StringRef name,
llvm::Optional<llvm::StringRef> filename);
Namespace(SereneContext &ctx, llvm::StringRef ns_name,
llvm::Optional<llvm::StringRef> filename);
public:
std::string name;
llvm::Optional<std::string> filename;
Namespace(SereneContext &ctx, llvm::StringRef ns_name,
llvm::Optional<llvm::StringRef> filename);
/// Create a new environment with the give \p parent as the parent,
/// push the environment to the internal environment storage and
/// return a reference to it. The namespace itself is the owner of

View File

@ -102,6 +102,9 @@ NSPtr SereneContext::makeNamespace(llvm::StringRef name,
};
MaybeNS SereneContext::readNamespace(const std::string &name) {
// TODO: Replace this location with a proper location indicating
// the reason why the location data is not available.
// For example, because the ns might be the entry point ns.
auto loc = reader::LocationRange::UnknownLocation(name);
return readNamespace(name, loc);
@ -109,7 +112,6 @@ MaybeNS SereneContext::readNamespace(const std::string &name) {
MaybeNS SereneContext::readNamespace(const std::string &name,
reader::LocationRange loc) {
return withCurrentNS<MaybeNS>(name, [&]() -> MaybeNS {
return this->sourceManager.readNamespace(*this, name, loc);
});