Skip to content

Commit

Permalink
conversion: also before conversion delete unsimulated function defini…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
gasparka committed Jun 19, 2018
1 parent d84583e commit 7e39471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pyha/conversion/redbaron_mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pyha
from pyha import Complex
from pyha.common.core import SKIP_FUNCTIONS, Hardware
from pyha.common.core import SKIP_FUNCTIONS, Hardware, PyhaFunc
from pyha.common.fixed_point import Sfix
from pyha.common.util import get_iterable, tabber, formatter, is_constant, const_filter
from pyha.conversion.python_types_vhdl import escape_reserved_vhdl, VHDLModule, init_vhdl_type, VHDLEnum, VHDLList, \
Expand Down Expand Up @@ -751,12 +751,24 @@ def convert(red: Node, obj=None):
set_convert_obj(obj)

# delete all non convertable functions from redbaron AST
# coding style is akward because of some redbaron bugs...
while True:
f = red.find('def', name=lambda x: x in SKIP_FUNCTIONS or x[:2] == '__' or x[:5] == '_pyha')
if not f:
break
f.parent.remove(f)

# delete functions that were not simulated
# problem was that some transforms may still parse (e.g find all assignments in the design) these and run into trouble as no type info exists
for k, v in obj.__dict__.items():
if isinstance(v, PyhaFunc):
if not v.calls:
f = red.find('def', name=lambda x: x == k)
if not f:
continue
f.parent.remove(f)


# run RedBaron based conversions before parsing
transform_preprocessor(red)
transform_resize_arguments(red)
Expand Down
1 change: 1 addition & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_func_call_not_simulated():
delete functions calls that have not been called during simulation"""
class T(Hardware):
def b(self):
l = 123 # b should NOT be parsed, or this line gives error (no type information)
return 1

def a(self):
Expand Down

0 comments on commit 7e39471

Please sign in to comment.