def reduce_parameters(): for p in raw_parameters: li = library.get(p.stack.library_name) gr = li.groups[p.stack.extension_name.upper()] ex = gr.extensions[p.stack.extension_name.lower()] # ca = ex.categories[p.stack.category_name.lower()] ca = ex.categories['functions'] fn = ca.functions[p.stack.function_name] if not p.name in fn.parameters: fn.parameters[p.name] = parameter(p) else: log.warn('P %s already in %s.%s.%s.%s' % (p.name, li.name, ex.name, ca.name, fn.name))
def reduce_functions(): for f in raw_functions: li = library.get(f.stack.library_name) gr = li.groups[f.stack.extension_name.upper()] ex = gr.extensions[f.stack.extension_name.lower()] # ca = ex.categories[f.stack.category_name.lower()] ca = ex.categories["functions"] if not f.name in ca.functions: ca.functions[f.name] = function(f) else: log.warn("F %s already in %s.%s.%s" % (f.name, li.name, ex.name, ca.name)) ca.functions[f.name].in_files.append(f.stack.file_name) reduce_parameters()
def reduce_constants(): log.info('resolving constant values...') for c in raw_constants: while '_' in c.value: if '.' in c.value: scope_name, constant_name = c.value.split('.') else: scope_name = None constant_name = c.value resolved_values = set([ o.value for o in raw_constants if o.name == constant_name and o.value != constant_name and scope_name in [ None, o.stack.library_name, o.stack.extension_name, o.stack.category_name ] ]) if len(resolved_values) > 1: log.warn(c.name + ': ' + c.value + ', multiple value possible, taking first: ' + str(resolved_values)) c.value = resolved_values.pop() elif len(resolved_values) > 0: c.value = resolved_values.pop() else: log.warn(c.name + ': ' + c.value + ', no value found') break log.info('reducing constants...') for rc in raw_constants: li = library.get(rc.stack.library_name) gr = li.groups[rc.stack.extension_name.upper()] ex = gr.extensions[rc.stack.extension_name.lower()] # ca = ex.categories[c.stack.category_name.lower()] ca = ex.categories['constants'] c = constant(rc) if not c.name in ca.constants: ca.constants[c.name] = constant(c) elif c == ca.constants[c.name]: ca.constants[c.name].update(c) else: log.warn('C %s (%s, %s) already in %s.%s.%s' % (c.name, c.value, ca.constants[c.name].value, li.name, ex.name, ca.name)) else: