diff --git a/lang/interpret_test.go b/lang/interpret_test.go index 1fbf6dcf..1181efc2 100644 --- a/lang/interpret_test.go +++ b/lang/interpret_test.go @@ -112,7 +112,7 @@ func TestAstFunc0(t *testing.T) { { graph, _ := pgraph.NewGraph("g") v1, v2 := vtex("int(42)"), vtex("var(x)") - e1 := edge("x") + e1 := edge("var:x") graph.AddVertex(&v1, &v2) graph.AddEdge(&v1, &v2, &e1) testCases = append(testCases, test{ @@ -141,7 +141,7 @@ func TestAstFunc0(t *testing.T) { { graph, _ := pgraph.NewGraph("g") v1, v2, v3, v4, v5 := vtex("int(42)"), vtex("var(a)"), vtex("var(b)"), vtex("var(c)"), vtex(`str("t")`) - e1, e2, e3 := edge("a"), edge("b"), edge("c") + e1, e2, e3 := edge("var:a"), edge("var:b"), edge("var:c") graph.AddVertex(&v1, &v2, &v3, &v4, &v5) graph.AddEdge(&v1, &v2, &e1) graph.AddEdge(&v2, &v3, &e2) @@ -164,7 +164,7 @@ func TestAstFunc0(t *testing.T) { graph, _ := pgraph.NewGraph("g") v1, v2 := vtex("bool(true)"), vtex("var(b)") graph.AddVertex(&v1, &v2) - e1 := edge("b") + e1 := edge("var:b") graph.AddEdge(&v1, &v2, &e1) testCases = append(testCases, test{ name: "simple bool", @@ -233,7 +233,7 @@ func TestAstFunc0(t *testing.T) { v5, v6 := vtex("var(i)"), vtex("var(x)") v7, v8 := vtex(`str("+")`), vtex(fmt.Sprintf(`call:%s(str("+"), int(42), var(i))`, operatorFuncName)) - e1, e2, e3, e4, e5 := edge("x"), edge("a"), edge("b"), edge("i"), edge("x") + e1, e2, e3, e4, e5 := edge("x"), edge("a"), edge("b"), edge("var:i"), edge("var:x") graph.AddVertex(&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8) graph.AddEdge(&v3, &v5, &e4) @@ -289,7 +289,7 @@ func TestAstFunc0(t *testing.T) { v4, v5 := vtex("var(x)"), vtex(`str("t")`) graph.AddVertex(&v1, &v2, &v3, &v4, &v5) - e1 := edge("x") + e1 := edge("var:x") // only one edge! (cool) graph.AddEdge(&v1, &v4, &e1) @@ -315,7 +315,7 @@ func TestAstFunc0(t *testing.T) { v4, v5 := vtex("var(x)"), vtex(`str("t")`) graph.AddVertex(&v1, &v2, &v3, &v4, &v5) - e1 := edge("x") + e1 := edge("var:x") // only one edge! (cool) graph.AddEdge(&v2, &v4, &e1) @@ -344,7 +344,7 @@ func TestAstFunc0(t *testing.T) { // v5, v6 := vtex(`str("t1")`), vtex(`str("t2")`) // // graph.AddVertex(&v0, &v1, &v2, &v3, &v4, &v5, &v6) - // e1, e2 := edge("x"), edge("x") + // e1, e2 := edge("var:x"), edge("var:x") // graph.AddEdge(&v1, &v3, &e1) // graph.AddEdge(&v2, &v4, &e2) // diff --git a/lang/interpret_test/TestAstFunc1/doubleinclude.graph b/lang/interpret_test/TestAstFunc1/doubleinclude.graph index b1095033..e813b273 100644 --- a/lang/interpret_test/TestAstFunc1/doubleinclude.graph +++ b/lang/interpret_test/TestAstFunc1/doubleinclude.graph @@ -1,7 +1,7 @@ -Edge: str("hey") -> var(foo) # foo -Edge: str("hey") -> var(foo) # foo -Edge: str("t1") -> var(a) # a -Edge: str("t2") -> var(a) # a +Edge: str("hey") -> var(foo) # var:foo +Edge: str("hey") -> var(foo) # var:foo +Edge: str("t1") -> var(a) # var:a +Edge: str("t2") -> var(a) # var:a Vertex: str("hey") Vertex: str("t1") Vertex: str("t2") diff --git a/lang/interpret_test/TestAstFunc1/empty-res-list-0.graph b/lang/interpret_test/TestAstFunc1/empty-res-list-0.graph index de0b977f..ab23ee3a 100644 --- a/lang/interpret_test/TestAstFunc1/empty-res-list-0.graph +++ b/lang/interpret_test/TestAstFunc1/empty-res-list-0.graph @@ -1,4 +1,4 @@ -Edge: list(str("hey")) -> var(names) # names +Edge: list(str("hey")) -> var(names) # var:names Edge: str("hello") -> list(str("hello"), str("world")) # 0 Edge: str("hey") -> list(str("hey")) # 0 Edge: str("world") -> list(str("hello"), str("world")) # 1 diff --git a/lang/interpret_test/TestAstFunc1/hello0.graph b/lang/interpret_test/TestAstFunc1/hello0.graph index 17c54891..12fe4cd4 100644 --- a/lang/interpret_test/TestAstFunc1/hello0.graph +++ b/lang/interpret_test/TestAstFunc1/hello0.graph @@ -1,5 +1,5 @@ Edge: str("hello: %s") -> call:fmt.printf(str("hello: %s"), var(s)) # a -Edge: str("world") -> var(s) # s +Edge: str("world") -> var(s) # var:s Edge: var(s) -> call:fmt.printf(str("hello: %s"), var(s)) # b Vertex: call:fmt.printf(str("hello: %s"), var(s)) Vertex: str("greeting") diff --git a/lang/interpret_test/TestAstFunc1/importscope0.graph b/lang/interpret_test/TestAstFunc1/importscope0.graph index 801e5366..f3a6c6b7 100644 --- a/lang/interpret_test/TestAstFunc1/importscope0.graph +++ b/lang/interpret_test/TestAstFunc1/importscope0.graph @@ -1,5 +1,5 @@ Edge: call:os.is_debian() -> if(call:os.is_debian()) # c -Edge: if(call:os.is_debian()) -> var(aaa) # aaa +Edge: if(call:os.is_debian()) -> var(aaa) # var:aaa Edge: str("bbb") -> if(call:os.is_debian()) # a Edge: str("ccc") -> if(call:os.is_debian()) # b Vertex: call:os.is_debian() diff --git a/lang/interpret_test/TestAstFunc1/importscope2.graph b/lang/interpret_test/TestAstFunc1/importscope2.graph index 801e5366..f3a6c6b7 100644 --- a/lang/interpret_test/TestAstFunc1/importscope2.graph +++ b/lang/interpret_test/TestAstFunc1/importscope2.graph @@ -1,5 +1,5 @@ Edge: call:os.is_debian() -> if(call:os.is_debian()) # c -Edge: if(call:os.is_debian()) -> var(aaa) # aaa +Edge: if(call:os.is_debian()) -> var(aaa) # var:aaa Edge: str("bbb") -> if(call:os.is_debian()) # a Edge: str("ccc") -> if(call:os.is_debian()) # b Vertex: call:os.is_debian() diff --git a/lang/interpret_test/TestAstFunc1/metaparams0.graph b/lang/interpret_test/TestAstFunc1/metaparams0.graph index 9a014663..fdea0d96 100644 --- a/lang/interpret_test/TestAstFunc1/metaparams0.graph +++ b/lang/interpret_test/TestAstFunc1/metaparams0.graph @@ -4,8 +4,8 @@ Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); pol Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # autogroup Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # realize Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # reverse -Edge: bool(true) -> var(b) # b -Edge: bool(true) -> var(b) # b +Edge: bool(true) -> var(b) # var:b +Edge: bool(true) -> var(b) # var:b Edge: float(4.2) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # limit Edge: int(-1) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # retry Edge: int(0) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # delay diff --git a/lang/interpret_test/TestAstFunc1/module_search1.graph b/lang/interpret_test/TestAstFunc1/module_search1.graph index 53a88290..5fa1e913 100644 --- a/lang/interpret_test/TestAstFunc1/module_search1.graph +++ b/lang/interpret_test/TestAstFunc1/module_search1.graph @@ -1,8 +1,8 @@ -Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # h2g2.answer -Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # example1.name -Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # example1.name -Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # mod1.name -Edge: int(3) -> var(third.three) # third.three +Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer +Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name +Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name +Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name +Edge: int(3) -> var(third.three) # var:third.three Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # x Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # x @@ -16,16 +16,16 @@ Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s") Edge: str("i imported remote: %s and %s") -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a -Edge: str("this is the nested git module mod1") -> var(mod1.name) # mod1.name -Edge: str("this is the nested git module mod1") -> var(mod1.name) # mod1.name -Edge: str("this is the nested local module mod1") -> var(mod1.name) # mod1.name +Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name +Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name +Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # b Edge: var(ex1) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example2/ and i contain: "), var(ex1)) # b Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b -Edge: var(example1.name) -> var(ex1) # ex1 -Edge: var(example1.name) -> var(example2.ex1) # example2.ex1 +Edge: var(example1.name) -> var(ex1) # var:ex1 +Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1 Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # c -Edge: var(h2g2.answer) -> var(answer) # answer +Edge: var(h2g2.answer) -> var(answer) # var:answer Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b diff --git a/lang/interpret_test/TestAstFunc1/polydoubleinclude.graph b/lang/interpret_test/TestAstFunc1/polydoubleinclude.graph index 2e6936d8..dde3da79 100644 --- a/lang/interpret_test/TestAstFunc1/polydoubleinclude.graph +++ b/lang/interpret_test/TestAstFunc1/polydoubleinclude.graph @@ -4,12 +4,12 @@ Edge: int(-37) -> list(int(13), int(42), int(0), int(-37)) # 3 Edge: int(0) -> list(int(13), int(42), int(0), int(-37)) # 2 Edge: int(13) -> list(int(13), int(42), int(0), int(-37)) # 0 Edge: int(42) -> list(int(13), int(42), int(0), int(-37)) # 1 -Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # b -Edge: str("hello") -> var(b) # b +Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # var:b +Edge: str("hello") -> var(b) # var:b Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a -Edge: str("t1") -> var(a) # a -Edge: str("t2") -> var(a) # a +Edge: str("t1") -> var(a) # var:a +Edge: str("t2") -> var(a) # var:a Edge: var(b) -> call:len(var(b)) # 0 Edge: var(b) -> call:len(var(b)) # 0 Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b))) diff --git a/lang/interpret_test/TestAstFunc1/recursive_module1.graph b/lang/interpret_test/TestAstFunc1/recursive_module1.graph index 53a88290..5fa1e913 100644 --- a/lang/interpret_test/TestAstFunc1/recursive_module1.graph +++ b/lang/interpret_test/TestAstFunc1/recursive_module1.graph @@ -1,8 +1,8 @@ -Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # h2g2.answer -Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # example1.name -Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # example1.name -Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # mod1.name -Edge: int(3) -> var(third.three) # third.three +Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer +Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name +Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name +Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name +Edge: int(3) -> var(third.three) # var:third.three Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # x Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # x @@ -16,16 +16,16 @@ Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s") Edge: str("i imported remote: %s and %s") -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a -Edge: str("this is the nested git module mod1") -> var(mod1.name) # mod1.name -Edge: str("this is the nested git module mod1") -> var(mod1.name) # mod1.name -Edge: str("this is the nested local module mod1") -> var(mod1.name) # mod1.name +Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name +Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name +Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # b Edge: var(ex1) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example2/ and i contain: "), var(ex1)) # b Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b -Edge: var(example1.name) -> var(ex1) # ex1 -Edge: var(example1.name) -> var(example2.ex1) # example2.ex1 +Edge: var(example1.name) -> var(ex1) # var:ex1 +Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1 Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # c -Edge: var(h2g2.answer) -> var(answer) # answer +Edge: var(h2g2.answer) -> var(answer) # var:answer Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b diff --git a/lang/interpret_test/TestAstFunc1/slow_unification0.graph b/lang/interpret_test/TestAstFunc1/slow_unification0.graph index 4710d2da..406c907f 100644 --- a/lang/interpret_test/TestAstFunc1/slow_unification0.graph +++ b/lang/interpret_test/TestAstFunc1/slow_unification0.graph @@ -1,27 +1,27 @@ Edge: call:_operator(str("=="), var(state), str("default")) -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # b Edge: call:_operator(str("=="), var(state), str("one")) -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # a -Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # state -Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # state -Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # state -Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # state -Edge: call:world.kvlookup(var(ns)) -> var(exchanged) # exchanged -Edge: str("") -> var(hostname) # hostname +Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state +Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state +Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state +Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state +Edge: call:world.kvlookup(var(ns)) -> var(exchanged) # var:exchanged +Edge: str("") -> var(hostname) # var:hostname Edge: str("==") -> call:_operator(str("=="), var(state), str("default")) # x Edge: str("==") -> call:_operator(str("=="), var(state), str("one")) # x Edge: str("==") -> call:_operator(str("=="), var(state), str("three")) # x Edge: str("==") -> call:_operator(str("=="), var(state), str("two")) # x Edge: str("default") -> call:_operator(str("=="), var(state), str("default")) # b Edge: str("default") -> call:maplookup(var(exchanged), var(hostname), str("default")) # default -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns -Edge: str("estate") -> var(ns) # ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns +Edge: str("estate") -> var(ns) # var:ns Edge: str("one") -> call:_operator(str("=="), var(state), str("one")) # b Edge: str("three") -> call:_operator(str("=="), var(state), str("three")) # b Edge: str("two") -> call:_operator(str("=="), var(state), str("two")) # b diff --git a/lang/structs.go b/lang/structs.go index cc679e8f..38b2f0b5 100644 --- a/lang/structs.go +++ b/lang/structs.go @@ -5617,7 +5617,7 @@ func (obj *ExprVar) Graph() (*pgraph.Graph, error) { return nil, err } - edge := &funcs.Edge{Args: []string{obj.Name}} + edge := &funcs.Edge{Args: []string{fmt.Sprintf("var:%s", obj.Name)}} var once bool edgeGenFn := func(v1, v2 pgraph.Vertex) pgraph.Edge { @@ -5671,7 +5671,7 @@ func (obj *ExprVar) Func() (interfaces.Func, error) { return &structs.VarFunc{ Type: typ, Func: f, - Edge: obj.Name, // the edge name used above in Graph is this... + Edge: fmt.Sprintf("var:%s", obj.Name), // the edge name used above in Graph is this... }, nil }