-
Notifications
You must be signed in to change notification settings - Fork 0
/
Execution Engine.py
51 lines (43 loc) · 1.65 KB
/
Execution Engine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from concurrent.futures import ThreadPoolExecutor
import logging
class ExecutionEngine:
def __init__(self, ast):
self.ast = ast
self.global_vars = {}
def execute(self):
with ThreadPoolExecutor(max_workers=4) as executor:
futures = [executor.submit(self.execute_section, section) for section in self.ast]
for future in futures:
future.result()
def execute_section(self, section):
blocks = section['content']
for block in blocks:
action_type = block['type']
lines = block['content']
if action_type == '|*|':
self.execute_action(lines)
elif action_type == '|_|':
self.execute_statements(lines)
elif action_type == '|-|':
self.execute_request(lines)
elif action_type == '|(<::>^<::>)|':
self.execute_aot_scan(lines)
elif action_type == '|+|':
self.execute_simulation(lines)
# Add more cases as needed
def execute_action(self, lines):
for line in lines:
exec(line.strip(), self.global_vars)
def execute_statements(self, lines):
for line in lines:
exec(line.strip(), self.global_vars)
def execute_request(self, lines):
for line in lines:
exec(line.strip(), self.global_vars)
def execute_simulation(self, lines):
for line in lines:
exec(line.strip(), self.global_vars)
def execute_aot_scan(self, lines):
for line in lines:
exec(line.strip(), self.global_vars)
def execute_simulation(self, lines