Skip to content

Commit 67fa9f9

Browse files
committed
Engine: Do not compile unsupported top level blocks
1 parent 1e1cf4a commit 67fa9f9

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/engine/engine.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,24 @@ void Engine::compile()
7777
for (auto block : blocks) {
7878
if (block->topLevel()) {
7979
auto section = blockSection(block->opcode());
80-
Compiler compiler(this, block);
81-
compiler.setConstInputValues(constInputValues);
82-
compiler.setVariables(variables);
83-
compiler.setLists(lists);
84-
compiler.compile();
85-
variables = compiler.variables();
86-
lists = compiler.lists();
87-
constInputValues = compiler.constInputValues();
88-
auto vm = std::make_shared<VirtualMachine>();
89-
vm->setFunctions(m_functions);
90-
vm->setConstValues(compiler.constValues());
91-
vm->setVariables(compiler.variablePtrs());
92-
vm->setLists(lists);
93-
vm->setBytecode(compiler.bytecode());
94-
m_scripts[block] = vm;
80+
if (section) {
81+
Compiler compiler(this, block);
82+
compiler.setConstInputValues(constInputValues);
83+
compiler.setVariables(variables);
84+
compiler.setLists(lists);
85+
compiler.compile();
86+
variables = compiler.variables();
87+
lists = compiler.lists();
88+
constInputValues = compiler.constInputValues();
89+
auto vm = std::make_shared<VirtualMachine>();
90+
vm->setFunctions(m_functions);
91+
vm->setConstValues(compiler.constValues());
92+
vm->setVariables(compiler.variablePtrs());
93+
vm->setLists(lists);
94+
vm->setBytecode(compiler.bytecode());
95+
m_scripts[block] = vm;
96+
} else
97+
std::cout << "warning: unsupported top level block: " << block->opcode() << std::endl;
9598
}
9699
}
97100
}

0 commit comments

Comments
 (0)