10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-13 01:23:45 +01:00

Completed subroutine touches and calls

This commit is contained in:
Anthony Scemama 2009-09-04 23:48:49 +02:00
parent 31547aac08
commit c1b0c0dfa2
4 changed files with 18 additions and 5 deletions

View File

@ -440,8 +440,6 @@ def irp_simple_statements(text):
def process_function(line):
assert isinstance(line,Function)
buffer = line.text.split('(')
if (len(buffer) < 2):
error.fail(line,"Syntax error")
subname = find_subname(line)
length = len(subname)
i = line.i

View File

@ -42,8 +42,15 @@ class Sub(object):
############################################################
def touches(self):
if '_touches' not in self.__dict__:
self._touches = filter(lambda x: isinstance(x,Touch),self.text) != []
from subroutines import subroutines
self._touches = []
for line in filter(lambda x: isinstance(x,Touch),self.text):
self._touches += line.text.split()[1:]
for sub in self.calls:
self._touches += subroutines[sub].touches
self._touches = make_single(self._touches)
return self._touches
touches = property(touches)
############################################################
def regexp(self):
@ -62,6 +69,7 @@ class Sub(object):
for line in buffer:
sub = line.text.split('(',1)[0].split()[1]
self._calls.append(sub)
self._calls = make_single(self._calls)
return self._calls
calls = property(calls)
@ -69,4 +77,4 @@ class Sub(object):
if __name__ == '__main__':
from preprocessed_text import preprocessed_text
from subroutines import subroutines
print subroutines['invert'].calls
print subroutines['brownian_step'].touches

View File

@ -38,6 +38,12 @@ def find_subname(line):
error.fail(line,"Syntax Error")
return buffer[-1]
def make_single(l):
d = {}
for x in l:
d[x] = True
return d.keys()
if __name__ == '__main__':
print build_dim([])

View File

@ -165,4 +165,5 @@ class Variable(object):
if __name__ == '__main__':
from preprocessed_text import preprocessed_text
from variables import variables
print variables['elec_fitcusp_lapl'].doc
for v in variables.keys():
print v