Skip to content

Commit 6e7a5e2

Browse files
IvanIvan
authored andcommitted
Final clean up
1 parent 8e810f9 commit 6e7a5e2

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"version": "1.0",
3+
"functions": {
4+
"factorial": {
5+
"states": [
6+
{
7+
"name": "FactorialEntry",
8+
"local_vars": 1,
9+
"operations": [
10+
{
11+
"type": "push_stack",
12+
"entries": [
13+
{
14+
"Value": {
15+
"FactorialInput": {
16+
"var": "n"
17+
}
18+
}
19+
},
20+
{
21+
"Retrn": "FactorialDone"
22+
},
23+
{
24+
"Value": {
25+
"FactorialArgument": {
26+
"var": "n"
27+
}
28+
}
29+
},
30+
{
31+
"State": "FactorialRecursiveCall"
32+
}
33+
]
34+
}
35+
]
36+
},
37+
{
38+
"name": "FactorialRecursiveCall",
39+
"local_vars": 1,
40+
"operations": [
41+
{
42+
"type": "write",
43+
"text": "f({n})",
44+
"next_state": "FactorialRecursionPostWrite"
45+
}
46+
]
47+
},
48+
{
49+
"name": "FactorialRecursionPostWrite",
50+
"local_vars": 1,
51+
"operations": [
52+
{
53+
"type": "sleep",
54+
"ms": {
55+
"mul": [
56+
{
57+
"var": "n"
58+
},
59+
{
60+
"const": 50
61+
}
62+
]
63+
},
64+
"next_state": "FactorialRecursionPostSleep"
65+
}
66+
]
67+
},
68+
{
69+
"name": "FactorialRecursionPostSleep",
70+
"local_vars": 1,
71+
"operations": [
72+
{
73+
"type": "conditional",
74+
"condition": {
75+
"le": [
76+
{
77+
"var": "n"
78+
},
79+
{
80+
"const": 1
81+
}
82+
]
83+
},
84+
"then": [
85+
{
86+
"type": "return",
87+
"value": {
88+
"const": 1
89+
}
90+
}
91+
],
92+
"else": [
93+
{
94+
"type": "push_stack",
95+
"entries": [
96+
{
97+
"Retrn": "FactorialRecursionPostRecursiveCall"
98+
},
99+
{
100+
"Value": {
101+
"FactorialArgument": {
102+
"sub": [
103+
{
104+
"var": "n"
105+
},
106+
{
107+
"const": 1
108+
}
109+
]
110+
}
111+
}
112+
},
113+
{
114+
"State": "FactorialRecursiveCall"
115+
}
116+
]
117+
}
118+
]
119+
}
120+
]
121+
},
122+
{
123+
"name": "FactorialRecursionPostRecursiveCall",
124+
"local_vars": 2,
125+
"operations": [
126+
{
127+
"type": "return",
128+
"value": {
129+
"mul": [
130+
{
131+
"var": "n"
132+
},
133+
{
134+
"var": "result"
135+
}
136+
]
137+
}
138+
}
139+
]
140+
},
141+
{
142+
"name": "FactorialDone",
143+
"local_vars": 2,
144+
"operations": [
145+
{
146+
"type": "done"
147+
}
148+
]
149+
}
150+
]
151+
}
152+
},
153+
"entry_point": "factorial"
154+
}

0 commit comments

Comments
 (0)