Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/tools/gdb_printers.py
2723 views
1
# This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
3
class VariantPrinter:
4
def __init__(self, val):
5
self.val = val
6
7
def to_string(self):
8
typeId = int(self.val['typeId'])
9
type = self.val.type.template_argument(typeId)
10
value = self.val['storage'].reinterpret_cast(type.pointer()).dereference()
11
return type.name + " [" + str(value) + "]"
12
13
def match_printer(val):
14
type = val.type.strip_typedefs()
15
if type.name and type.name.startswith('Luau::Variant<'):
16
return VariantPrinter(val)
17
return None
18
19
gdb.pretty_printers.append(match_printer)
20
21