More dependency movement from zpl, incremental design improvements.

Made token_fmt more ergonomic, going to have to use a similar behavior with the upfront body constructors.
This commit is contained in:
2023-07-12 01:33:11 -04:00
parent 20d307759b
commit 7828e6d2ea
26 changed files with 2009 additions and 739 deletions

98
.vscode/gencpp.natvis vendored
View File

@ -1,98 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="gen::AllocatorInfo">
<DisplayString>Data:{Data} Proc:{Proc}</DisplayString>
</Type>
<Type Name="gen::Array&lt;*&gt;">
<DisplayString>Num:{((Header*)((char*)Data - sizeof(Header)))->Num}, Capacity:{((Header*)((char*)Data - sizeof(Header)))->Capacity}</DisplayString>
<Expand>
<Synthetic Name="Header">
<DisplayString>{(Header*)((char*)Data - sizeof(Header))}</DisplayString>
<Expand>
<Item Name="Allocator">((Header*)((char*)Data - sizeof(Header)))->Allocator</Item>
<Item Name="Capacity">((Header*)((char*)Data - sizeof(Header)))->Capacity</Item>
<Item Name="Num">((Header*)((char*)Data - sizeof(Header)))->Num</Item>
</Expand>
</Synthetic>
<ArrayItems>
<Size>((Header*)((char*)Data - sizeof(Header)))->Capacity</Size>
<ValuePointer>Data</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="gen::StrC">
<DisplayString>Len:{Len} Ptr:{Ptr, [Len]s}</DisplayString>
</Type>
<Type Name="gen::String">
<DisplayString Condition="Data == nullptr">null</DisplayString>
<DisplayString>{Data,na}</DisplayString>
<Expand>
<Synthetic Name="Header">
<DisplayString>{(Header*)((char*)Data - sizeof(Header))}</DisplayString>
<Expand>
<Item Name="Allocator">((Header*)((char*)Data - sizeof(Header)))->Allocator</Item>
<Item Name="Length">((Header*)((char*)Data - sizeof(Header)))->Length</Item>
<Item Name="Capacity">((Header*)((char*)Data - sizeof(Header)))->Capacity</Item>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="gen::String::Header">
<DisplayString>Length: {Length}, Capacity: {Capacity}</DisplayString>
<Expand>
<Item Name="Allocator">Allocator</Item>
<Item Name="Length">Length</Item>
<Item Name="Capacity">Capacity</Item>
</Expand>
</Type>
<Type Name="gen::AST">
<DisplayString>{Name} {Type}</DisplayString>
<Expand>
<Item Name="Type">Type</Item>
<Item Name="Name">Name</Item>
<Item Name="Parent">Parent</Item>
<Item Name="Op" Condition="Op != 43">Op</Item>
<Item Name="ModuleFlags">ModuleFlags</Item>
<Item Name="ParentAcess" Condition="ParentAccess != gen::AccessSpec::Invalid">ParentAccess</Item>
<Item Name="ArrStatic" Condition="DynamicEntries == false">ArrStatic</Item>
<Item Name="Index" Condition="DynamicEntries == false">StaticIndex</Item>
<Item Name="ArrDyn" Condition="DynamicEntries == true">ArrDyn</Item>
<Item Name="Index" Condition="DynamicEntries == true">ArrDyn.num()</Item>
</Expand>
</Type>
<Type Name="gen::Code">
<DisplayString Condition="ast != nullptr">{ast->Name} {ast->Type}</DisplayString>
<Expand>
<Item Name="Type">ast->Type</Item>
<Item Name="Name">ast->Name</Item>
<Item Name="Parent">ast->Parent</Item>
<Item Name="Op" Condition="ast->Op != 43">ast->Op</Item>
<Item Name="ModuleFlags">ast->ModuleFlags</Item>
<Item Name="ParentAcess" Condition="ast->ParentAccess != gen::AccessSpec::Invalid">ast->ParentAccess</Item>
<Item Name="ArrStatic" Condition="ast->DynamicEntries == false">ast->ArrStatic</Item>
<Item Name="Index" Condition="ast->DynamicEntries == false">ast->StaticIndex</Item>
<Item Name="ArrDyn" Condition="ast->DynamicEntries == true">ast->ArrDyn</Item>
<Item Name="Index" Condition="ast->DynamicEntries == true">ast->ArrDyn.num()</Item>
</Expand>
</Type>
<Type Name="gen::Code">
<DisplayString>{ast.Name} {ast.Type}</DisplayString>
</Type>
<Type Name ="gen::Parser::Token">
<DisplayString>Length:{Length} Text:{Text, [Length]s} Type:{Type}</DisplayString>
</Type>
<Type Name="gen::Parser::TokArray">
<DisplayString>Current[ { Arr[Idx] } ] Idx:{ Idx }</DisplayString>
</Type>
</AutoVisualizer>

View File

@ -1,84 +0,0 @@
import lldb
class String_SyntheticChildrenProvider:
def __init__(self, valobj, internal_dict):
self.valobj = valobj
def num_children(self):
return 3
def get_child_index(self, name):
if name == "Data":
return 0
if name == "Length":
return 1
if name == "Capacity":
return 2
return None
def get_child_at_index(self, index):
if index == 0:
return self.valobj.GetChildMemberWithName("Data")
data = self.valobj.GetChildMemberWithName("Data")
header_ptr = data.GetValueAsUnsigned() - 16
target = self.valobj.GetTarget()
header_type = target.FindFirstType("gen::String::Header")
header = self.valobj.CreateValueFromAddress("Header", header_ptr, header_type)
if index == 1:
return header.GetChildMemberWithName("Length")
if index == 2:
return header.GetChildMemberWithName("Capacity")
return None
def update(self):
pass
def list_synthetic_providers(debugger):
print("Listing synthetic providers (start)")
num_categories = debugger.GetNumCategories()
print("Debugger language categories count:", num_categories)
cpp_category = None
for i in range(num_categories):
print("WERE HERE")
print(debugger)
cat = debugger.GetCategoryAtIndex(i)
print("Category name: {}, language: {}".format(cat.GetName(), cat.GetLanguage()))
if cat.GetLanguage() == lldb.eLanguageTypeC_plus_plus:
cpp_category = cat
break
if not cpp_category:
print("Could not get C++ category")
return
synthetic_providers = cpp_category.GetSyntheticChildren()
if not synthetic_providers:
print("Could not get synthetic children")
return
num_providers = synthetic_providers.GetSize()
print("Number of synthetic providers:", num_providers)
for i in range(num_providers):
provider = synthetic_providers.GetSyntheticChildAtIndex(i)
print("Provider regex: {}, class name: {}".format(provider.GetRegex(), provider.GetDescription()))
print("Listing synthetic providers (finish)")
def __lldb_init_module(debugger, internal_dict):
print("Importing the String visualization")
debugger.HandleCommand("type synthetic add -x '^gen::String$' -l gencpp_libvis.String_SyntheticChildrenProvider")
print("Before list_synthetic_providers")
list_synthetic_providers(debugger)
lldb.debugger = None

12
.vscode/launch.json vendored
View File

@ -12,7 +12,6 @@
"args": [],
"cwd": "${workspaceFolder}/test/gen/",
"postRunCommands": [
"command script import \"${workspaceFolder}/.vscode/gencpp_lldbvis.py\""
]
},
{
@ -22,16 +21,7 @@
"program": "${workspaceFolder}/test/gen/build/gencpp.exe",
"args": [],
"cwd": "${workspaceFolder}/test/gen/",
"visualizerFile": "${workspaceFolder}/.vscode/gencpp.natvis"
},
{
"type": "cppvsdbg",
"request": "launch",
"name": "Debug gentime parsed vsdbg",
"program": "${workspaceFolder}/test/gen/build/gencpp_parsed.exe",
"args": [],
"cwd": "${workspaceFolder}/test/gen/",
"visualizerFile": "${workspaceFolder}/.vscode/gencpp.natvis"
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
}
]
}