Most of the time, we don't need to have a dynamic call sub graph, since the actual function call could be represented statically as it originally was before lambda functions were implemented. Simplifying the graph shape has important performance benefits in terms of both keep the graph smaller (memory, etc) and in avoiding the need to run transactions at runtime (speed) to reshape the graph. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
77 lines
2.8 KiB
Plaintext
77 lines
2.8 KiB
Plaintext
-- main.mcl --
|
|
import "fmt"
|
|
|
|
# this value should only be built once
|
|
$some_value1 = 42 # or something more complex like the output of a slow function...
|
|
class foo($num) {
|
|
# we should have a different `$inside` value for each use of this class
|
|
$inside = $some_value1 + $some_value2 + 4
|
|
test [fmt.printf("test-%d-%d", $num, $inside),] {} # some resource
|
|
}
|
|
$some_value2 = 13 # check that non-ordering works too!
|
|
|
|
# We *don't* unnecessarily copy `4` on each include, because it's static!
|
|
include foo(1)
|
|
include foo(2)
|
|
include foo(3)
|
|
-- OUTPUT --
|
|
Edge: _operator -> _operator # a
|
|
Edge: _operator -> _operator # a
|
|
Edge: _operator -> _operator # a
|
|
Edge: _operator -> printf: func(format str, a int, b int) str # b
|
|
Edge: _operator -> printf: func(format str, a int, b int) str # b
|
|
Edge: _operator -> printf: func(format str, a int, b int) str # b
|
|
Edge: const: int(1) -> printf: func(format str, a int, b int) str # a
|
|
Edge: const: int(13) -> _operator # b
|
|
Edge: const: int(13) -> _operator # b
|
|
Edge: const: int(13) -> _operator # b
|
|
Edge: const: int(2) -> printf: func(format str, a int, b int) str # a
|
|
Edge: const: int(3) -> printf: func(format str, a int, b int) str # a
|
|
Edge: const: int(4) -> _operator # b
|
|
Edge: const: int(4) -> _operator # b
|
|
Edge: const: int(4) -> _operator # b
|
|
Edge: const: int(42) -> _operator # a
|
|
Edge: const: int(42) -> _operator # a
|
|
Edge: const: int(42) -> _operator # a
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("+") -> _operator # op
|
|
Edge: const: str("test-%d-%d") -> printf: func(format str, a int, b int) str # format
|
|
Edge: const: str("test-%d-%d") -> printf: func(format str, a int, b int) str # format
|
|
Edge: const: str("test-%d-%d") -> printf: func(format str, a int, b int) str # format
|
|
Edge: printf: func(format str, a int, b int) str -> composite: []str # 0
|
|
Edge: printf: func(format str, a int, b int) str -> composite: []str # 0
|
|
Edge: printf: func(format str, a int, b int) str -> composite: []str # 0
|
|
Vertex: _operator
|
|
Vertex: _operator
|
|
Vertex: _operator
|
|
Vertex: _operator
|
|
Vertex: _operator
|
|
Vertex: _operator
|
|
Vertex: composite: []str
|
|
Vertex: composite: []str
|
|
Vertex: composite: []str
|
|
Vertex: const: int(1)
|
|
Vertex: const: int(13)
|
|
Vertex: const: int(2)
|
|
Vertex: const: int(3)
|
|
Vertex: const: int(4)
|
|
Vertex: const: int(4)
|
|
Vertex: const: int(4)
|
|
Vertex: const: int(42)
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("+")
|
|
Vertex: const: str("test-%d-%d")
|
|
Vertex: const: str("test-%d-%d")
|
|
Vertex: const: str("test-%d-%d")
|
|
Vertex: printf: func(format str, a int, b int) str
|
|
Vertex: printf: func(format str, a int, b int) str
|
|
Vertex: printf: func(format str, a int, b int) str
|