class documentation

class RevenPrototypes(object):

View In Hierarchy

Access prototypes-parsing capability from a reven2.RevenServer

Method __init__ No summary
Method parse_one_function Helper function to parse the first function from the given translation unit to a ready to use Prototype
Method parse_translation_unit Parse functions from the given translation unit.
Property calling_conventions Available calling conventions.
Instance Variable _reven_server Undocumented
def __init__(self, reven_server):
Parameters
reven_server:_RevenServerreven2.RevenServer
def parse_one_function(self, translation_unit, calling_convention):

Helper function to parse the first function from the given translation unit to a ready to use Prototype

Examples

>>> rvnproto = RevenPrototypes(reven_server)
>>> proto = rvnproto.parse_one_function(
...     "using Bar = int; int foo(Bar bar);",
...      rvnproto.calling_conventions.Ms64
... )
>>> call_tr = reven_server.trace.transition(1234)
>>> foo = proto.call_site_values(call_tr)
>>> print(foo.ret())
0
>>> print(foo.arg("bar"))
4

Information

Parameters
translation_unit:strcontent of the translation unit.
calling_convention:_CallingConventioncalling convention to use for resolving arguments.
Returns
PrototypePrototype instance.
Raises
RuntimeErrorif translation unit parsing fails.
IndexErrorif no function found in translation unit.
def parse_translation_unit(self, translation_unit):

Parse functions from the given translation unit.

Examples

>>> rvnproto = RevenPrototypes(reven_server)
>>> parsed = rvnproto.parse_translation_unit("int foo(bool bar);")
>>> print(parsed.diagnostics)
[]
>>> print(parsed.unknown_types)
[]
>>> for f in parsed.functions:
...     print(f"{f.name} -> {f.return_type.name}")
...     for p in f.parameters:
...         print(f"- {p.name}: {p.type.name}")
foo -> int
- bar: bool

Information

Parameters
translation_unit:strcontent of the translation unit.
Returns
ParsedTranslationUnitParsedTranslationUnit instance.
@property
calling_conventions: CallingConventions =

Available calling conventions.

_reven_server =

Undocumented