various intern pool & comptime interpreter changes (#1179)

* intern_pool: add getUnsignedInt

* add an empty struct literal

* resolve array length as usize in comptime interpreter

* use only one global intern pool

* store analysis errors in `DocumentStore.Handle`

* add typed undefined value

* add typed null value
This commit is contained in:
Techatrix
2023-05-09 06:25:26 +02:00
committed by GitHub
parent f6c808a4b3
commit 029f5094ff
12 changed files with 146 additions and 71 deletions

View File

@@ -16,6 +16,7 @@ const Analyser = @This();
gpa: std.mem.Allocator,
arena: std.heap.ArenaAllocator,
store: *DocumentStore,
ip: ?InternPool,
bound_type_params: std.AutoHashMapUnmanaged(Ast.full.FnProto.Param, TypeWithHandle) = .{},
using_trail: std.AutoHashMapUnmanaged(Ast.Node.Index, void) = .{},
resolved_nodes: std.HashMapUnmanaged(NodeWithUri, ?TypeWithHandle, NodeWithUri.Context, std.hash_map.default_max_load_percentage) = .{},
@@ -25,6 +26,7 @@ pub fn init(gpa: std.mem.Allocator, store: *DocumentStore) Analyser {
.gpa = gpa,
.arena = std.heap.ArenaAllocator.init(gpa),
.store = store,
.ip = null,
};
}
@@ -32,6 +34,7 @@ pub fn deinit(self: *Analyser) void {
self.bound_type_params.deinit(self.gpa);
self.using_trail.deinit(self.gpa);
self.resolved_nodes.deinit(self.gpa);
if (self.ip) |*intern_pool| intern_pool.deinit(self.gpa);
self.arena.deinit();
}
@@ -823,7 +826,7 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
log.info("Invoking interpreter!", .{});
const interpreter = analyser.store.ensureInterpreterExists(handle.uri) catch |err| {
const interpreter = analyser.store.ensureInterpreterExists(handle.uri, &analyser.ip.?) catch |err| {
log.err("Failed to interpret file: {s}", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);