def _lift_component_decl(location, *args): if len(args) == 1: return args[0] id, component_defn = args return Component(id, includes=component_defn.includes, control=component_defn.control, hardware=component_defn.hardware, provides=component_defn.provides, uses=component_defn.uses, emits=component_defn.emits, consumes=component_defn.consumes, dataports=component_defn.dataports, attributes=component_defn.attributes, mutexes=component_defn.mutexes, semaphores=component_defn.semaphores, binary_semaphores=component_defn.binary_semaphores, composition=component_defn.composition, configuration=component_defn.configuration, location=location)
def p_connection_defn(t): '''connection_defn : connection connector_ref ID LPAREN from ID DOT ID COMMA to ID DOT ID RPAREN SEMI | connection connector_ref ID LPAREN from ID COMMA to ID DOT ID RPAREN SEMI | connection connector_ref ID LPAREN from ID DOT ID COMMA to ID RPAREN SEMI''' connector = t[2] name = t[3] if len(t) == 16: from_instance = Reference(t[6], Instance, filename=t.lexer.filename, \ lineno=t.lexer.lineno) from_interface = Reference(t[8], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) to_instance = Reference(t[11], Instance, filename=t.lexer.filename, \ lineno=t.lexer.lineno) to_interface = Reference(t[13], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) else: assert len(t) == 14 # placeholder refering to 'current instance of this component' # required for hierarchical components virtual_instance = Instance(Component(), '__virtual__', filename=t.lexer.filename, lineno=t.lexer.lineno) if t[7] == ',': from_instance = virtual_instance from_interface = Reference(t[6], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) to_instance = Reference(t[9], Instance, filename=t.lexer.filename, \ lineno=t.lexer.lineno) to_interface = Reference(t[11], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) else: assert t[9] == ',' from_instance = Reference(t[6], Instance, \ filename=t.lexer.filename, lineno=t.lexer.lineno) from_interface = Reference(t[8], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) to_instance = virtual_instance to_interface = Reference(t[11], Interface, \ filename=t.lexer.filename, lineno=t.lexer.lineno) t[0] = Connection(connector, name, from_instance, from_interface, \ to_instance, to_interface, filename=t.lexer.filename, \ lineno=t.lexer.lineno)
def _lift_component_defn(location, *args): compositions = [x for x in args if isinstance(x, Composition)] assert len(compositions) <= 1 composition = compositions[0] if len(compositions) == 1 else None configurations = [x for x in args if isinstance(x, Configuration)] assert len(configurations) <= 1 configuration = configurations[0] if len(configurations) == 1 else None return Component(includes=[x for x in args if isinstance(x, Include)], control='control' in args, hardware='hardware' in args, provides=[x for x in args if isinstance(x, Provides)], uses=[x for x in args if isinstance(x, Uses)], emits=[x for x in args if isinstance(x, Emits)], consumes=[x for x in args if isinstance(x, Consumes)], dataports=[x for x in args if isinstance(x, Dataport)], attributes=[x for x in args if isinstance(x, Attribute)], mutexes=[x for x in args if isinstance(x, Mutex)], semaphores=[x for x in args if isinstance(x, Semaphore)], binary_semaphores=[x for x in args if isinstance(x, BinarySemaphore)], composition=composition, configuration=configuration, location=location)
def p_component_block(t): '''component_block : LBRACE component_defn RBRACE''' includes, control, hardware, provides, uses, emits, consumes, dataports, \ attributes, mutexes, semaphores, composition, configuration = t[2] assert isinstance(control, bool) assert isinstance(hardware, bool) assert isinstance(provides, list) for p in provides: assert isinstance(p, Provides) assert isinstance(uses, list) for u in uses: assert isinstance(u, Uses) assert isinstance(consumes, list) for c in consumes: assert isinstance(c, Consumes) assert isinstance(dataports, list) for d in dataports: assert isinstance(d, Dataport) t[0] = Component(None, includes, control, hardware, provides, uses, emits, \ consumes, dataports, attributes, mutexes, semaphores, composition, \ configuration, filename=t.lexer.filename, lineno=t.lexer.lineno)