Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support octal, hex, and arbitrary radix numbers #140

Merged
merged 10 commits into from
Dec 26, 2024
6 changes: 6 additions & 0 deletions compiler+runtime/include/cpp/jank/analyze/expr/var_deref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ namespace jank::analyze::expr
template <typename E>
struct var_deref : expression_base
{
/* Holds the fully qualified name for the originally resolved var.
* It will be useful to know that the var deref happened through a
* referred var, for static analysis and error reporting.
*
* For all the other purposes, `var` member should be used that points
* to the actual value of the var.. */
runtime::obj::symbol_ptr qualified_name{};
runtime::var_ptr var{};

Expand Down
4 changes: 2 additions & 2 deletions compiler+runtime/include/cpp/jank/read/lex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ namespace jank::read::lex
processor(native_persistent_string_view const &f);

result<token, error> next();
result<codepoint, error> peek() const;
result<codepoint, error> peek(native_integer const ahead = 1) const;
option<error> check_whitespace(native_bool const found_space);

iterator begin();
iterator end();

size_t pos{};
/* Whether or not the previous token requires a space after it. */
/* Whether the previous token requires a space after it. */
native_bool require_space{};
/* True when seeing a '/' following a number. */
native_bool found_slash_after_number{};
Expand Down
19 changes: 19 additions & 0 deletions compiler+runtime/include/cpp/jank/runtime/module/loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ namespace jank::runtime::module
latest,
};

enum class module_type : uint8_t
{
o,
cpp,
jank,
cljc
};

struct file_entry
{
object_ptr to_runtime_data() const;
native_bool exists() const;
std::time_t last_modified_at() const;

/* If the file is within a JAR, this will be the path to the JAR. */
option<native_persistent_string> archive_path;
Expand Down Expand Up @@ -68,6 +78,14 @@ namespace jank::runtime::module
option<file_entry> cljc;
};

struct find_result
{
/* All the sources for a module */
entry sources;
/* On the basis of origin, source that should be loaded. */
option<module_type> to_load;
};

/* These separators match what the JVM does on each system. */
#ifdef _WIN32
static constexpr char module_separator{ ';' };
Expand All @@ -80,6 +98,7 @@ namespace jank::runtime::module
native_bool is_loaded(native_persistent_string_view const &) const;
void set_loaded(native_persistent_string_view const &);

string_result<find_result> find(native_persistent_string_view const &module, origin const ori);
string_result<void> load(native_persistent_string_view const &module, origin const ori);

string_result<void>
Expand Down
2 changes: 1 addition & 1 deletion compiler+runtime/src/cpp/jank/codegen/llvm_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace jank::codegen
llvm::Value *llvm_processor::gen(expr::var_deref<expression> const &expr,
expr::function_arity<expression> const &) const
{
auto const ref(gen_var(expr.qualified_name));
auto const ref(gen_var(make_box<obj::symbol>(expr.var->n, expr.var->name)));
auto const fn_type(
llvm::FunctionType::get(ctx->builder->getPtrTy(), { ctx->builder->getPtrTy() }, false));
auto const fn(ctx->module->getOrInsertFunction("jank_deref", fn_type));
Expand Down
Loading
Loading