@Override
public Obj invoke(Context context, Obj arg) {
// We don't care about the receiver.
arg = arg.getField(1);
Obj obj = context.getInterpreter().getConstructingObject();
// Initialize the parent classes from the record.
for (ClassObj parent : mClass.getParents()) {
Obj value = arg.getField(parent.getName());
if (value != null) {
context.getInterpreter().initializeNewObject(context, parent, value);
}
}
// Initialize the fields from the record.
for (Entry<String, FieldObj> field : mClass.getFieldDefinitions().entrySet()) {
// Assign it from the record.
Obj value = arg.getField(field.getKey());
if (value != null) {
obj.setField(field.getKey(), arg.getField(field.getKey()));
}
}