File Loading

A significant part of file loading was case analysis on the instruction type. A couple of macros were used to make the code shorter, but it essentially looks as follows:

if (instr_name == "acc")
  return new acc_instr();
if (instr_name == "return)
  return new return_instr();
if (instr_name == "const")
  return new const_instr(Value::parse_value(arg1));
...

Note that this sort of case analysis is necessary in many languages, not just object-oriented ones. One notable exception is Java. One can use reflection to automatically generate an instance of an object given only the name of the object in string representation. Since C++ doesn't have reflection, however, this wasn't an option.

All of the relevant parsing code is located in actor_parse.cpp.



Mason Smith 2008-06-11