@@ -103,12 +103,13 @@ void Compiler::addInstruction(Opcode opcode, std::initializer_list<unsigned int>
103103 m_bytecode.push_back (arg);
104104}
105105
106- /* ! Compiles the given input and adds it to the bytecode. */
107- void Compiler::addInput (Input *input )
106+ /* ! Compiles the given input (resolved by ID) and adds it to the bytecode. */
107+ void Compiler::addInput (int id )
108108{
109- switch (input->type ()) {
109+ auto in = input (id);
110+ switch (in->type ()) {
110111 case Input::Type::Shadow:
111- addInstruction (OP_CONST, { constIndex (input ->primaryValue ()) });
112+ addInstruction (OP_CONST, { constIndex (in ->primaryValue ()) });
112113 break ;
113114
114115 case Input::Type::NoShadow:
@@ -150,6 +151,17 @@ unsigned int Compiler::variableIndex(std::shared_ptr<IEntity> varEntity)
150151 return m_variables.size () - 1 ;
151152}
152153
154+ /* ! Returns the index of the given list. */
155+ unsigned int Compiler::listIndex (std::shared_ptr<IEntity> listEntity)
156+ {
157+ auto list = dynamic_cast <List *>(listEntity.get ());
158+ auto it = std::find (m_lists.begin (), m_lists.end (), list);
159+ if (it != m_lists.end ())
160+ return it - m_lists.begin ();
161+ m_lists.push_back (list);
162+ return m_lists.size () - 1 ;
163+ }
164+
153165unsigned int Compiler::constIndex (InputValue *value)
154166{
155167 auto it = std::find (m_constValues.begin (), m_constValues.end (), value);
0 commit comments