Пример #1
0
func (this *writer) newEdgeStmt(edge *Edge) *ast.EdgeStmt {
	src, err := this.newLocation(edge.Src, edge.SrcPort)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		fmt.Fprintln(os.Stderr, "Src:", edge.Src, ", Dst:", edge.Dst)
		return nil
	}
	dst, err := this.newLocation(edge.Dst, edge.DstPort)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		fmt.Fprintln(os.Stderr, "Src:", edge.Src, ", Dst:", edge.Dst)
		return nil
	}
	stmt := &ast.EdgeStmt{
		Source: src,
		EdgeRHS: ast.EdgeRHS{
			&ast.EdgeRH{
				ast.EdgeOp(edge.Dir),
				dst,
			},
		},
		Attrs: ast.PutMap(edge.Attrs),
	}
	return stmt
}
Пример #2
0
func (this *writer) newNodeStmt(name string) *ast.NodeStmt {
	node := this.Nodes.Lookup[name]
	id := ast.MakeNodeId(node.Name, "")
	this.writtenLocations[node.Name] = true
	return &ast.NodeStmt{
		id,
		ast.PutMap(node.Attrs),
	}
}