Skip to content

Commit

Permalink
Add noinline option to procedure declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
perry0513 committed Mar 1, 2024
1 parent df7fb08 commit 04947b7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/uclid/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,22 @@ def __declstring__(self) -> str:


class UclidProcedureDecl(UclidDecl):
def __init__(self, name: str, proceduresig, body):
def __init__(self, name: str, proceduresig, body, noinline=False) -> None:
super().__init__(DeclTypes.PROCEDURE)
self.name = name
self.proceduresig = proceduresig
self.body = body
self.noinline = noinline

@property
def __declstring__(self) -> str:
return """procedure {}
return """procedure {}{}
{}
{{
{}
}}
""".format(
"[noinline] " if self.noinline else "",
self.name,
self.proceduresig.__inject__(),
textwrap.indent(self.body.__inject__(), "\t"),
Expand Down Expand Up @@ -1745,14 +1747,19 @@ def mkUninterpretedFunction(self, name, functionsig) -> UclidFunction:
return uf

def mkProcedure(
self, name: str, proceduresig: UclidProcedureSig, body: UclidStmt
self,
name: str,
proceduresig: UclidProcedureSig,
body: UclidStmt,
noinline: bool = False,
) -> UclidProcedure:
"""Add a new procedure to the module
Args:
name (str): Procedure name
proceduresig (UclidProcedureSig): Procedure signature
body (UclidStmt): Procedure body
noinline (bool, optional): True for non-inline procedure. Defaults to False.
Returns:
UclidProcedure: Procedure object
Expand All @@ -1763,7 +1770,7 @@ def mkProcedure(
)
else:
proc = UclidProcedure(name)
procdecl = UclidProcedureDecl(name, proceduresig, body)
procdecl = UclidProcedureDecl(name, proceduresig, body, noinline)
self.procedure_defns[name] = procdecl
return proc

Expand Down

0 comments on commit 04947b7

Please sign in to comment.