Skip to content

Commit

Permalink
Added global method to transpilers
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelMarcelino committed May 8, 2022
1 parent 5a946ac commit 1ef2764
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pycpp/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def usings(self):
uses = "\n".join(f"#include {mod}{lint_exception}" for mod in usings)
return uses

def globals(self):
return "\n".join(self._globals)

def headers(self, meta: InferMeta):
lint_exception = (
" // NOLINT(build/include_order)" if not self._no_prologue else ""
Expand Down
3 changes: 3 additions & 0 deletions pydart/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def usings(self):
uses = "\n".join(f"import '{mod}';" for mod in usings)
return f"// @dart=2.9\n{uses}" if uses else ""

def globals(self):
return "\n".join(self._globals)

def visit_FunctionDef(self, node) -> str:
body = "\n".join([self.visit(n) for n in node.body])
typenames, args = self.visit(node.args)
Expand Down
3 changes: 3 additions & 0 deletions pygo/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def usings(self):
buf += ")\n"
return buf + "\n\n"

def globals(self):
return "\n".join(self._globals)

def _combine_value_index(self, value_type, index_type) -> str:
return f"{value_type}{index_type}"

Expand Down
3 changes: 3 additions & 0 deletions pykt/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def usings(self):
uses = "\n".join(f"import {mod}" for mod in usings)
return uses

def globals(self):
return "\n".join(self._globals)

def visit_FunctionDef(self, node) -> str:
body = "\n".join([self.visit(n) for n in node.body])
typenames, args = self.visit_arguments(node.args)
Expand Down
3 changes: 3 additions & 0 deletions pynim/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def usings(self):
uses = "\n".join(f"import {mod}" for mod in usings)
return uses

def globals(self):
return "\n".join(self._globals)

def _combine_value_index(self, value_type, index_type) -> str:
return f"{value_type}[{index_type}]"

Expand Down
3 changes: 3 additions & 0 deletions pyrs/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def usings(self):
)
return f"{cargo_toml}\n{lint_ignores}\n\n{externs}\n{uses}\n"

def globals(self):
return "\n".join(self._globals)

def features(self):
if self._features:
features = ", ".join(sorted(list(set(self._features))))
Expand Down
3 changes: 3 additions & 0 deletions pysmt/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def usings(self):
uses = "\n".join(f"import {mod}" for mod in usings)
return uses

def globals(self):
return "\n".join(self._globals)

def _combine_value_index(self, value_type, index_type) -> str:
return f"(_ {value_type} {index_type})"

Expand Down
3 changes: 3 additions & 0 deletions pyv/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def usings(self):
# but V expects the module statement to be at the top.
return f"module main\n{uses}"

def globals(self):
return "\n".join(self._globals)

def _combine_value_index(self, value_type: str, index_type: str) -> str:
return f"{value_type}{index_type}"

Expand Down

0 comments on commit 1ef2764

Please sign in to comment.