Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
added full name property to methods to distinguish module methods
Browse files Browse the repository at this point in the history
  • Loading branch information
localhuman committed Sep 23, 2017
1 parent c207375 commit 9e399c6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions boa/code/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def preprocess_method_calls(self):
changed_items = None
remove_pop_top = False
for index, token in enumerate(self.oplist):

if token.py_op == pyop.CALL_FUNCTION and token.func_processed == False:

token.func_processed = True
Expand Down
3 changes: 2 additions & 1 deletion boa/code/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def build(self):

filename = module.__file__

self.imported_module = Module(filename)
self.imported_module = Module(filename, module_name=self.module_path)



def is_valid(self):
Expand Down
6 changes: 6 additions & 0 deletions boa/code/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class Method():
def name(self):
return self.bp.name

@property
def full_name(self):
if len(self.module.module_path):
return '%s.%s' % (self.module.module_path, self.bp.name)
return self.bp.name

@property
def args(self):
# alist = list(self.bp.args)
Expand Down
19 changes: 14 additions & 5 deletions boa/code/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import collections


class Module():

bp = None # this is to store the byteplay reference
Expand All @@ -33,13 +34,14 @@ class Module():

loaded_modules = None

@property
def main_path(self):
return sys.modules['__main__']
_module_name =None


@property
def module_path(self):
return sys.modules['__main__'].__file__
return self._module_name



@property
def main(self):
Expand Down Expand Up @@ -70,16 +72,20 @@ def method_by_name(self, method_name):
return m
return None

def __init__(self, path):
def __init__(self, path, module_name=''):

self.path = path

self._module_name = module_name

source = open(path, 'rb')

suite = compile(source.read(), path, 'exec')

self.bp = Code.from_code(suite)



source.close()

self.build()
Expand Down Expand Up @@ -159,6 +165,9 @@ def write(self):

self.link_methods()

for m in self.methods:
print("method is %s " % m.full_name)

return self.write_methods()


Expand Down

0 comments on commit 9e399c6

Please sign in to comment.