def visit(self, node): args = [ ast.NamedArg(ident=ast.Id(ident='data'), arg=node.arg) ] if node.label: const_name = node.label.ident else: # Create a unique name if not given by label self.counter += 1 const_name = '_literal_const_'+str(self.counter) const_actor = ast.Assignment(ident=const_name, actor_type='std.Constant', args=args) const_actor.debug_info = node.arg.debug_info const_actor_port = ast.OutPort(actor=const_name, port='token') link = node.parent link.replace_child(node, const_actor_port) block = link.parent block.add_child(const_actor)
def visit(self, node): args = [ ast.NamedArg(ident=ast.Id(ident='data'), arg=node.arg), ast.NamedArg(ident=ast.Id(ident='n'), arg=ast.Value(value=-1)) ] self.counter += 1 const_name = '_literal_const_' + str(self.counter) const_actor = ast.Assignment(ident=const_name, actor_type='std.Constant', args=args) const_actor.debug_info = node.arg.debug_info const_actor_port = ast.OutPort(actor=const_name, port='token') link = node.parent link.replace_child(node, const_actor_port) block = link.parent block.add_child(const_actor)
def visit(self, node): link = node.parent if link.outport is node: actor_type = 'flow.Void' port_class = ast.OutPort reason = "Using 'void' as input to '{}.{}'".format(link.inport.actor, link.inport.port) self.issue_tracker.add_warning(reason, node) else: actor_type='flow.Terminator' port_class = ast.InPort self.counter += 1 actor_name = '_void_'+str(self.counter) void_actor = ast.Assignment(ident=actor_name, actor_type=actor_type) void_actor_port = port_class(actor=actor_name, port='void') link = node.parent link.replace_child(node, void_actor_port) block = link.parent block.add_child(void_actor)
def visit(self, node): # std.Constantify(constant) ports: in/out args = [ast.NamedArg(ident=ast.Id(ident='constant'), arg=node.value)] if node.label: transform_name = node.label.ident else: # Create a unique name if not given by label self.counter += 1 transform_name = '_transform_'+str(self.counter) transform_actor = ast.Assignment(ident=transform_name, actor_type='std.Constantify', args=args) transform_actor.debug_info = node.value.debug_info transform_actor_outport = ast.OutPort(actor=transform_name, port='out') transform_actor_inport = ast.InPort(actor=transform_name, port='in') link = node.parent block = link.parent block.add_child(transform_actor) new_link = ast.Link(outport=transform_actor_outport, inport=node.port) block.add_child(new_link) link.inport = transform_actor_inport
def p_assignment(self, p): """assignment : IDENTIFIER COLON qualified_name LPAREN named_args RPAREN""" p[0] = ast.Assignment(ident=p[1], actor_type=p[3], args=p[5], debug_info=self.debug_info(p, 1))