add initial intern pool implementation
This commit is contained in:
parent
40167a5b52
commit
4f180712bb
File diff suppressed because it is too large
Load Diff
@ -943,6 +943,7 @@ pub fn ensureInterpreterExists(self: *DocumentStore, uri: Uri) !void {
|
||||
var int = try self.allocator.create(ComptimeInterpreter);
|
||||
int.* = ComptimeInterpreter{
|
||||
.allocator = self.allocator,
|
||||
.arena = std.heap.ArenaAllocator.init(self.allocator),
|
||||
.document_store = self,
|
||||
.uri = uri,
|
||||
};
|
||||
|
2110
src/InternPool.zig
Normal file
2110
src/InternPool.zig
Normal file
File diff suppressed because it is too large
Load Diff
@ -504,11 +504,12 @@ fn typeToCompletion(
|
||||
),
|
||||
.primitive, .array_index => {},
|
||||
.@"comptime" => |co| {
|
||||
const ti = co.type.getTypeInfo();
|
||||
switch (ti) {
|
||||
.@"struct" => |st| {
|
||||
var fit = st.fields.iterator();
|
||||
while (fit.next()) |entry| {
|
||||
const key = co.interpreter.ip.indexToKey(co.type.ty);
|
||||
|
||||
switch (key) {
|
||||
.struct_type => |struct_info| {
|
||||
var field_it = struct_info.fields.iterator();
|
||||
while (field_it.next()) |entry| {
|
||||
try list.append(allocator, .{
|
||||
.label = entry.key_ptr.*,
|
||||
.kind = .Field,
|
||||
@ -517,15 +518,7 @@ fn typeToCompletion(
|
||||
});
|
||||
}
|
||||
|
||||
var it = st.scope.declarations.iterator();
|
||||
while (it.next()) |entry| {
|
||||
try list.append(allocator, .{
|
||||
.label = entry.key_ptr.*,
|
||||
.kind = if (entry.value_ptr.isConstant()) .Constant else .Variable,
|
||||
.insertText = entry.key_ptr.*,
|
||||
.insertTextFormat = .PlainText,
|
||||
});
|
||||
}
|
||||
// TODO declaration completion
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
@ -849,7 +842,7 @@ fn hoverSymbol(server: *Server, decl_handle: analysis.DeclWithHandle) error{OutO
|
||||
|
||||
const resolved_type_str = if (resolved_type) |rt|
|
||||
if (rt.type.is_type_val) switch (rt.type.data) {
|
||||
.@"comptime" => |*co| try std.fmt.allocPrint(server.arena.allocator(), "{ }", .{co.interpreter.formatTypeInfo(co.type.getTypeInfo())}),
|
||||
.@"comptime" => |*co| try std.fmt.allocPrint(server.arena.allocator(), "{}", .{co.type.ty.fmtType(&co.interpreter.ip)}),
|
||||
else => "type",
|
||||
} else switch (rt.type.data) { // TODO: Investigate random weird numbers like 897 that cause index of bounds
|
||||
.pointer,
|
||||
|
Loading…
Reference in New Issue
Block a user